tbx
0.7.5
|
Maintain a simple set of string properties with their values. More...
#include <propertyset.h>
Public Member Functions | |
bool | exists (std::string name) const |
Check if property is a member of this property set. More... | |
void | set (std::string name, std::string value) |
Set the value of a string property. More... | |
void | set (std::string name, const char *value) |
Set the value of a string property from a C string. More... | |
std::string | get (std::string name, const char *def="") const |
Get the value of a property as a string. More... | |
void | set (std::string name, int value) |
Set the value of an integer property. More... | |
int | get (std::string name, int def) const |
Get the value of an integer property. More... | |
void | set (std::string name, bool value) |
Set the value of a boolean property. More... | |
bool | get (std::string name, bool def) const |
Get the value of an boolean property. More... | |
bool | erase (std::string name) |
Erases a property from the set. More... | |
void | set_indexed (std::string name, int index, std::string value) |
Set an indexed string property. More... | |
std::string | get_indexed (std::string name, int index, const char *def="") const |
Get the value of an indexed string property. More... | |
void | set_indexed (std::string name, int index, int value) |
Set an indexed integer property. More... | |
int | get_indexed (std::string name, int index, int def) const |
Get the value of an indexed integer property. More... | |
void | set_indexed (std::string name, int index, bool value) |
Set an indexed boolean property. More... | |
bool | get_indexed (std::string name, int index, bool def) const |
Get the value of an indexed boolean property. More... | |
bool | exists_indexed (std::string name, int index) |
Check if the property set contains the indexed property. More... | |
bool | erase_indexed (std::string name, int index) |
Erase an indexed property. More... | |
bool | write (std::ostream &os) const |
Writes the property list to a stream. More... | |
bool | read (std::istream &is) |
Reads the properties from a stream. More... | |
void | clear () |
Remove all properties from the property set. | |
bool | empty () |
Check if property set is empty. | |
bool | save (std::string file_name) const |
Save property set to a file. More... | |
bool | load (std::string file_name) |
Load property set from a file. More... | |
Protected Attributes | |
std::map< std::string, std::string > | _properties |
Underlying map to contain the properties. | |
Maintain a simple set of string properties with their values.
The property names are case sensitive
bool tbx::PropertySet::erase | ( | std::string | name | ) |
Erases a property from the set.
name | property name to erase |
bool tbx::PropertySet::erase_indexed | ( | std::string | name, |
int | index | ||
) |
Erase an indexed property.
name | property name to erased |
index | index to be appended to the property name |
bool tbx::PropertySet::exists | ( | std::string | name | ) | const |
Check if property is a member of this property set.
name | name of property to check |
bool tbx::PropertySet::exists_indexed | ( | std::string | name, |
int | index | ||
) |
Check if the property set contains the indexed property.
name | property name to check |
index | index to be appended to the property name |
std::string tbx::PropertySet::get | ( | std::string | name, |
const char * | def = "" |
||
) | const |
Get the value of a property as a string.
name | property name to get |
def | default value if the property is not in the property set |
int tbx::PropertySet::get | ( | std::string | name, |
int | def | ||
) | const |
Get the value of an integer property.
name | property name to get |
def | default value if the property is not in the property set |
bool tbx::PropertySet::get | ( | std::string | name, |
bool | def | ||
) | const |
Get the value of an boolean property.
name | property name to get |
def | default value if the property is not in the property set |
std::string tbx::PropertySet::get_indexed | ( | std::string | name, |
int | index, | ||
const char * | def = "" |
||
) | const |
Get the value of an indexed string property.
Short cut that just appends the index to the property name before using it in the above routines.
name | property name to get |
index | index to be appended to the property name |
def | default value if the property is not in the property set |
int tbx::PropertySet::get_indexed | ( | std::string | name, |
int | index, | ||
int | def | ||
) | const |
Get the value of an indexed integer property.
Short cut that just appends the index to the property name before using it in the above routines.
name | property name to get |
index | index to be appended to the property name |
def | default value if the property is not in the property set |
bool tbx::PropertySet::get_indexed | ( | std::string | name, |
int | index, | ||
bool | def | ||
) | const |
Get the value of an indexed boolean property.
Short cut that just appends the index to the property name before using it in the above routines.
name | property name to get |
index | index to be appended to the property name |
def | default value if the property is not in the property set |
bool tbx::PropertySet::load | ( | std::string | file_name | ) |
Load property set from a file.
file_name | name of file to load from |
bool tbx::PropertySet::read | ( | std::istream & | is | ) |
Reads the properties from a stream.
Property list is assumed to continue until the end of the stream
Note: Any string property values will have leading and trailing spaces removed.
is | stream to read properties from |
bool tbx::PropertySet::save | ( | std::string | file_name | ) | const |
Save property set to a file.
file_name | name of file to save to |
void tbx::PropertySet::set | ( | std::string | name, |
std::string | value | ||
) |
Set the value of a string property.
name | property name to set |
value | new value |
void tbx::PropertySet::set | ( | std::string | name, |
const char * | value | ||
) |
Set the value of a string property from a C string.
name | property name to set |
value | new value |
void tbx::PropertySet::set | ( | std::string | name, |
int | value | ||
) |
Set the value of an integer property.
name | property name to set |
value | new value |
void tbx::PropertySet::set | ( | std::string | name, |
bool | value | ||
) |
Set the value of a boolean property.
name | property name to set |
value | new value |
void tbx::PropertySet::set_indexed | ( | std::string | name, |
int | index, | ||
std::string | value | ||
) |
Set an indexed string property.
Short cut that just appends the index to the property name before using it in the above routines.
name | property name to set |
index | index to be appended to the property name |
value | new value |
void tbx::PropertySet::set_indexed | ( | std::string | name, |
int | index, | ||
int | value | ||
) |
Set an indexed integer property.
Short cut that just appends the index to the property name before using it in the above routines.
name | property name to set |
index | index to be appended to the property name |
value | new value |
void tbx::PropertySet::set_indexed | ( | std::string | name, |
int | index, | ||
bool | value | ||
) |
Set an indexed boolean property.
Short cut that just appends the index to the property name before using it in the above routines.
name | property name to set |
index | index to be appended to the property name |
value | new value |
bool tbx::PropertySet::write | ( | std::ostream & | os | ) | const |
Writes the property list to a stream.
os | stream to write list to |