Qore Programming Language  0.9.3.1
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 Methods

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 (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 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...
 

Private 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

◆ HashAssignmentHelper() [1/5]

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

constructor taking a const char*

Parameters
n_hthe hash to use
keythe key to assign
must_already_existif true, then this constructor will only succeed if the key already exists

◆ HashAssignmentHelper() [2/5]

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

constructor taking a const std::string&

Parameters
n_hthe hash to use
keythe key to assign
must_already_existif true, then this constructor will only succeed if the key already exists

◆ HashAssignmentHelper() [3/5]

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
xsinkthe container object for Qore-language exceptions, in case one is thrown trying to covert the key encoding to the default encoding
n_hthe hash to use
keythe key to assign
must_already_existif true, then this constructor will only succeed if the key already exists

◆ HashAssignmentHelper() [4/5]

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
xsinkthe container object for Qore-language exceptions, in case one is thrown trying to covert the key encoding to the default encoding
n_hthe hash to use
keythe key to assign
must_already_existif true, then this constructor will only succeed if the key already exists

◆ HashAssignmentHelper() [5/5]

DLLEXPORT HashAssignmentHelper::HashAssignmentHelper ( HashIterator hi)

constructor taking a HashIterator&

Parameters
hithe HashIterator to use for the key and hash

Member Function Documentation

◆ assign()

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)

◆ get()

DLLEXPORT QoreValue HashAssignmentHelper::get ( ) 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
Since
Qore 0.9

◆ operator bool()

DLLEXPORT HashAssignmentHelper::operator bool ( ) const

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

in case this function returns false

◆ operator*()

DLLEXPORT QoreValue HashAssignmentHelper::operator* ( ) const

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

Returns
the current value of the hash key

◆ reassign() [1/2]

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

reassigns the object to the given key for a new assignment

Parameters
keythe key to assign
must_already_existif true, then this function will not create a new key
Since
Qore 0.8.12

◆ reassign() [2/2]

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
keythe key to assign
must_already_existif true, then this function will not create a new key
Since
Qore 0.8.12

◆ swap()

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

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: