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

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

#include <FileProperties.h>

Classes

struct  Item
 
struct  RegistrPropertyParams
 

Public Types

typedef std::deque< std::string > KeyNameToID
 
typedef std::map< std::size_t,
RegistrPropertyParams
RegisteredProperties
 
typedef std::map< std::size_t,
Item
Values
 

Public Member Functions

void abandon ()
 Abandons the file stream ownership. More...
 
void close ()
 Closes the file stream. More...
 
 FilePropertiesT (FileT &file, bool isStreamOwner=true)
 Constructor. More...
 
void flush ()
 Flushes the stream . More...
 
bool get (const std::string &key, std::string *pValue) const
 Searches for the property with the specified key in this property list. More...
 
bool getBool (const std::string &key, bool *value) const
 
bool getInt (const std::string &key, int *value) const
 
void getProperties (std::set< std::string > *keys)
 Resturns set of the properties existing at the property file. More...
 
const FileT & getStream () const
 Returns the stream. More...
 
void registerProperty (const std::string &propName, unsigned int linePosition, int valueLength)
 Allow to set property position at the file. More...
 
void set (const std::string &key, const std::string &value, bool flushStream=false)
 Maps the specified key to the specified value. More...
 
void setBool (const std::string &key, bool value, bool flushStream=false)
 
void setInt (const std::string &key, int value, bool flushStream=false)
 
void setStr (const std::string &key, const char *value, int size, bool flushStream=false)
 
virtual ~FilePropertiesT ()
 Destructor. More...
 

Static Public Member Functions

static bool getBooleanProperty (FilePropertiesT *pProperties, const std::string &propertyName)
 Reads the boolean value from the properties. More...
 
static int getIntegerProperty (FilePropertiesT *pProperties, const std::string &propertyName)
 Reads the integer value from the given properties. More...
 
static std::string getStringProperty (FilePropertiesT *pProperties, const std::string &propertyName, bool isRequired=true)
 Reads the std::string value from the given properties. More...
 
static void trimWhiteSpace (std::string *apStr)
 Removes white space from both ends of the given std::string. More...
 

Detailed Description

template<typename FileT>
class Utils::FilePropertiesT< FileT >

This class represents a persistent set of properties.

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

Note
this class is synchronized.

Member Typedef Documentation

template<typename FileT>
typedef std::deque<std::string> Utils::FilePropertiesT< FileT >::KeyNameToID
template<typename FileT>
typedef std::map<std::size_t, RegistrPropertyParams> Utils::FilePropertiesT< FileT >::RegisteredProperties
template<typename FileT>
typedef std::map<std::size_t, Item> Utils::FilePropertiesT< FileT >::Values

Constructor & Destructor Documentation

template<typename FileT >
Utils::FilePropertiesT< FileT >::FilePropertiesT ( FileT &  file,
bool  isStreamOwner = true 
)

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). isStreamOwner - not used

Id:
FileProperties.cpp,v 1.16 2008/09/12 10:32:14 odp Exp
template<typename FileT >
Utils::FilePropertiesT< FileT >::~FilePropertiesT ( )
virtual

Destructor.

Member Function Documentation

template<typename FileT >
void Utils::FilePropertiesT< FileT >::abandon ( )

Abandons the file stream ownership.

template<typename FileT >
void Utils::FilePropertiesT< FileT >::close ( )

Closes the file stream.

template<typename FileT >
void Utils::FilePropertiesT< FileT >::flush ( )

Flushes the stream .

template<typename FileT >
bool Utils::FilePropertiesT< FileT >::get ( const std::string &  key,
std::string *  pValue 
) 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 pValue to the found value, false otherwise.

Referenced by Utils::FilePropertiesT< FileT >::getStringProperty().

template<typename FileT >
bool Utils::FilePropertiesT< FileT >::getBool ( const std::string &  key,
bool *  value 
) const
template<typename FileT >
bool Utils::FilePropertiesT< FileT >::getBooleanProperty ( FilePropertiesT< FileT > *  pProperties,
const std::string &  propertyName 
)
static

Reads the boolean value from the properties.

Exceptions
Utils::Exceptionif the key or value was not found.

References Utils::FilePropertiesT< FileT >::trimWhiteSpace().

template<typename FileT >
bool Utils::FilePropertiesT< FileT >::getInt ( const std::string &  key,
int *  value 
) const
template<typename FileT >
int Utils::FilePropertiesT< FileT >::getIntegerProperty ( FilePropertiesT< FileT > *  pProperties,
const std::string &  propertyName 
)
static

Reads the integer value from the given properties.

Exceptions
Utils::Exceptionif the key or value was not found.
template<typename FileT >
void Utils::FilePropertiesT< FileT >::getProperties ( std::set< std::string > *  keys)

Resturns set of the properties existing at the property file.

template<typename FileT >
const FileT & Utils::FilePropertiesT< FileT >::getStream ( ) const

Returns the stream.

template<typename FileT >
std::string Utils::FilePropertiesT< FileT >::getStringProperty ( FilePropertiesT< FileT > *  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.

References Utils::FilePropertiesT< FileT >::get().

template<typename FileT >
void Utils::FilePropertiesT< FileT >::registerProperty ( const std::string &  propName,
unsigned int  linePosition,
int  valueLength 
)

Allow to set property position at the file.

Parameters
propName- property name
linePosition- line, where this property have to be wrote. Valid values >= 0.
valueLength- max size of the property value. Valid values >0 and -1. When it '-1' - size undefined.
template<typename FileT >
void Utils::FilePropertiesT< FileT >::set ( const std::string &  key,
const std::string &  value,
bool  flushStream = false 
)

Maps the specified key to the specified value.

template<typename FileT >
void Utils::FilePropertiesT< FileT >::setBool ( const std::string &  key,
bool  value,
bool  flushStream = false 
)
template<typename FileT >
void Utils::FilePropertiesT< FileT >::setInt ( const std::string &  key,
int  value,
bool  flushStream = false 
)
template<typename FileT >
void Utils::FilePropertiesT< FileT >::setStr ( const std::string &  key,
const char *  value,
int  size,
bool  flushStream = false 
)
template<typename FileT >
void Utils::FilePropertiesT< FileT >::trimWhiteSpace ( std::string *  apStr)
static

Removes white space from both ends of the given std::string.

Referenced by Utils::FilePropertiesT< FileT >::getBooleanProperty().