mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Nibbler
- Implemented Nibbler::getName to parse an alpha-numeric name. - Added appropriate unit tests.
This commit is contained in:
parent
91225d808f
commit
3fd83ca400
3 changed files with 55 additions and 1 deletions
|
@ -987,6 +987,36 @@ bool Nibbler::getDOM (std::string& result)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// A name is a string of alpha-numeric characters.
|
||||
bool Nibbler::getName (std::string& result)
|
||||
{
|
||||
std::string::size_type i = mCursor;
|
||||
|
||||
if (i < mLength)
|
||||
{
|
||||
if (isalpha (mInput[i]))
|
||||
{
|
||||
++i;
|
||||
while (i < mLength &&
|
||||
(isalpha (mInput[i]) ||
|
||||
isdigit (mInput[i])))
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > mCursor)
|
||||
{
|
||||
result = mInput.substr (mCursor, i - mCursor);
|
||||
mCursor = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// A word is a contiguous string of non-space, non-digit, non-punct characters.
|
||||
bool Nibbler::getWord (std::string& result)
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
bool getDate (const std::string&, time_t&);
|
||||
bool getOneOf (const std::vector <std::string>&, std::string&);
|
||||
bool getDOM (std::string&);
|
||||
bool getName (std::string&);
|
||||
bool getWord (std::string&);
|
||||
|
||||
bool skipN (const int quantity = 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue