本文整理汇总了C++中ErrorHandler::valid方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorHandler::valid方法的具体用法?C++ ErrorHandler::valid怎么用?C++ ErrorHandler::valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::valid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseObject
inline Iterator parseObject(Iterator begin, Iterator end, ObjectBodyParser objectBodyParser, ErrorHandler &errorHandler)
{
Iterator i = skipLeadingSpaces<spacePolicy>(begin, end);
if (unlikely(i == end)) {
goto prematureEnd;
}
if (unlikely(*i != u8"{"[0])) {
goto malformedJson;
}
i = objectBodyParser(++i, end, errorHandler);
if (unlikely(!errorHandler.valid())) {
return end;
}
if (unlikely(i == end)) {
goto prematureEnd;
}
if (unlikely(*i != u8"}"[0])) {
goto malformedJson;
}
return skipTrailingSpaces<spacePolicy>(++i, end);
prematureEnd:
errorHandler.prematureEnd();
return end;
malformedJson:
errorHandler.malformedJson(i);
return end;
}
示例2: parsePropertyValue
inline Iterator parsePropertyValue(Iterator begin, Iterator end, const char * const propName,
const std::size_t propNameSize, ValueParser valueParser, ErrorHandler &errorHandler)
{
Iterator i = skipLeadingSpaces<spacePolicy>(begin, end);
// TODO optimise property name matching
const char *realPropNameBegin;
std::size_t realPropNameSize;
auto propNameParser = [&](const char * const begin, const char * const end, ErrorHandler &errorHandler) -> const char *
{
// TODO support quotation marks in property name (make it optional for better performance.
realPropNameBegin = begin;
const char * const propNameEnd = std::find(begin, end, u8"\""[0]);
realPropNameSize = propNameEnd - realPropNameBegin;
return propNameEnd;
};
// TODO support forward iterators; combine scanning and comparing into a single loop.
i = afc::json::parseString<const char *, decltype(propNameParser) &, ErrorHandler, afc::json::noSpaces>
(i, end, propNameParser, errorHandler);
if (unlikely(!errorHandler.valid())) {
return end;
}
if (unlikely(!afc::equal(propName, propNameSize, realPropNameBegin, realPropNameSize))) {
errorHandler.malformedJson(i);
return end;
}
i = afc::json::parseColon<const char *, ErrorHandler, spacePolicy>(i, end, errorHandler);
if (unlikely(!errorHandler.valid())) {
return end;
}
i = valueParser(i, end, errorHandler);
if (unlikely(!errorHandler.valid())) {
return end;
}
return skipTrailingSpaces<spacePolicy>(i, end);
}
示例3: parseArray
inline Iterator parseArray(Iterator begin, Iterator end, ArrayElementParser arrayElementParser, ErrorHandler &errorHandler)
{
Iterator i = skipLeadingSpaces<spacePolicy>(begin, end);
if (unlikely(i == end)) {
goto prematureEnd;
}
if (unlikely(*i != u8"["[0])) {
goto malformedJson;
}
if (unlikely(++i == end)) {
goto prematureEnd;
}
if (*i == u8"]"[0]) {
return skipTrailingSpaces<spacePolicy>(++i, end);
}
for (;;) {
i = arrayElementParser(i, end, errorHandler);
if (unlikely(!errorHandler.valid())) {
return end;
}
if (unlikely(i == end)) {
goto prematureEnd;
}
const char c = *i;
if (c == u8"]"[0]) {
return skipTrailingSpaces<spacePolicy>(++i, end);
}
if (likely(c == u8","[0])) {
++i;
} else {
goto malformedJson;
}
}
prematureEnd:
errorHandler.prematureEnd();
return end;
malformedJson:
errorHandler.malformedJson(i);
return end;
}