mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Enhancements - Cmd object
- New Cmd object to handle localized commands, customReports and general command parsing. - Localized new Subst methods. - Relocate guess method from parse.cpp to text.cpp. - Converted Att object to use new valid/parse scheme. - Unit tests for Cmd object. - Fixed att.t.cpp unit tests.
This commit is contained in:
parent
ffa0c6e758
commit
24f31eeb00
17 changed files with 416 additions and 52 deletions
31
src/Att.cpp
31
src/Att.cpp
|
@ -86,13 +86,39 @@ Att::~Att ()
|
|||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Att::valid (const std::string& input) const
|
||||
{
|
||||
Nibbler n (input);
|
||||
std::string ignored;
|
||||
if (n.getUntilOneOf (".:", ignored))
|
||||
{
|
||||
if (ignored.length () == 0)
|
||||
return false;
|
||||
|
||||
while (n.skip ('.'))
|
||||
if (!n.getUntilOneOf (".:", ignored))
|
||||
return false;
|
||||
|
||||
if (n.skip (':') &&
|
||||
(n.getQuoted ('"', ignored) ||
|
||||
n.getUntil (' ', ignored) ||
|
||||
n.getUntilEOS (ignored)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// start --> name --> . --> mod --> : --> " --> value --> " --> end
|
||||
// ^ |
|
||||
// |__________|
|
||||
//
|
||||
bool Att::parse (Nibbler& n)
|
||||
void Att::parse (Nibbler& n)
|
||||
{
|
||||
// Ensure a clean object first.
|
||||
mName = "";
|
||||
|
@ -126,7 +152,6 @@ bool Att::parse (Nibbler& n)
|
|||
n.getUntil (' ', mValue))
|
||||
{
|
||||
decode (mValue);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw std::string ("Missing attribute value"); // TODO i18n
|
||||
|
@ -136,8 +161,6 @@ bool Att::parse (Nibbler& n)
|
|||
}
|
||||
else
|
||||
throw std::string ("Missing : after attribute name"); // TODO i18n
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue