22 #define THE_INI static_cast<MRPT_CSimpleIni*>(m_ini.get()) 35 THE_INI->Load(aux.c_str(), aux.size());
47 THE_INI->Load(str.c_str(), str.size());
72 THE_INI->Load(str.c_str(), str.size());
84 THE_INI->Load(aux.c_str(), aux.size());
92 THE_INI->Load(str.c_str(), str.size());
116 THE_INI->SetValue(section.c_str(),
name.c_str(), str.c_str(),
nullptr);
117 if (ret < 0)
THROW_EXCEPTION(
"Error changing value in INI-style file!");
127 const std::string& defaultStr,
bool failIfNotFound)
const 130 const char* defVal = failIfNotFound ? nullptr : defaultStr.c_str();
135 section.c_str(),
name.c_str(), defVal,
138 if (failIfNotFound && !aux)
142 "Value '%s' not found in section '%s' of memory configuration " 143 "string list and failIfNotFound=true.",
144 name.c_str(), section.c_str()));
151 if ((pos = ret.find(
"//")) != string::npos && pos > 0 &&
152 isspace(ret[pos - 1]))
153 ret = ret.substr(0, pos);
164 static_cast<const MRPT_CSimpleIni*
>(m_ini.get())->GetAllSections(names);
168 sections.resize(names.size());
169 for (
n = names.begin(),
s = sections.begin();
n != names.end(); ++
n, ++
s)
181 ->GetAllKeys(section.c_str(), names);
185 keys.resize(names.size());
186 for (
n = names.begin(),
s = keys.begin();
n != names.end(); ++
n, ++
s)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void getAllSections(vector_string §ions) const override
Returns a list with all the section names.
#define THROW_EXCEPTION(msg)
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.
std::string getContent() const
This class implements a config file-like interface over a memory-stored string list.
std::vector< std::string > vector_string
A type for passing a vector of strings.
A class for storing a list of text lines.
CSimpleIniTempl< char, SI_GenericNoCase< char >, MRPT_IniFileParser > MRPT_CSimpleIni
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
virtual ~CConfigFileMemory()
dtor
CConfigFileMemory & operator=(const CConfigFileMemory &o)
Copy operator.
std::list< Entry > TNamesDepend
set of dependent string pointers.
GLuint const GLchar * name
void_ptr_noncopy m_ini
The IniFile object.
void writeString(const std::string §ion, const std::string &name, const std::string &str) override
A virtual method to write a generic string.
void getAllKeys(const std::string §ion, vector_string &keys) const override
Returs a list with all the keys into a section.
void getText(std::string &outText) const
Returns the whole string list as a single string with ' ' characters for newlines.
CConfigFileMemory()
Empty constructor.
void setContent(const utils::CStringList &stringList)
Changes the contents of the virtual "config file".