Class CConfigFilePrefixer
Defined in File CConfigFilePrefixer.h
Inheritance Relationships
Base Type
public mrpt::config::CConfigFileBase(Class CConfigFileBase)
Class Documentation
-
class CConfigFilePrefixer : public mrpt::config::CConfigFileBase
A wrapper for other CConfigFileBase-based objects that prefixes a given token to every key and/or section. If, for example, your code expect:
[params1] foo = 34.0 bar = /dev/ttyUSB0
Using this class with key entries prefix
s1_will enable the same existing code to transparently parse this file content:[params1] s1_foo = 34.0 s1_bar = /dev/ttyUSB0
See: config_file_format
See also
Public Functions
-
CConfigFilePrefixer()
Unbound constructor: must bind this object to CConfigFileBase before usage with bind() and setPrefixes()
-
CConfigFilePrefixer(const CConfigFileBase &o, const std::string &prefix_sections, const std::string &prefix_keys)
Construct and bind to (wrap) a given object with given prefix texts
-
void bind(const CConfigFileBase &o)
Make this object to wrap the given existing CConfigFileBase object. Can be changed at any moment after construction
-
void setPrefixes(const std::string &prefix_sections, const std::string &prefix_keys)
Change the prefix for sections and keys. Can be called at any moment.
-
std::string getSectionPrefix() const
-
std::string getKeyPrefix() const
-
CConfigFileBase *getBoundConfigFileBase() const
Returns the currently-bounded config source, or nullptr if none.
-
~CConfigFilePrefixer() override
-
virtual void getAllSections(std::vector<std::string> §ions) const override
Returns a list with all the section names.
-
virtual void getAllKeys(const std::string §ion, std::vector<std::string> &keys) const override
Returns a list with all the keys into a section
-
virtual void clear() override
Empties the “config file”
Protected Functions
-
virtual void writeString(const std::string §ion, const std::string &name, const std::string &str) override
A virtual method to write a generic string.
-
virtual std::string readString(const std::string §ion, const std::string &name, const std::string &defaultStr, bool failIfNotFound = false) const override
A virtual method to read a generic string.
- Throws:
std::exception – If the key name is not found and “failIfNotFound” is true. Otherwise the “defaultValue” is returned.
-
CConfigFilePrefixer()