25 CConfigFileBase::~CConfigFileBase() {}
26 void CConfigFileBase::write(
28 const int name_padding_width,
const int value_padding_width,
38 name_padding_width, value_padding_width, comment);
40 void CConfigFileBase::write(
42 const int name_padding_width,
const int value_padding_width,
48 ((std::abs(
value) > 1e-4f && std::abs(
value) < 1e4f) ||
53 name_padding_width, value_padding_width, comment);
58 void CConfigFileBase::writeString(
60 const int name_padding_width,
const int value_padding_width,
63 if (name_padding_width < 1 && value_padding_width < 1 && comment.empty())
64 this->writeString(section,
name, str);
67 if (name_padding_width >= 1)
69 "%*s", -name_padding_width,
75 if (value_padding_width >= 1)
77 " %*s", -value_padding_width,
88 this->writeString(section, name_pad, value_pad);
94 double CConfigFileBase::read_double(
96 bool failIfNotFound)
const 99 readString(section,
name,
format(
"%.16e", defaultValue), failIfNotFound)
106 float CConfigFileBase::read_float(
108 bool failIfNotFound)
const 111 readString(section,
name,
format(
"%.10e", defaultValue), failIfNotFound)
118 int CConfigFileBase::read_int(
120 bool failIfNotFound)
const 123 readString(section,
name,
format(
"%i", defaultValue), failIfNotFound)
132 bool failIfNotFound)
const 134 string s = readString(
135 section,
name,
format(
"%lu", (
long unsigned int)defaultValue),
143 bool CConfigFileBase::read_bool(
145 bool failIfNotFound)
const 150 section,
name,
string(defaultValue ?
"1" :
"0"),
152 if (
s ==
"true")
return true;
153 if (
s ==
"false")
return false;
154 if (
s ==
"yes")
return true;
155 if (
s ==
"no")
return false;
156 return (0 != atoi(
s.c_str()));
164 const std::string& defaultValue,
bool failIfNotFound)
const 167 readString(section,
name, defaultValue, failIfNotFound));
175 const std::string& defaultValue,
bool failIfNotFound)
const 177 string s = readString(section,
name, defaultValue, failIfNotFound);
186 "Value '%s' seems to be present in section '%s' but, are " 188 name.c_str(), section.c_str()));
198 bool CConfigFileBase::sectionExists(
const std::string& section_name)
const 201 getAllSections(sects);
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
#define THROW_EXCEPTION(msg)
std::vector< std::string > vector_string
A type for passing a vector of strings.
int MRPT_SAVE_NAME_PADDING()
Default padding sizes for macros MRPT_SAVE_CONFIG_VAR_COMMENT(), etc.
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
static int MRPT_SAVE_VALUE_PADDING
GLsizei const GLchar ** string
void tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) noexcept
Tokenizes a string according to a set of delimiting characters.
unsigned __int64 uint64_t
GLuint const GLchar * name
uint64_t _strtoull(const char *nptr, char **endptr, int base)
An OS-independent version of strtoull.
std::string trim(const std::string &str)
Removes leading and trailing spaces.
static int MRPT_SAVE_NAME_PADDING
GLenum GLsizei GLenum format
GLsizei const GLfloat * value
int MRPT_SAVE_VALUE_PADDING()
int _strcmpi(const char *str1, const char *str2) noexcept
An OS-independent version of strcmpi.