ArrayParser doesn't require the string to be null terminated anymore,
instead the length of the string can be passed in. This is first step in process to allow Value to work without null terminator.
This commit is contained in:
parent
93c8b49f61
commit
b210c570fc
4 changed files with 26 additions and 13 deletions
|
|
@ -12,9 +12,9 @@ namespace {
|
|||
|
||||
}
|
||||
|
||||
ArrayParser::ArrayParser(const char *array_string)
|
||||
ArrayParser::ArrayParser(const char *array_string, int length)
|
||||
: data(array_string)
|
||||
, end(array_string + strlen(array_string))
|
||||
, end(length >= 0 ? array_string + length : array_string + strlen(array_string))
|
||||
, pos(array_string)
|
||||
{
|
||||
initializeParse();
|
||||
|
|
@ -36,7 +36,7 @@ ArrayParser::NextElemResult ArrayParser::GetNextElem()
|
|||
// parse unquoted value, fast path no escapes
|
||||
const char *start = pos;
|
||||
while (pos < end && *pos != Seperator && *pos != ArrayEnd) ++pos;
|
||||
if (*pos == 0) // reached end of data shouldn't happen
|
||||
if (pos == end) // reached end of data shouldn't happen
|
||||
throw std::runtime_error("Invalid input");
|
||||
|
||||
result.ok = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue