VSM C++ SDK
Vehicle Specific Modules SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ugcs::vsm::Properties Class Reference

This class represents persistent set of properties which can be stored and loaded in/from any stream. More...

#include <properties.h>

Classes

class  Iterator
 Stored properties iterator. More...
 
struct  Not_convertible_exception_dummy_struct
 The value cannot be converted to the specified type from its string representation. More...
 
struct  Not_found_exception_dummy_struct
 Thrown when a specified key not found. More...
 
struct  Parse_exception_dummy_struct
 Thrown when text stream parsing fails. More...
 

Public Types

typedef std::shared_ptr
< Properties
Ptr
 Pointer type. More...
 
typedef
ugcs::vsm::Derived_exception
< Exception,
Parse_exception_dummy_struct
Parse_exception
 Definition of a new exception type. More...
 
typedef
ugcs::vsm::Derived_exception
< Exception,
Not_found_exception_dummy_struct
Not_found_exception
 Definition of a new exception type. More...
 
typedef
ugcs::vsm::Derived_exception
< Exception,
Not_convertible_exception_dummy_struct
Not_convertible_exception
 Definition of a new exception type. More...
 

Public Member Functions

 VSM_DEFINE_EXCEPTION (Exception)
 Base class for all Properties exceptions. More...
 
 Properties ()
 Construct empty properties. More...
 
void Load (std::istream &stream)
 Load properties from text stream. More...
 
bool Exists (const std::string &key) const
 Check if the property with the specified key exists. More...
 
std::string Get (const std::string &key) const
 Get string value of the property. More...
 
int32_t Get_int (const std::string &key) const
 Get integer value of the property. More...
 
double Get_float (const std::string &key) const
 Get floating point number value of the property. More...
 
void Set_description (const std::string &key, const std::string &description)
 Set the description of the property. More...
 
void Set (const std::string &key, const std::string &value)
 Set string value of the property. More...
 
void Set (const std::string &key, int32_t value)
 Set integer value of the property. More...
 
void Set (const std::string &key, double value)
 Set floating point number value of the property. More...
 
void Delete (const std::string &key)
 Delete the property with the specified key. More...
 
void Store (std::ostream &stream)
 Store properties into the specified stream. More...
 
Iterator begin (const std::string &prefix=std::string(), char separator= '.') const
 Begin properties iteration. More...
 
Iterator end () const
 Iterator for one-past-the-end position. More...
 

Static Public Member Functions

template<typename... Args>
static Ptr Get_instance (Args &&...args)
 Get global or create new properties instance. More...
 

Detailed Description

This class represents persistent set of properties which can be stored and loaded in/from any stream.

Each property is a key and its value. The format of the text representation and overall concepts are corresponding to Java properties - http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html.

Member Typedef Documentation

typedef std::shared_ptr<Properties> ugcs::vsm::Properties::Ptr

Pointer type.

Constructor & Destructor Documentation

ugcs::vsm::Properties::Properties ( )

Construct empty properties.

Member Function Documentation

Iterator ugcs::vsm::Properties::begin ( const std::string &  prefix = std::string(),
char  separator = '.' 
) const
inline

Begin properties iteration.

Parameters
prefixPrefix to match property name with.
separatorSeparator used for property name components separation.
Returns
Iterator object.
void ugcs::vsm::Properties::Delete ( const std::string &  key)

Delete the property with the specified key.

Parameters
keyKey of the property to delete.
Exceptions
Not_found_exceptionif the value with specified key is not found.
Iterator ugcs::vsm::Properties::end ( ) const
inline

Iterator for one-past-the-end position.

bool ugcs::vsm::Properties::Exists ( const std::string &  key) const

Check if the property with the specified key exists.

std::string ugcs::vsm::Properties::Get ( const std::string &  key) const

Get string value of the property.

Parameters
keyKey of the value to retrieve.
Returns
String representation of the value.
Exceptions
Not_found_exceptionValue with specified key is not found.
double ugcs::vsm::Properties::Get_float ( const std::string &  key) const

Get floating point number value of the property.

Parameters
keyKey of the value to retrieve.
Returns
Floating point number representation of the value.
Exceptions
Not_found_exceptionif the value with specified key is not found.
Not_convertible_exceptionif the value cannot be converted to floating point number representation.
template<typename... Args>
static Ptr ugcs::vsm::Properties::Get_instance ( Args &&...  args)
inlinestatic

Get global or create new properties instance.

int32_t ugcs::vsm::Properties::Get_int ( const std::string &  key) const

Get integer value of the property.

Base for the number is automatically detected - values which start by "0x" or "0X" prefix are interpreted as hexadecimal, started by "0" - as octal, all the rest as decimal.

Parameters
keyKey of the value to retrieve.
Returns
Integer representation of the value.
Exceptions
Not_found_exceptionif the value with specified key is not found.
Not_convertible_exceptionif the value cannot be converted to integer representation.
void ugcs::vsm::Properties::Load ( std::istream &  stream)

Load properties from text stream.

Parameters
streamInput text stream.
Exceptions
Parse_exceptionif invalid data read from the specified stream.
void ugcs::vsm::Properties::Set ( const std::string &  key,
const std::string &  value 
)

Set string value of the property.

If the key does not exist the new entry is added.

Parameters
keyKey for the new property.
valueString representation for the property.
void ugcs::vsm::Properties::Set ( const std::string &  key,
int32_t  value 
)

Set integer value of the property.

If the key does not exist the new entry is added.

Parameters
keyKey for the new property.
valueInteger representation for the property.
void ugcs::vsm::Properties::Set ( const std::string &  key,
double  value 
)

Set floating point number value of the property.

If the key does not exist the new entry is added.

Parameters
keyKey for the new property.
valueFloating point number representation for the property.
void ugcs::vsm::Properties::Set_description ( const std::string &  key,
const std::string &  description 
)

Set the description of the property.

If the key does not exist the new entry is added with no value.

Parameters
keyKey for the new property.
descriptionDescription string of the property. Can be multi-line (separated by
). Blank lines are allowed. All lines will be prepended by '#' on Store.
void ugcs::vsm::Properties::Store ( std::ostream &  stream)

Store properties into the specified stream.

ugcs::vsm::Properties::VSM_DEFINE_EXCEPTION ( Exception  )

Base class for all Properties exceptions.


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