206{
210
211 boost::nowide::ifstream ifs(
path.string());
212 std::string line;
213 size_t idx_line = 0;
215 while (std::getline(ifs, line)) {
216#ifndef _MSVCVER
217
218 while (! line.empty() && line.back() == '\r')
219 line.pop_back();
220#endif
221 ++ idx_line;
222
224 if (*key == '#')
225
226 continue;
227
230
231 continue;
232
233 char *key_end = key;
234 bool maybe_semver = true;
235 for (; *key_end != 0; ++ key_end) {
236 if (std::isalnum(*key_end) || strchr("+.-", *key_end) != nullptr) {
237
238 } else if (*key_end == '_') {
239
240 maybe_semver = false;
241 } else
242
243 break;
244 }
245 if (*key_end != 0 && *key_end != ' ' && *key_end != '\t' && *key_end != '=')
246 throw file_parser_error(
"Invalid keyword or semantic version",
path, idx_line);
248 bool key_value_pair = *value == '=';
249 if (key_value_pair)
251 *key_end = 0;
252 boost::optional<Semver> semver;
253 if (maybe_semver)
255 if (key_value_pair) {
256 if (semver)
257 throw file_parser_error(
"Key cannot be a semantic version",
path, idx_line);\
258
260 if (strcmp(key, "min_slic3r_version") == 0 || strcmp(key, "max_slic3r_version") == 0) {
261 if (! svalue.empty())
263 if (! semver)
264 throw file_parser_error(std::string(key) +
" must referece a valid semantic version",
path, idx_line);
265 if (strcmp(key, "min_slic3r_version") == 0)
267 else
269 } else {
270
271 }
272 continue;
273 }
274 if (! semver)
275 throw file_parser_error(
"Invalid semantic version",
path, idx_line);
279 }
280
281
284}
std::string m_vendor
Definition Version.hpp:86
const boost::filesystem::path & path() const
Definition Version.hpp:79
boost::filesystem::path m_path
Definition Version.hpp:88
const_iterator end() const
Definition Version.hpp:68
static boost::optional< Semver > parse(const std::string &str)
Definition Semver.hpp:63
char * left_trim(char *c)
Definition Version.cpp:159
std::string unquote_version_comment(char *value, char *end, const std::string &path, int idx_line)
Definition Version.cpp:189
char * right_trim(char *start)
Definition Version.cpp:165
std::string unquote_value(char *value, char *end, const std::string &path, int idx_line)
Definition Version.cpp:173
Semver min_slic3r_version
Definition Version.hpp:22
std::string comment
Definition Version.hpp:28
Semver max_slic3r_version
Definition Version.hpp:26