Skip to content

DataMap

cliff-bohm edited this page Jun 23, 2016 · 9 revisions

A DataMap is used to collect arbitrary data about some object. The data is stored in a map, that is an unordered list of key value pairs. Data can be added to and removed from the DataMap. DataMaps also include functions to save their contents to files.

###Usage The Set() and Get() methods write values into and read values from a data Map. Append can be used to add lists of data one element at a time. See interface below for more instructions.

###Interface

template void Set(const string &key, const Type& value)
sets a key/value pair in DataMap
string Get(const string &key);
retrieve the value associated with "key"
template void Append(const string &key, const Type &value)
appends a value at "key" to a DataMap.
This creates a list with the format "[Value1,Value2,Value3,...]" associated with key. If Set() is used on a list, it will overwrite the list. If Append() is used with value what was assigned with Set(), an error will be reported and MABE will terminate.
void Clear(const string &key)
Clear the key and it's data from the DataMap
void ClearMap()
clear all keys (and data) from the DataMap
bool fieldExists(const string &key);
retrun true DataMap contains key
void writeToFile(const string &fileName, const vector& keys = { }) 
write the contents of this DataMap to fileName
This file will contain a header line with the key names. If keys is provided, then only write the values associated with keys.
vector getKeys()
return a vector with all of the keys in this DataMap
void SetMany(vector dataPairs);
takes a vector of string with key/value pairs. Calls Set() with each pair.
Clone this wiki locally