RepastHPC
2.3.1
|
Map type object that contains key, value(string) properties. More...
#include <Properties.h>
Public Types | |
typedef boost::transform_iterator< KeyGetter, std::map< std::string, std::string >::const_iterator > | key_iterator |
Public Member Functions | |
Properties () | |
Creates an empty Properties. | |
Properties (const std::string &file, boost::mpi::communicator *comm=0, int maxPropFileSize=MAX_PROP_FILE_SIZE) | |
Creates a new Properties using the properties defined in the specified file. More... | |
Properties (const std::string &file, int argc, char **argv, boost::mpi::communicator *comm=0, int maxPropFileSize=MAX_PROP_FILE_SIZE) | |
Creates a new Properties using the properties defined in the specified file and any properties specified in Key=Val format in the argument array. More... | |
Properties (int argc, char **argv) | |
Creates a new Properties using the properties specified in Key=Val format in the argument. More... | |
void | putProperty (const std::string &key, std::string value) |
Puts a property into this Properties with the specified key and value. More... | |
void | putProperty (const std::string &key, long double value) |
Puts a property into this Properties with the specified key and value. More... | |
std::string | getProperty (const std::string &key) const |
Gets the property with the specified key. More... | |
bool | contains (const std::string &key) const |
Gets whether or not this Properties contains the specified key. More... | |
key_iterator | keys_begin () const |
Gets the start of an iterator over this Properties' keys. More... | |
key_iterator | keys_end () const |
Gets the end of an iterator over this Properties' keys. More... | |
void | readFile (const std::string &file, boost::mpi::communicator *comm=0, int maxPropFileSize=MAX_PROP_FILE_SIZE) |
Adds any properties defined in the specified file. More... | |
void | processCommandLineArguments (int argc, char **argv) |
Processes a char** array of the given size; any component that has an equals sign is entered as a property value, overriding any previous entry read from the properies file. More... | |
int | size () const |
Gets the number of properties in this Properties. More... | |
void | log (std::string logName, std::vector< std::string > *keysToWrite=0) |
Writes the contents of the properties file to the specified repast log (at 'INFO' log level) More... | |
void | writeToSVFile (std::string fileName, std::string separator=",") |
Writes the contents of the properties file to the specified separated-value file. More... | |
void | writeToSVFile (std::string fileName, std::vector< std::string > &keysToWrite, std::string separator=",") |
Writes the contents of the properties file to the specified separated-value file. More... | |
bool | writeToPropsFile (std::string filename, std::string header="") |
Writes the contents of this properties object to a file that could be read as another properties file. More... | |
bool | writeToPropsFile (std::string filename, std::vector< std::string > &keysToWrite, std::string header="") |
Writes the contents of this properties object to a file that could be read as another properties file, writing only the keys specified, in the order specified. More... | |
std::string | propsFileString (std::vector< std::string > &keysToWrite, std::string header="") |
Gets the string that will be written to a properties file using the writeToPropsFile methods. | |
Map type object that contains key, value(string) properties.
A Properties instance can be constructed from a file. Each line is a property with the key and value separated by =. For example,
some.property = 3
another.property = hello
repast::Properties::Properties | ( | const std::string & | file, |
boost::mpi::communicator * | comm = 0 , |
||
int | maxPropFileSize = MAX_PROP_FILE_SIZE |
||
) |
Creates a new Properties using the properties defined in the specified file.
Each line is a property with the key and value separated by =. For example,
some.property = 3
another.property = hello
file | the properties file path |
comm | pointer to a communicator; if null (the default), all processes read the properties file separately. If a communicator is provided, rank 0 reads the file and broadcasts it to all other ranks. |
maxPropFileSize | optional parameter; if the properties file is larger than the default MAX_PROP_FILE_SIZE, the new size can be passed here. |
repast::Properties::Properties | ( | const std::string & | file, |
int | argc, | ||
char ** | argv, | ||
boost::mpi::communicator * | comm = 0 , |
||
int | maxPropFileSize = MAX_PROP_FILE_SIZE |
||
) |
Creates a new Properties using the properties defined in the specified file and any properties specified in Key=Val format in the argument array.
Properties in the argument array will supersede any in the properties file.
Each line in the properties file is a property with the key and value separated by =. For example,
some.property = 3
another.property = hello
file | the properties file path |
argc | count of the elements in the argv array |
array | of char* that may include Key=Value pairs. Elements with no '=' are ignored. |
comm | pointer to a communicator; if null (the default), all processes read the properties file separately. If a communicator is provided, rank 0 reads the file and broadcasts it to all other ranks. |
maxPropFileSize | optional parameter; if the properties file is larger than the default MAX_PROP_FILE_SIZE, the new size can be passed here. |
repast::Properties::Properties | ( | int | argc, |
char ** | argv | ||
) |
Creates a new Properties using the properties specified in Key=Val format in the argument.
argc | count of the elements in the argv array |
array | of char* that may include Key=Value pairs. Elements with no '=' are ignored. |
bool repast::Properties::contains | ( | const std::string & | key | ) | const |
Gets whether or not this Properties contains the specified key.
key | the property key |
string repast::Properties::getProperty | ( | const std::string & | key | ) | const |
Gets the property with the specified key.
key | the property key |
|
inline |
Gets the start of an iterator over this Properties' keys.
|
inline |
Gets the end of an iterator over this Properties' keys.
|
inline |
Writes the contents of the properties file to the specified repast log (at 'INFO' log level)
logName | name of the log to use |
keysToWrite | optional; if included, writes only the keys included in the vector and their values, in the order they appear in the vector. Will write blank values for any key name in the vector that is not in the properties file. If not included, all properties and their values are written, in map order. |
void repast::Properties::processCommandLineArguments | ( | int | argc, |
char ** | argv | ||
) |
Processes a char** array of the given size; any component that has an equals sign is entered as a property value, overriding any previous entry read from the properies file.
argc | the number of entries in the array |
argv | the array of char values to be mapped |
void repast::Properties::putProperty | ( | const std::string & | key, |
long double | value | ||
) |
Puts a property into this Properties with the specified key and value.
Note that even though the second argument can be passed as a numeric value, it is stored as a string
key | the property key |
value | the property value |
void repast::Properties::putProperty | ( | const std::string & | key, |
std::string | value | ||
) |
Puts a property into this Properties with the specified key and value.
key | the property key |
value | the property value |
void repast::Properties::readFile | ( | const std::string & | file, |
boost::mpi::communicator * | comm = 0 , |
||
int | maxPropFileSize = MAX_PROP_FILE_SIZE |
||
) |
Adds any properties defined in the specified file.
Each line is a property with the key and value separated by =. For example,
some.property = 3
another.property = hello
file | the properties file path |
comm | pointer to a communicator; if null (the default), all processes read the properties file separately. If a communicator is provided, rank 0 reads the file and broadcasts it to all other ranks. |
|
inline |
Gets the number of properties in this Properties.
bool repast::Properties::writeToPropsFile | ( | std::string | filename, |
std::string | header = "" |
||
) |
Writes the contents of this properties object to a file that could be read as another properties file.
If a file with the specified name already exists, the existing file will not be changed and 'false' will be returned.
bool repast::Properties::writeToPropsFile | ( | std::string | filename, |
std::vector< std::string > & | keysToWrite, | ||
std::string | header = "" |
||
) |
Writes the contents of this properties object to a file that could be read as another properties file, writing only the keys specified, in the order specified.
If a file with the specified name already exists, the existing file will not be changed and 'false' will be returned.
void repast::Properties::writeToSVFile | ( | std::string | fileName, |
std::string | separator = "," |
||
) |
Writes the contents of the properties file to the specified separated-value file.
If the file does not exist it is created and a header line is written with the key values.
fileName | name |
void repast::Properties::writeToSVFile | ( | std::string | fileName, |
std::vector< std::string > & | keysToWrite, | ||
std::string | separator = "," |
||
) |
Writes the contents of the properties file to the specified separated-value file.
If the file does not exist it is created and a header line is written with the key values.
fileName | name |