A map of references to base type scalars, arrays or std::string; changing values in either are equivalent operations.
More...
|
| template<class F > |
| ref_t & | link (const std::string &key, F &x) |
| | Associates a map entry with a variable.
|
| |
|
ref_t & | link (const std::string &key, void *ptr, const std::type_info &type, size_t count=1) |
| | Create a reference to a basic type or std::string. (Also for basetype arrays.)
|
| |
|
void | unlink (const std::string &key) |
| |
| template<class T2 > |
| void | copyStruct (const ReferenceMap2< T > &m, const T2 &src, T2 &dst, extLinkPolicy policy=RESERVE) |
| | Experimental. Copies references and values of a structure to another.
|
| |
| | SmartMap (char separator='\0', char arraySeparator=':') |
| |
|
| SmartMap (const SmartMap &smap) |
| |
| virtual void | clear () |
| |
|
bool | hasKey (const std::string &key) const |
| |
| std::string | get (const std::string &key, const std::string &defaultValue) const |
| | Retrieves a value, or default value if value is unset.
|
| |
|
std::string | get (const std::string &key, const char *defaultValue) const |
| |
| template<class T2 > |
| T2 | get (const std::string &key, const T2 &defaultValue) const |
| | Retrieves a value, if set, else returns the given default value.
|
| |
| virtual T & | operator[] (const std::string &key) |
| | Returns an element. Creates one, conditionally.
|
| |
| virtual const T & | operator[] (const std::string &key) const |
| | Unlike with std::map, operator[] const is defined, returning reference to a static empty instance.
|
| |
|
virtual const keylist_t & | getKeyList () const |
| | Derived versions may produce an ordered set of keys.
|
| |
| const map_t & | getMap () const |
| |
|
template<class T2 > |
| void | exportMap (std::map< std::string, T2 > &m) const |
| | Copies the contents to another map.
|
| |
| template<bool STRICT = true> |
| void | importEntries (const std::string &entries, char assignmentSymbol='=', char separatorSymbol=0) |
| | Assigns a value to given key; if the entry does not exist, tries to create it with directly with operator[].
|
| |
| template<bool STRICT = true> |
| void | importEntries (const std::list< std::string > &entries, char assignmentSymbol='=') |
| |
| template<class S , bool STRICT = true> |
| void | importMap (const std::map< std::string, S > &m) |
| | Assign values from a map, overriding existing entries.
|
| |
| template<class T2 , bool STRICT = true> |
| void | importCastableMap (const drain::SmartMap< T2 > &m) |
| | Assign values from a map, possibly extending the map.
|
| |
| template<class T2 > |
| void | updateFromMap (const std::map< std::string, T2 > &m) |
| | Assign values from a map. Updates existing entries only.
|
| |
|
template<class T2 > |
| void | updateFromCastableMap (const drain::SmartMap< T2 > &m) |
| | Convenience.
|
| |
|
void | setValues (const std::string &entries, char assignmentSymbol='=', char separatorSymbol=0) |
| | Sets values. If strictness==STRICTLY_CLOSED, throws exception if tries to assign a non-existing entry.
|
| |
|
void | setValues (const char *entries, char assignmentSymbol='=', char separatorSymbol=0) |
| |
|
template<class S > |
| void | setValuesSEQ (const S &sequence) |
| |
|
void | updateValues (const std::string &entries, char assignmentSymbol='=', char separatorSymbol=0) |
| | Sets applicable values ie. modifies existing entries only. In ordered maps, skips extra entries silently.
|
| |
|
void | getKeys (std::ostream &ostr) const |
| |
|
std::string | getKeys () const |
| | Convenience function for std::string output.
|
| |
|
void | getValues (std::ostream &ostr) const |
| | Dumps the values.
|
| |
|
std::string | getValues () const |
| | Convenience function for std::string output.
|
| |
|
std::ostream & | toStream (std::ostream &ostr, char equal='=', char startChar='{', char endChar='}', char separatorChar=',') const |
| | Note: parameters discarded.
|
| |
|
std::string | toStr (char equal='=', char start=0, char end=0, char separator=0) const |
| |
| void | dump (std::ostream &ostr=std::cout) const |
| | Write map as a JSON code.
|
| |
template<class T = Reference>
class drain::ReferenceMap2< T >
A map of references to base type scalars, arrays or std::string; changing values in either are equivalent operations.
New, templated implementation, extending support to FlexVariables, for example.
Future extension: units. Should be contained in Variable type, not "externally" in the map.
- Template Parameters
-
| T | SmartVariable: Reference or FlexibleVariable; in future, also Parameter<Reference> or Parameter<FlexibleVariable>. Must implement link() |