Task: Migrated from Nibbler to Pig

This commit is contained in:
Paul Beckingham 2016-12-11 20:00:30 -05:00
parent 06f177534d
commit f684e821d4

View file

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