8 #ifndef META_OCEAN_IO_FILE_CONFIG_H
9 #define META_OCEAN_IO_FILE_CONFIG_H
38 typedef std::multimap<std::string, FileValue>
FileValues;
82 unsigned int values()
const override;
88 unsigned int values(
const std::string& name)
const override;
94 bool exist(
const std::string& name)
const override;
106 bool value(
const std::string& name,
const unsigned int index,
Value** value)
override;
118 bool value(
const unsigned int index, std::string& name,
Value** value)
override;
149 std::string
operator()(
const std::string& value)
const override;
155 std::vector<bool>
operator()(
const std::vector<bool>& value)
const override;
161 std::vector<int>
operator()(
const std::vector<int>& value)
const override;
167 std::vector<double>
operator()(
const std::vector<double>& value)
const override;
173 std::vector<std::string>
operator()(
const std::vector<std::string>& value)
const override;
203 bool operator=(
const std::vector<bool>& values)
override;
209 bool operator=(
const std::vector<int>& values)
override;
215 bool operator=(
const std::vector<double>& values)
override;
221 bool operator=(
const std::vector<std::string>& values)
override;
336 explicit FileConfig(
const std::string& filename,
const bool read =
true);
342 inline const std::string& filename()
const;
351 bool setFilename(
const std::string& filename,
const bool read =
true);
375 unsigned int values(
const std::string& name)
const override;
381 bool exist(
const std::string& name)
const override;
393 bool value(
const unsigned int index, std::string& name,
Value** value)
override;
405 bool value(
const std::string& name,
const unsigned int index,
Value** value)
override;
432 inline bool isEmpty()
const;
452 static bool write(
const FileValues& values, std::ostream& stream,
unsigned int offset);
460 static bool writeTabs(std::ostream& stream,
unsigned int offset);
This class implements a configuration value.
Definition: Config.h:77
This class implements an application or module configuration toolkit.
Definition: Config.h:38
ValueType
Definition of different value types.
Definition: Config.h:45
This scanner is able to scan the specific config file type.
Definition: FileConfig.h:286
ConfigScanner(const std::string &filename)
Creates a new config scanner object by a given filename.
Keyword
Definition of several keywords.
Definition: FileConfig.h:308
@ KEYWORD_TRUE
TRUE keyword.
Definition: FileConfig.h:310
Symbol
Definition of several symbols.
Definition: FileConfig.h:293
@ SYMBOL_CLOSE
Curly close brackets.
Definition: FileConfig.h:297
@ SYMBOL_BEGIN
Square open brackets.
Definition: FileConfig.h:299
@ SYMBOL_OPEN
Curly open brackets.
Definition: FileConfig.h:295
Definition of a file value object.
Definition: FileConfig.h:44
Value & operator[](const std::string &name) override
Returns a sub value specified by it's name.
bool operator()(const bool value) const override
Returns this value as boolean.
FileValue()=default
Creates a new value object.
std::string string_
Value as string.
Definition: FileConfig.h:276
std::vector< int > operator()(const std::vector< int > &value) const override
Returns this value as multi integer.
std::vector< double > numberValues() const
Returns the number values of this object.
std::string operator()(const std::string &value) const override
Returns this value as string.
bool value(const unsigned int index, std::string &name, Value **value) override
Returns a sub value specified by it's index.
std::vector< bool > operator()(const std::vector< bool > &value) const override
Returns this value as multi boolean.
bool operator=(const std::vector< double > &values) override
Sets this value as multi number.
FileValues subValues_
Sub values if this value is a group.
Definition: FileConfig.h:279
std::vector< int > integerValues() const
Returns the integer values of this object.
unsigned int values(const std::string &name) const override
Returns the number of sub values with a given name.
FileValue & value(const std::string &name, const unsigned int index) override
Returns a sub value specified by it's name and it's index if more than one value exists with the same...
FileValue(const FileValues &values)
Creates a new value object holding sub values.
std::vector< double > operator()(const std::vector< double > &value) const override
Returns this value as multi number.
~FileValue() override
Destructs a value object.
bool operator=(const double value) override
Sets this value as number.
bool exist(const std::string &name) const override
Returns whether this value holds at least one specified sub value.
bool operator=(const std::vector< std::string > &values) override
Sets this value as multi string.
bool value(const std::string &name, const unsigned int index, Value **value) override
Returns a sub value specified by it's name and it's index if more than one value exists with the same...
FileValue(const std::string &value, const ValueType type)
Creates a new value object by a single value as string and the real value type.
bool operator=(const std::vector< bool > &values) override
Sets this value as multi boolean.
int integerValue() const
Returns the integer value of this object.
std::vector< std::string > operator()(const std::vector< std::string > &value) const override
Returns this value as multi string.
bool operator=(const std::vector< int > &values) override
Sets this value as multi integer.
unsigned int values() const override
Returns the number of sub values.
bool boolValue() const
Returns the boolean value of this object.
FileValue & add(const std::string &name) override
Adds a new sub value specified by it's name.
std::vector< std::string > stringValues() const
Returns the string values of this object.
bool operator=(const int value) override
Sets this value as integer.
std::vector< bool > boolValues() const
Returns the boolean value of this object.
bool operator=(const bool value) override
Sets this value as boolean.
double operator()(const double value) const override
Returns this value as number.
FileValue(const FileValue &fileValue)=default
Default copy constructor.
FileValue & value(const unsigned int index, std::string &name) override
Returns a sub value specified by it's index.
int operator()(const int value) const override
Returns this value as integer.
double numberValue() const
Returns the number value of this object.
bool operator=(const std::string &value) override
Sets this value as string.
This class implements an application or module configuration toolkit using files as input or output.
Definition: FileConfig.h:29
static FileValue & nullValue()
Returns the default value holding no data.
bool value(const unsigned int index, std::string &name, Value **value) override
Returns a sub value specified by it's index.
static bool writeTabs(std::ostream &stream, unsigned int offset)
Writes a given number of tabs.
FileValues values_
Roots objects.
Definition: FileConfig.h:471
FileValue & value(const unsigned int index, std::string &name) override
Returns a sub value specified by it's index.
bool setFilename(const std::string &filename, const bool read=true)
Sets the filename of the new config objects.
std::string filename_
Filename of this config object.
Definition: FileConfig.h:474
bool read() override
Reads / loads all values of this configuration.
static bool write(const FileValues &values, std::ostream &stream, unsigned int offset)
Writes values to a stream with a given tab offset.
unsigned int values() const override
Returns the number of sub values.
FileConfig(const std::string &filename, const bool read=true)
Creates a new config object by a given configuration file.
bool exist(const std::string &name) const override
Returns whether this value holds at least one specified sub value.
FileValue & add(const std::string &name) override
Adds a new sub value specified by it's name.
std::multimap< std::string, FileValue > FileValues
Definition of a map mapping value names to value objects.
Definition: FileConfig.h:33
FileConfig()
Creates a new config object.
bool readSubValues(FileValues &values, Scanner &scanner, bool stopWithBrackets)
Reads sub values.
FileValue & value(const std::string &name, const unsigned int index) override
Returns a sub value specified by it's name and it's index if more than one value exists with the same...
bool value(const std::string &name, const unsigned int index, Value **value) override
Returns a sub value specified by it's name and it's index if more than one value exists with the same...
bool isEmpty() const
Returns whether this file configuration container does not hold any values.
Definition: FileConfig.h:482
bool write() override
Writes / saves all values of this configuration.
unsigned int values(const std::string &name) const override
Returns the number of sub values with a given name.
static bool write(const FileValues &values, std::ostream &stream)
Writes objects to a given output stream explicitly.
FileValue & operator[](const std::string &name) override
Returns a sub value specified by it's name.
const std::string & filename() const
Returns the config file.
Definition: FileConfig.h:477
This class implements a simple scanner.
Definition: Scanner.h:31
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15