22 #define THE_INI m_impl->m_ini 35 THE_INI.Load(aux.c_str(), aux.size());
42 THE_INI.Load(str.c_str(), str.size());
58 THE_INI.Load(aux.c_str(), aux.size());
63 THE_INI.Load(str.c_str(), str.size());
78 THE_INI.SetValue(section.c_str(),
name.c_str(), str.c_str(),
nullptr);
79 if (ret < 0)
THROW_EXCEPTION(
"Error changing value in INI-style file!");
86 const std::string& defaultStr,
bool failIfNotFound)
const 89 const char* defVal = failIfNotFound ? nullptr : defaultStr.c_str();
93 section.c_str(),
name.c_str(), defVal,
96 if (failIfNotFound && !aux)
100 "Value '%s' not found in section '%s' of memory configuration " 101 "string list and failIfNotFound=true.",
102 name.c_str(), section.c_str()));
109 if ((pos = ret.find(
"//")) != string::npos && pos > 0 &&
110 isspace(ret[pos - 1]))
111 ret = ret.substr(0, pos);
123 sections.resize(
names.size());
124 for (
n =
names.begin(),
s = sections.begin();
n !=
names.end(); ++
n, ++
s)
129 const string& section, std::vector<std::string>& keys)
const 136 keys.resize(
names.size());
This class implements a config file-like interface over a memory-stored string list.
CConfigFileMemory()
Empty constructor.
#define THROW_EXCEPTION(msg)
void stringListAsString(const std::vector< std::string > &lst, std::string &out, const std::string &newline="\")
Convert a string list to one single string with new-lines.
std::string getContent() const
void getAllKeys(const std::string §ion, std::vector< std::string > &keys) const override
Returs a list with all the keys into a section.
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.
GLsizei const GLchar ** string
void getAllSections(std::vector< std::string > §ions) const override
Returns a list with all the section names.
std::vector< string > names
mrpt::pimpl< Impl > m_impl
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void setContent(const std::vector< std::string > &stringList)
Changes the contents of the virtual "config file".
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLuint const GLchar * name
virtual ~CConfigFileMemory()
dtor
void writeString(const std::string §ion, const std::string &name, const std::string &str) override
A virtual method to write a generic string.
pimpl< T > make_impl(Args &&... args)
std::list< Entry > TNamesDepend
set of dependent string pointers.