#include <mxmPerlStyleHash.h>
Inheritance diagram for mxmPerlStyleHash:
Public Member Functions | |
mxmPerlStyleHash (const mxmPerlStyleHash &other_hash) | |
mxmPerlStyleHash & | operator= (const mxmPerlStyleHash &other_hash) |
mxmString & | operator[] (const mxmString &key) |
Returns a reference to the value for a given key. | |
mxmString | value (const mxmString &key) const |
Also returns the value for a given key, but does not implicitly create the key if it is not present. | |
void | deleteKey (const mxmString &key) |
If present, the key/value pair addressed by the given key is purged from the hash. | |
void | setCaseInsensitiveKeysMode (bool enabled) |
Specify whether or not you want your keys to be treated case sensitively. | |
void | mergeKeys (const mxmPerlStyleHash &other_hash, const mxmStringList &allowed_key_mask, bool treat_mask_as_prefixes=false, const mxmString &target_key_prefix="") |
Merges in keys from the other hash, but only those that are cleared by the allowed_key_mask . | |
void | mergeKeysFromString (const mxmString &hash_string, const mxmString &pair_delimiters, const mxmString &key_value_separators, const mxmString &trim_chars) |
Merges in key/value pairs contained in the specified string. | |
mxm::smart< mxmStringList > | enumerateKeys (void) const |
Generates a list of all keys. | |
void | purgeValueCharacters (const mxmString &key, const mxmString &characters_to_purge) |
Removes all occurances of the characters specified from the value for the given key. | |
mxmString | concatenate (const mxmString &pair_separator=",", const mxmString &key_value_separator="=") const |
Converts the whole hash into a single string. | |
int | size (void) const |
(Re)implementation, to make sense with hashes. | |
mxmPerlStyleHash::Iterator | iterator (void) const |
Provides the calling context with an external iterator. | |
void | appendItemToTail (mxmObject *item) |
(Re)implementation, to make sense with hashes. | |
Static Public Member Functions | |
static mxmPerlStyleHash | emptyHash (void) |
Returns an empty hash. | |
static mxmPerlStyleHash | fromCommandLineArg (const mxmString &arg) |
Produces a hash from an appropriate command line argument. | |
Private Member Functions | |
void | init_mxmPerlStyleHash (void) |
Private Attributes | |
bool | CaseInsensitiveKeys |
void * | StableABIDataExtension |
Classes | |
class | Iterator |
Iterator implementation for mxmPerlStyleHash es. More... | |
class | KeyValuePair |
Represents one key/value string pair in a hash. More... | |
class | KeyValuePairDecider |
Installed with the mxmList, so only key/value pairs can be added. More... |
Since it is still an option to replace many of the camera software's Perl
scripts by small and efficient C++
applications, we tried to mimic with this class the convenient handling Perl
offers for this kind of data type.
Note that we are perfectly aware of the true meaning of the term hash
. However, within the context of this class we use it in the way Perl
does.
Note also that in contrast to Perl
hashes, for mxmHash es, the sequential ordering of the stored key/value pairs is significant - when iterating over a hash's key/value pairs, they are reproduced in the same order in which they were originally added to the hash.
Check out some stuff you can do to hashes:
mxmPerlStyleHash hash; mxmPerlStyleHash::KeyValuePair *key_value_pair;
hash["kai"] = "funz"; // add key/value pair hash["daniel"] = "kabs"; hash["david"] = "gruys"; hash["kai"] = "hergenroether"; // overwrite value printf("kai is %s\n", hash["kai"].text()); // access a key's value if(hash["steve"].isNull()) // check whether a key is printf("steve does not exist!\n"); // present hash.deleteKey("kai"); // purges a key printf("# hash entries : %d\n", hash.size()); // get number of keys
mxmPerlStyleHash::Iterator iter // read out all key/value = hash.iterator(); // pairs while(key_value_pair = static_cast<mxmPerlStyleHash::KeyValuePair *>(iter.nextItem())) { printf("-->%s = %s\n", key_value_pair->key()->text(), key_value_pair->value()->text()); }
[khe]
Kai Hergenroether
|
(Re)implementation, to make sense with hashes. A previous occurance of the respective key is wasted. The new key/value pair is appended to the tail of the list.
Not recommended not be used, however. Obsoleted by the
Reimplemented from mxmList. |
|
Returns a reference to the value for a given key.
In fact, this is the main hash class functionality. Use this operator to both set and retrieve key values. Setting key values happens by assigning to the string returned by the operator. If the string returned is a |
|
Specify whether or not you want your keys to be treated case sensitively. The default is case sensitive keys.
|
|
(Re)implementation, to make sense with hashes. This reimplementation is slow. Reimplemented from mxmList. |
|
Also returns the value for a given key, but does not implicitly create the key if it is not present.
For non-existent keys the method returns a |