yaml解析字符串有注释时和`\t`抛异常
obqrn opened this issue · 2 comments
建议parse_value函数修改为
template <string_t U, class It>
IGUANA_INLINE void parse_value(U &value, It &&value_begin, It &&value_end) {
using T = std::decay_t;
auto start = value_begin;
auto end = value_end;
if (*value_begin == '"') {
++start;
--end;
if (*end != '"') [[unlikely]] {
for (; start < end && *end != '"';) {
--end;
}
if (*end != '"') [[unlikely]]
throw std::runtime_error(R"(Expected ")");
}
if constexpr (str_t) {
parse_escape_str(value, start, end);
return;
}
}
else if (*value_begin == ''') {
++start;
--end;
if (*end != ''') [[unlikely]] {
for (; start < end && *end != ''';) {
--end;
}
if (*end != ''') [[unlikely]]
throw std::runtime_error(R"(Expected ')");
}
}
value = T(&*start, static_cast<size_t>(std::distance(start, end)));
}
同时skip_space_and_lines修改
template
IGUANA_INLINE size_t skip_space_and_lines(auto &&it, auto &&end,
size_t minspaces) {
size_t res = minspaces;
while (it != end) {
if (*it == '\n') {
++it;
res = 0;
}
else if (*it == ' ') {
++it;
++res;
}
else if (*it == '\t') {
++it;
++res;
}
else if (*it == '#') {
while (it != end && *it != '\n') {
++it;
}
res = 0;
}
else {
if constexpr (Throw) {
if (res < minspaces) [[unlikely]] {
throw std::runtime_error("Indentation problem");
}
}
return res;
}
}
return res; // throw in certain situations ?
}
好的,谢谢,晚一点我会修复一下!你要想也可以提一个pr
已经修复了,虽然有点晚,并且全面支持了C++17