23 CConfigFileBase::~CConfigFileBase()
29 writeString(section,
name,
format(((std::abs(
value)>1e-4 && std::abs(
value)<1e4 ) ||
value==.0)?
"%f" :
"%e",
value), name_padding_width,value_padding_width,comment);
33 writeString(section,
name,
format(((std::abs(
value)>1e-4f && std::abs(
value)<1e4f ) ||
value==.0f) ?
"%f" :
"%e",
value), name_padding_width,value_padding_width,comment);
39 if (name_padding_width<1 && value_padding_width<1 && comment.empty())
40 this->writeString(section,
name,str);
43 if (name_padding_width>=1)
48 if (value_padding_width>=1)
49 value_pad =
mrpt::format(
" %*s",-value_padding_width, str.c_str());
58 this->writeString(section,name_pad,value_pad);
65 double CConfigFileBase::read_double(
const std::string §ion,
const std::string &
name,
double defaultValue,
bool failIfNotFound )
const 67 return atof( readString(section,
name,
format(
"%.16e",defaultValue),failIfNotFound).c_str());
75 return (
float)atof( readString(section,
name,
format(
"%.10e",defaultValue),failIfNotFound).c_str());
83 return atoi( readString(section,
name,
format(
"%i",defaultValue),failIfNotFound).c_str());
92 string s = readString(section,
name,
format(
"%lu",(
long unsigned int)defaultValue),failIfNotFound);
102 if (
s==
"true")
return true;
103 if (
s==
"false")
return false;
104 if (
s==
"yes")
return true;
105 if (
s==
"no")
return false;
106 return (0 != atoi(
s.c_str()));
122 string s = readString(section,
name, defaultValue,failIfNotFound );
135 else return auxStrs[0];
139 bool CConfigFileBase::sectionExists(
const std::string §ion_name)
const 142 getAllSections(sects);
int BASE_IMPEXP MRPT_SAVE_VALUE_PADDING
Default padding sizes for macros MRPT_SAVE_CONFIG_VAR_COMMENT(), etc.
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.
std::string BASE_IMPEXP lowerCase(const std::string &str)
Returns an lower-case version of a string.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
unsigned __int64 uint64_t
int BASE_IMPEXP _strcmpi(const char *str1, const char *str2) MRPT_NO_THROWS
An OS-independent version of strcmpi.
GLuint const GLchar * name
uint64_t BASE_IMPEXP _strtoull(const char *nptr, char **endptr, int base)
An OS-independent version of strtoull.
std::string BASE_IMPEXP trim(const std::string &str)
Removes leading and trailing spaces.
GLenum GLsizei GLenum format
GLsizei const GLfloat * value
void BASE_IMPEXP tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
Tokenizes a string according to a set of delimiting characters.
int BASE_IMPEXP MRPT_SAVE_NAME_PADDING