B2BITS FIX Antenna HFT  1.0.16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Utils::Properties Class Reference

This class represents a persistent set of properties. More...

#include <Properties.h>

Public Types

typedef std::vector< std::string > Keys
 Collection of keys. More...
 

Public Member Functions

void assign (const Properties &other)
 Copies values from other to internal property storage. More...
 
void clear ()
 Resets Properties instance. More...
 
bool get (const std::string &key, std::string *value=NULL) const
 Searches for the property with the specified key in this property list. More...
 
bool getBool (const std::string &key, bool *value) const
 
bool getBoolean (const std::string &propertyName) const
 Reads the boolean value from the properties. More...
 
bool getInt (const std::string &key, int *value) const
 
int getInteger (const std::string &propertyName, int minValue=-INT_MAX, int maxValue=INT_MAX) const
 Reads the integer value from the given properties. More...
 
void getKeys (Keys *keys) const
 Return a collection of current keys. More...
 
std::string getString (const std::string &propertyName, bool isRequired=true) const
 Reads the std::string value from the given properties. More...
 
void load (std::istream *apIStream, PropertyDecoder *decoder=NULL)
 Reads a property list (key and element pairs) from the input stream. More...
 
Propertiesoperator= (const Properties &other)
 Assing operator. More...
 
 Properties ()
 Constructor. More...
 
 Properties (std::istream *apIStream, PropertyDecoder *decoder=NULL)
 Constructor. More...
 
 Properties (const std::map< std::string, std::string > &settings, PropertyDecoder *decoder=NULL)
 Constructor. More...
 
 Properties (const Properties &other)
 Copy constructor. More...
 
void save (std::ostream *outStream)
 Saves the properties. More...
 
void set (const std::string &key, const std::string &value)
 Maps the specified key to the specified value. More...
 
void set_nolock (const std::string &key, const std::string &value)
 
void setBool (const std::string &key, bool value)
 
void setInt (const std::string &key, int value)
 
virtual ~Properties ()
 Destructor. More...
 

Static Public Member Functions

static bool getBooleanProperty (const Utils::Properties *pProperties, const std::string &propertyName)
 Reads the boolean value from the properties. More...
 
static bool getBoolProperty (const Utils::Properties *pProperties, const std::string &propertyName, bool isRequired=true)
 
static int getIntegerProperty (const Utils::Properties *properties, const std::string &propertyName, int minValue=-INT_MAX, int maxValue=INT_MAX)
 Reads the integer value from the given properties. More...
 
static int getIntProperty (const Utils::Properties *pProperties, const std::string &propertyName, bool isRequired=true)
 
static std::string getStringProperty (const Utils::Properties *pProperties, const std::string &propertyName, bool isRequired=true)
 Reads the std::string value from the given properties. More...
 

Detailed Description

This class represents a persistent set of properties.

The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a std::string.

This class is synchronized.

Member Typedef Documentation

typedef std::vector<std::string> Utils::Properties::Keys

Collection of keys.

Constructor & Destructor Documentation

Utils::Properties::Properties ( )

Constructor.

Creates an empty property list with no default values.

Utils::Properties::Properties ( std::istream *  apIStream,
PropertyDecoder decoder = NULL 
)
explicit

Constructor.

Reads a property list (key and element pairs) from the input stream.

A line that contains only whitespace or whose first non-whitespace character is an ASCII # or ! is ignored (thus, # or ! indicate comment lines).

Utils::Properties::Properties ( const std::map< std::string, std::string > &  settings,
PropertyDecoder decoder = NULL 
)
explicit

Constructor.

Creates a property list by the given map.

virtual Utils::Properties::~Properties ( )
virtual

Destructor.

Utils::Properties::Properties ( const Properties other)

Copy constructor.

Member Function Documentation

void Utils::Properties::assign ( const Properties other)

Copies values from other to internal property storage.

void Utils::Properties::clear ( )

Resets Properties instance.

bool Utils::Properties::get ( const std::string &  key,
std::string *  value = NULL 
) const

Searches for the property with the specified key in this property list.

Returns
true if the key is found in this property list and sets apValue to the found value, false otherwise.
bool Utils::Properties::getBool ( const std::string &  key,
bool *  value 
) const
bool Utils::Properties::getBoolean ( const std::string &  propertyName) const

Reads the boolean value from the properties.

Exceptions
Utils::Exceptionif the key or value was not found.
static bool Utils::Properties::getBooleanProperty ( const Utils::Properties pProperties,
const std::string &  propertyName 
)
static

Reads the boolean value from the properties.

Exceptions
Utils::Exceptionif the key or value was not found.
static bool Utils::Properties::getBoolProperty ( const Utils::Properties pProperties,
const std::string &  propertyName,
bool  isRequired = true 
)
static
bool Utils::Properties::getInt ( const std::string &  key,
int *  value 
) const
int Utils::Properties::getInteger ( const std::string &  propertyName,
int  minValue = -INT_MAX,
int  maxValue = INT_MAX 
) const

Reads the integer value from the given properties.

Parameters
propertyNameThe property name.
minValuethe minimum value.
maxValuethe maximum value.
Exceptions
Utils::Exceptionif the key or value was not found or the value is out-of-range.
static int Utils::Properties::getIntegerProperty ( const Utils::Properties properties,
const std::string &  propertyName,
int  minValue = -INT_MAX,
int  maxValue = INT_MAX 
)
static

Reads the integer value from the given properties.

Parameters
propertiesThe source properties.
propertyNameThe property name.
minValuethe minimum value.
maxValuethe maximum value.
Exceptions
Utils::Exceptionif the key or value was not found or the value is out-of-range.
static int Utils::Properties::getIntProperty ( const Utils::Properties pProperties,
const std::string &  propertyName,
bool  isRequired = true 
)
static
void Utils::Properties::getKeys ( Keys keys) const

Return a collection of current keys.

Note
Not synchronized.

Referenced by FixProtocols::createCustomProtocols().

std::string Utils::Properties::getString ( const std::string &  propertyName,
bool  isRequired = true 
) const

Reads the std::string value from the given properties.

Exceptions
Utils::Exceptionif isRequired is "true" and the key or value was not found.

Referenced by FixProtocols::createCustomProtocols(), and FixProtocols::loadProtocolFile().

static std::string Utils::Properties::getStringProperty ( const Utils::Properties pProperties,
const std::string &  propertyName,
bool  isRequired = true 
)
static

Reads the std::string value from the given properties.

Exceptions
Utils::Exceptionif isRequired is "true" and the key or value was not found.
void Utils::Properties::load ( std::istream *  apIStream,
PropertyDecoder decoder = NULL 
)

Reads a property list (key and element pairs) from the input stream.

A line that contains only whitespace or whose first non-whitespace character is an ASCII # or ! is ignored (thus, # or ! indicate comment lines).

Properties& Utils::Properties::operator= ( const Properties other)

Assing operator.

void Utils::Properties::save ( std::ostream *  outStream)

Saves the properties.

void Utils::Properties::set ( const std::string &  key,
const std::string &  value 
)

Maps the specified key to the specified value.

void Utils::Properties::set_nolock ( const std::string &  key,
const std::string &  value 
)
void Utils::Properties::setBool ( const std::string &  key,
bool  value 
)
void Utils::Properties::setInt ( const std::string &  key,
int  value 
)