$darkmode
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 (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 (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 () |
destroys the object and does post processing on the new value | |
DLLEXPORT void | assign (QoreValue 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 QoreValue | get () const |
returns the current value of the hash key; the pointer returned is still owned by the hash More... | |
DLLEXPORT const char * | getKey () const |
Returns the current key. More... | |
DLLEXPORT | operator bool () const |
returns true if the object is holding a valid pointer, false if not More... | |
DLLEXPORT QoreValue | operator* () const |
returns the current value of the hash key; any 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 QoreValue | swap (QoreValue 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 | |
use this class to make assignments to hash keys from a pointer to the key value
DLLEXPORT HashAssignmentHelper::HashAssignmentHelper | ( | QoreHashNode & | n_h, |
const char * | key, | ||
bool | must_already_exist = false |
||
) |
constructor taking a const char*
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&
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
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
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&
hi | the HashIterator to use for the key and hash |
DLLEXPORT void HashAssignmentHelper::assign | ( | QoreValue | 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 QoreValue HashAssignmentHelper::get | ( | ) | const |
returns the current value of the hash key; the pointer returned is still owned by the hash
DLLEXPORT const char* HashAssignmentHelper::getKey | ( | ) | const |
Returns the current key.
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 QoreValue HashAssignmentHelper::operator* | ( | ) | const |
returns the current value of the hash key; any pointer returned is still owned by the hash
DLLEXPORT void HashAssignmentHelper::reassign | ( | const char * | key, |
bool | must_already_exist = false |
||
) |
reassigns the object to the given key for a new assignment
key | the key to assign |
must_already_exist | if true, then this function will not create a new key |
DLLEXPORT void HashAssignmentHelper::reassign | ( | const std::string & | key, |
bool | must_already_exist = false |
||
) |
reassigns the object to the given key for a new assignment
key | the key to assign |
must_already_exist | if true, then this function will not create a new key |
DLLEXPORT QoreValue HashAssignmentHelper::swap | ( | QoreValue | 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