32 CConfigFileBase::~CConfigFileBase() {}
33 void CConfigFileBase::write(
35 const int name_padding_width,
const int value_padding_width,
45 name_padding_width, value_padding_width, comment);
47 void CConfigFileBase::write(
49 const int name_padding_width,
const int value_padding_width,
55 ((std::abs(
value) > 1e-4f && std::abs(
value) < 1e4f) ||
60 name_padding_width, value_padding_width, comment);
65 void CConfigFileBase::writeString(
67 const int name_padding_width,
const int value_padding_width,
70 if (name_padding_width < 1 && value_padding_width < 1 && comment.empty())
71 this->writeString(section,
name, str);
74 if (name_padding_width >= 1)
76 "%*s", -name_padding_width,
82 if (value_padding_width >= 1)
84 " %*s", -value_padding_width,
95 this->writeString(section, name_pad, value_pad);
101 double CConfigFileBase::read_double(
103 bool failIfNotFound)
const 106 readString(section,
name,
format(
"%.16e", defaultValue), failIfNotFound)
113 float CConfigFileBase::read_float(
115 bool failIfNotFound)
const 118 readString(section,
name,
format(
"%.10e", defaultValue), failIfNotFound)
125 int CConfigFileBase::read_int(
127 bool failIfNotFound)
const 130 readString(section,
name,
format(
"%i", defaultValue), failIfNotFound)
139 bool failIfNotFound)
const 141 string s = readString(
142 section,
name,
format(
"%lu", (
long unsigned int)defaultValue),
150 bool CConfigFileBase::read_bool(
152 bool failIfNotFound)
const 157 section,
name,
string(defaultValue ?
"1" :
"0"),
159 if (
s ==
"true")
return true;
160 if (
s ==
"false")
return false;
161 if (
s ==
"yes")
return true;
162 if (
s ==
"no")
return false;
163 return (0 != atoi(
s.c_str()));
171 const std::string& defaultValue,
bool failIfNotFound)
const 174 readString(section,
name, defaultValue, failIfNotFound));
182 const std::string& defaultValue,
bool failIfNotFound)
const 184 string s = readString(section,
name, defaultValue, failIfNotFound);
185 std::vector<std::string> auxStrs;
193 "Value '%s' seems to be present in section '%s' but, are " 195 name.c_str(), section.c_str()));
205 bool CConfigFileBase::sectionExists(
const std::string& section_name)
const 207 std::vector<std::string> sects;
208 getAllSections(sects);
#define THROW_EXCEPTION(msg)
int MRPT_SAVE_NAME_PADDING()
Default padding sizes for macros MRPT_SAVE_CONFIG_VAR_COMMENT(), etc.
void tokenize(const std::string &inString, const std::string &inDelimiters, OUT_CONTAINER &outTokens, bool skipBlankTokens=true) noexcept
Tokenizes a string according to a set of delimiting characters.
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
int MRPT_SAVE_VALUE_PADDING()
static std::string & trim(std::string &s)
static int MRPT_SAVE_VALUE_PADDING
GLsizei const GLchar ** string
unsigned __int64 uint64_t
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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 _strcmpi(const char *str1, const char *str2) noexcept
An OS-independent version of strcmpi.