10 #ifndef _UGCS_VSM_PROPERTIES_H_
11 #define _UGCS_VSM_PROPERTIES_H_
30 typedef std::shared_ptr<Properties>
Ptr;
44 template <
typename... Args>
48 return singleton.Get_instance(std::forward<Args>(args)...);
60 Load(std::istream &stream);
64 Exists(
const std::string &key)
const;
73 Get(
const std::string &key)
const;
86 Get_int(
const std::string &key)
const;
109 Set_description(
const std::string &key,
const std::string &description);
118 Set(
const std::string &key,
const std::string &
value);
127 Set(
const std::string &key, int32_t
value);
136 Set(
const std::string &key,
double value);
144 Delete(
const std::string &key);
148 Store(std::ostream &stream);
155 std::string str_repr;
165 std::string description;
179 typedef std::map<std::string, Property> Table_type;
195 Iterator(
const Table_type::const_iterator &iterator,
196 const Table_type::const_iterator &end_iterator,
197 const std::string &prefix = std::string(),
198 char separator =
'.'):
199 table_iterator(iterator),
200 table_end(end_iterator),
211 if (table_iterator == table_end) {
213 "Dereferencing end iterator");
215 return table_iterator->first;
222 if (table_iterator == table_end) {
224 "Dereferencing end iterator");
226 return &table_iterator->first;
233 return table_iterator == it.table_iterator;
240 return !(*
this == it);
269 Table_type::const_iterator table_iterator, table_end;
285 begin(
const std::string &prefix = std::string(),
char separator =
'.')
const
287 return Iterator(table.begin(), table.end(), prefix, separator);
294 return Iterator(table.end(), table.end());
301 int last_sequence_number = 0;
309 Find_property(
const std::string &key)
const;
313 Find_property(
const std::string &key);
317 Escape(
const std::string &str,
bool is_key =
false);
std::shared_ptr< Properties > Ptr
Pointer type.
Definition: properties.h:30
void operator++(int)
Postfix increment operator.
Definition: properties.h:249
Singleton class definition.
void operator++()
Prefix increment operator.
bool operator==(const Iterator &it) const
Equality check method.
Definition: properties.h:231
void Store(std::ostream &stream)
Store properties into the specified stream.
static Ptr Get_instance(Args &&...args)
Get global or create new properties instance.
Definition: properties.h:46
Iterator end() const
Iterator for one-past-the-end position.
Definition: properties.h:292
void Set_description(const std::string &key, const std::string &description)
Set the description of the property.
This class represents persistent set of properties which can be stored and loaded in/from any stream...
Definition: properties.h:27
VSM exceptions definition.
std::string operator[](size_t comp_idx)
Get component of name with the specified index.
std::string Get(const std::string &key) const
Get string value of the property.
Stored properties iterator.
Definition: properties.h:186
#define VSM_DEFINE_DERIVED_EXCEPTION(__base_class, __exc_class)
Define custom derived exception.
Definition: exception.h:208
const std::string * operator->() const
Get the value.
Definition: properties.h:220
void Load(std::istream &stream)
Load properties from text stream.
Properties()
Construct empty properties.
bool Exists(const std::string &key) const
Check if the property with the specified key exists.
Definition: property.h:16
void Delete(const std::string &key)
Delete the property with the specified key.
bool operator!=(const Iterator &it) const
Non-equality check method.
Definition: properties.h:238
int32_t Get_int(const std::string &key) const
Get integer value of the property.
Iterator begin(const std::string &prefix=std::string(), char separator= '.') const
Begin properties iteration.
Definition: properties.h:285
VSM_DEFINE_EXCEPTION(Exception)
Base class for all Properties exceptions.
std::string operator*() const
Get the value.
Definition: properties.h:209
double Get_float(const std::string &key) const
Get floating point number value of the property.
void Set(const std::string &key, const std::string &value)
Set string value of the property.
Helper class for implementing singletons.
Definition: singleton.h:69
#define VSM_EXCEPTION(__exc_class, __msg,...)
Throw VSM exception instance.
Definition: exception.h:168
Iterator(const Table_type::const_iterator &iterator, const Table_type::const_iterator &end_iterator, const std::string &prefix=std::string(), char separator= '.')
Construct new iterator which iterates values starting from the given prefix.
Definition: properties.h:195
T value
Stored value (in wire byte order).
Definition: endian.h:376
Helper class for defining derived exceptions.
Definition: exception.h:133
Base class for all VSM exceptions.
Definition: exception.h:22