Keyple C++  0.9.0
Keyple, an Open Source SDK for Ticketing
Public Member Functions | List of all members
keyple::common::Properties Class Reference

#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
 

Constructor & Destructor Documentation

◆ Properties()

keyple::common::Properties::Properties ( )

Creates a new empty property list with no default values.

Member Function Documentation

◆ getProperty() [1/2]

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.

Parameters
keyThe key for this property
Returns
the value for the given key, or null if not found
See also
setProperty()
getProperty()

◆ getProperty() [2/2]

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.

Parameters
keyThe key for this property
defaultValueA default value
Returns
The value for the given key
See also
setProperty()

◆ load()

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 \uxxxx 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
Parameters
inStreamthe input stream
Exceptions
IOExceptionif an error occurred when reading the input
NullPointerExceptionif in is null

The documentation for this class was generated from the following files: