Task: Migrated from Nibbler to Pig

This commit is contained in:
Paul Beckingham 2016-12-11 20:00:30 -05:00
parent a456228e98
commit cdfd92ed9b

View file

@ -39,7 +39,7 @@
#include <Lexer.h>
#ifdef PRODUCT_TASKWARRIOR
#include <Context.h>
#include <Nibbler.h>
#include <Pig.h>
#endif
#include <ISO8601.h>
#ifdef PRODUCT_TASKWARRIOR
@ -576,24 +576,24 @@ void Task::parse (const std::string& input)
if (input[0] == '[')
{
Nibbler n (input);
Pig pig (input);
std::string line;
if (n.skip ('[') &&
n.getUntil (']', line) &&
n.skip (']') &&
(n.skip ('\n') || n.depleted ()))
if (pig.skip ('[') &&
pig.getUntil (']', line) &&
pig.skip (']') &&
(pig.skip ('\n') || pig.eos ()))
{
if (line.length () == 0)
throw std::string (STRING_RECORD_EMPTY);
Nibbler nl (line);
Pig attLine (line);
std::string name;
std::string value;
while (!nl.depleted ())
while (!attLine.eos ())
{
if (nl.getUntil (':', name) &&
nl.skip (':') &&
nl.getQuoted ('"', value))
if (attLine.getUntil (':', name) &&
attLine.skip (':') &&
attLine.getQuoted ('"', value))
{
#ifdef PRODUCT_TASKWARRIOR
legacyAttributeMap (name);
@ -605,11 +605,11 @@ void Task::parse (const std::string& input)
data[name] = decode (json::decode (value));
}
nl.skip (' ');
attLine.skip (' ');
}
std::string remainder;
nl.getUntilEOS (remainder);
attLine.getRemainder (remainder);
if (remainder.length ())
throw std::string (STRING_RECORD_JUNK_AT_EOL);
}