Library: OSP
Package: Util
Header: Poco/OSP/Properties.h
The Properties class manages a collection of key-value pairs.
Property keys are not case sensitive.
Member Functions: get, getBool, getFloat, getInt, has, keys, operator =, operator [], set, swap
typedef std::map < std::string, std::string, ILT > PropsMap;
Properties();
Creates an empty Properties object.
Properties(
const Properties & props
);
Creates a Properties object by copying another one.
~Properties();
Destroys the Properties object.
std::string get(
const std::string & key
) const;
Returns the value for the given key.
Throws a Poco::NotFoundException if the given key does not exist.
std::string get(
const std::string & key,
const std::string & deflt
) const;
Returns the value for the given key, or deflt if the key does not exist.
bool getBool(
const std::string & key
) const;
Returns the given value as a boolean. To be true, the string value must be something other than "false".
Throws a Poco::NotFoundException if the given key does not exist.
bool getBool(
const std::string & key,
bool deflt
) const;
Returns the given value as a boolean. To be true, the string value must be something other than "false".
Returns deflt if key does not exist.
double getFloat(
const std::string & key
) const;
Returns the given value as an integer.
Throws a Poco::NotFoundException if the given key does not exist and a Poco::SyntaxException if the property value is not a valid floating point number.
double getFloat(
const std::string & key,
double deflt
) const;
Returns the given value as a double.
Returns deflt if key does not exist.
int getInt(
const std::string & key
) const;
Returns the given value as an integer.
Throws a Poco::NotFoundException if the given key does not exist and a Poco::SyntaxException if the property value is not a valid integer.
int getInt(
const std::string & key,
int deflt
) const;
Returns the given value as an integer.
Returns deflt if key does not exist.
bool has(
const std::string & key
) const;
Returns true if and only if a property with the given key exists.
void keys(
std::vector < std::string > & keys
) const;
Fills the given vector with all keys.
Properties & operator = (
const Properties & props
);
Assigns another Properties object.
std::string operator[] (
const std::string & key
) const;
Returns the value for the given key.
Throws a Poco::NotFoundException if the given key does not exist.
void set(
const std::string & key,
const std::string & value
);
Adds a new or updates an existing property.
void swap(
Properties & props
);
Exchanges the contents of the Properties object with those from another one.