Keyple C++
0.9.0
Keyple, an Open Source SDK for Ticketing
|
#include <Properties.h>
Public Member Functions | |
Properties () | |
void | load (std::ifstream &inStream) |
std::string | getProperty (const std::string &key) const |
std::string | getProperty (const std::string &key, const std::string &defaultValue) const |
keyple::common::Properties::Properties | ( | ) |
Creates a new empty property list with no default values.
std::string keyple::common::Properties::getProperty | ( | const std::string & | key | ) | const |
Gets the property with the specified key in this property list. If the key is not found, the default property list is searched. If the property is not found in the default, null is returned.
key | The key for this property |
std::string keyple::common::Properties::getProperty | ( | const std::string & | key, |
const std::string & | defaultValue | ||
) | const |
Gets the property with the specified key in this property list. If the key is not found, the default property list is searched. If the property is not found in the default, the specified defaultValue is returned.
key | The key for this property |
defaultValue | A default value |
void keyple::common::Properties::load | ( | std::ifstream & | inStream | ) |
Reads a property list from an input stream. The stream should have the following format:
An empty line or a line starting with #
or !
is ignored. A backslash (\
) at the end of the line makes the line continueing on the next line (but make sure there is no whitespace after the backslash). Otherwise, each line describes a key/value pair.
The chars up to the first whitespace, = or : are the key. You can include this caracters in the key, if you precede them with a backslash (\
). The key is followed by optional whitespaces, optionally one =
or :
, and optionally some more whitespaces. The rest of the line is the resource belonging to the key.
Escape sequences \t, \n, \r, \\, \", \', \!, \#, \
(a space), and unicode characters with the \u
xxxx notation are detected, and converted to the corresponding single character.
# This is a comment key = value k\:5 \ a string starting with space and ending with newline
# This is a multiline specification; note that the value contains # no white space. weekdays: Sunday,Monday,Tuesday,Wednesday,\ Thursday,Friday,Saturday # The safest way to include a space at the end of a value: label = Name:\u0020
inStream | the input stream |
IOException | if an error occurred when reading the input |
NullPointerException | if in is null |