8#ifndef META_OCEAN_IO_FILE_CONFIG_H
9#define META_OCEAN_IO_FILE_CONFIG_H
38 using FileValues = std::multimap<std::string, FileValue>;
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;
342 inline const std::string&
filename()
const;
375 unsigned int values(
const std::string& name)
const override;
381 bool exist(
const std::string& name)
const override;
405 bool value(
const std::string& name,
const unsigned int index,
Value**
value)
override;
460 static bool writeTabs(std::ostream& stream,
unsigned int offset);
This class implements a configuration value.
Definition Config.h:77
Value()=default
Creates a new value object.
virtual ValueType type() const
Returns the type of this value.
Config()
Creates a new configuration toolkit.
ValueType
Definition of different value types.
Definition Config.h:45
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_FALSE
FALSE keyword.
Definition FileConfig.h:312
@ 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
@ SYMBOL_END
Square close brackets.
Definition FileConfig.h:301
Definition of a file value object.
Definition FileConfig.h:44
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::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.
Strings operator()(const Strings &value) const override
Returns this value as multi string.
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
unsigned int values(const std::string &name) const override
Returns the number of sub values with a given name.
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.
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...
std::vector< bool > boolValues() const
Returns the boolean value of this object.
bool exist(const std::string &name) const override
Returns whether this value holds at least one specified sub value.
Strings stringValues() const
Returns the string values of this object.
std::vector< int > integerValues() const
Returns the integer values of this object.
friend class FileConfig
Definition FileConfig.h:45
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.
FileValue & value(const unsigned int index, std::string &name) override
Returns a sub value specified by it's index.
std::vector< int > operator()(const std::vector< int > &value) const override
Returns this value as multi integer.
bool operator=(const Strings &values) override
Sets 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.
std::vector< double > numberValues() const
Returns the number values of this object.
Value & operator[](const std::string &name) override
Returns a sub value specified by it's name.
bool operator=(const int value) override
Sets this value as integer.
std::vector< bool > operator()(const std::vector< bool > &value) const override
Returns this value as multi boolean.
bool operator=(const bool value) override
Sets this value as boolean.
FileValue & add(const std::string &name) override
Adds a new sub value specified by it's name.
double operator()(const double value) const override
Returns this value as number.
FileValue(const FileValue &fileValue)=default
Default copy constructor.
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.
std::multimap< std::string, FileValue > FileValues
Definition of a map mapping value names to value objects.
Definition FileConfig.h:38
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
bool setFilename(const std::string &filename, const bool read=true)
Sets the filename of the new config objects.
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...
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.
static FileValue & nullValue()
Returns the default value holding no data.
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.
FileConfig()
Creates a new config object.
bool readSubValues(FileValues &values, Scanner &scanner, bool stopWithBrackets)
Reads sub values.
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 & value(const unsigned int index, std::string &name) override
Returns a sub value specified by it's index.
FileValue & add(const std::string &name) override
Adds a new sub value specified by it's name.
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:33
const std::string & filename() const
Returns the name of the input file, if the input is a file.
Definition Scanner.h:891
Scanner(const std::shared_ptr< std::istream > &stream, float *progress=nullptr, bool *cancel=nullptr)
Creates a new scanner using a stream as input.
std::vector< std::string > Strings
Definition of a vector holding strings.
Definition Base.h:162
Namespace of the Ocean IO library.
Definition Base64.h:17
The namespace covering the entire Ocean framework.
Definition Accessor.h:15