All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
HashAssignmentHelper Class Reference

use this class to make assignments to hash keys from a pointer to the key value More...

`#include <QoreHashNode.h>`

## Public Member Functions

DLLEXPORT | HashAssignmentHelper (QoreHashNode &n_h, const char *key, bool must_already_exist=false)
| constructor taking a const char* More...
DLLEXPORT | HashAssignmentHelper (QoreHashNode &n_h, const std::string &key, bool must_already_exist=false)
| constructor taking a const std::string& More...
DLLEXPORT | HashAssignmentHelper (ExceptionSink *xsink, QoreHashNode &n_h, const QoreString &key, bool must_already_exist=false)
| constructor taking a const QoreString& More...
DLLEXPORT | HashAssignmentHelper (ExceptionSink *xsink, QoreHashNode &n_h, const QoreString *key, bool must_already_exist=false)
| constructor taking a const QoreString& More...
DLLEXPORT | HashAssignmentHelper (HashIterator &hi)
| constructor taking a HashIterator& More...
DLLEXPORT | ~HashAssignmentHelper ()
| destroys the object and does post processing on the new value
DLLEXPORT void | assign (AbstractQoreNode *v, ExceptionSink *xsink)
| assigns a value to the hash key, dereferences any old value, assumes that the value is already referenced for the assignment More...
DLLEXPORT | operator bool () const
| returns true if the object is holding a valid pointer, false if not More...
DLLEXPORT AbstractQoreNode * | operator* () const
| returns the current value of the hash key; the pointer returned is still owned by the hash More...
DLLEXPORT void | reassign (const char *key, bool must_already_exist=false)
| reassigns the object to the given key for a new assignment More...
DLLEXPORT void | reassign (const std::string &key, bool must_already_exist=false)
| reassigns the object to the given key for a new assignment More...
DLLEXPORT AbstractQoreNode * | swap (AbstractQoreNode *v, ExceptionSink *xsink)
| swaps the current value with the new value of the hash key, assumes that the new value is already referenced for the assignment; returns the old value More...

## Protected Attributes

class hash_assignment_priv * | priv
| private implementation

## Detailed Description

use this class to make assignments to hash keys from a pointer to the key value

## Constructor & Destructor Documentation

DLLEXPORT HashAssignmentHelper::HashAssignmentHelper | ( | QoreHashNode & | n_h,
|  | const char * | key,
|  | bool | must_already_exist = `false`
| ) |  |

constructor taking a const char*

Parameters

  n_h | the hash to use
  key | the key to assign
  must_already_exist | if true, then this constructor will only succeed if the key already exists

DLLEXPORT HashAssignmentHelper::HashAssignmentHelper | ( | QoreHashNode & | n_h,
|  | const std::string & | key,
|  | bool | must_already_exist = `false`
| ) |  |

constructor taking a const std::string&

Parameters

  n_h | the hash to use
  key | the key to assign
  must_already_exist | if true, then this constructor will only succeed if the key already exists

DLLEXPORT HashAssignmentHelper::HashAssignmentHelper | ( | ExceptionSink * | xsink,
|  | QoreHashNode & | n_h,
|  | const QoreString & | key,
|  | bool | must_already_exist = `false`
| ) |  |

constructor taking a const QoreString&

this constructor may raise a Qore-language exception if the key argument cannot be successfully converted to the default encoding, in which case no further functions should be called on the object

Parameters

  xsink | the container object for Qore-language exceptions, in case one is thrown trying to covert the key encoding to the default encoding
  n_h | the hash to use
  key | the key to assign
  must_already_exist | if true, then this constructor will only succeed if the key already exists

DLLEXPORT HashAssignmentHelper::HashAssignmentHelper | ( | ExceptionSink * | xsink,
|  | QoreHashNode & | n_h,
|  | const QoreString * | key,
|  | bool | must_already_exist = `false`
| ) |  |

constructor taking a const QoreString&

this constructor may raise a Qore-language exception if the key argument cannot be successfully converted to the default encoding, in which case no further functions should be called on the object

Parameters

  xsink | the container object for Qore-language exceptions, in case one is thrown trying to covert the key encoding to the default encoding
  n_h | the hash to use
  key | the key to assign
  must_already_exist | if true, then this constructor will only succeed if the key already exists

DLLEXPORT HashAssignmentHelper::HashAssignmentHelper | ( | HashIterator & | hi | ) |

constructor taking a HashIterator&

Parameters

  hi | the HashIterator to use for the key and hash

## Member Function Documentation

DLLEXPORT void HashAssignmentHelper::assign | ( | AbstractQoreNode * | v,
|  | ExceptionSink * | xsink
| ) |  |

assigns a value to the hash key, dereferences any old value, assumes that the value is already referenced for the assignment

a Qore-language exception could be raised when the existing value is dereferenced (i.e. if it's an object that goes out of scope and the destructor raises an exception, for example)

DLLEXPORT HashAssignmentHelper::operator bool | ( |  | ) | const

returns true if the object is holding a valid pointer, false if not

in case this function returns false

DLLEXPORT AbstractQoreNode* HashAssignmentHelper::operator* | ( |  | ) | const

returns the current value of the hash key; the pointer returned is still owned by the hash

Returns
  the current value of the hash key

DLLEXPORT void HashAssignmentHelper::reassign | ( | const char * | key,
|  | bool | must_already_exist = `false`
| ) |  |

reassigns the object to the given key for a new assignment

Parameters

  key | the key to assign
  must_already_exist | if true, then this function will not create a new key

Since
  Qore 0.8.12

DLLEXPORT void HashAssignmentHelper::reassign | ( | const std::string & | key,
|  | bool | must_already_exist = `false`
| ) |  |

reassigns the object to the given key for a new assignment

Parameters

  key | the key to assign
  must_already_exist | if true, then this function will not create a new key

Since
  Qore 0.8.12

DLLEXPORT AbstractQoreNode* HashAssignmentHelper::swap | ( | AbstractQoreNode * | v,
|  | ExceptionSink * | xsink
| ) |  |

swaps the current value with the new value of the hash key, assumes that the new value is already referenced for the assignment; returns the old value

could throw a Qore-language exception if there is a type error; in this case 0 is returned and the value passed for the assignment is dereferenced

Returns
  the old value of the hash key including its reference count (the old value is not dereferenced); the caller owns the value returned

The documentation for this class was generated from the following file:

- include/qore/QoreHashNode.h (6de6cc3b438610bf03b2bec44a3d7c61f90e3165)