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);