mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Parsing
- Implemented Nibbler::getUUID to assist parsing efforts.
This commit is contained in:
parent
58a677ffb5
commit
354d66a5ac
3 changed files with 68 additions and 2 deletions
|
@ -446,6 +446,62 @@ bool Nibbler::getRx (const std::string& regex, std::string& result)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getUUID (std::string& result)
|
||||
{
|
||||
std::string::size_type i = mCursor;
|
||||
|
||||
if (i < mLength &&
|
||||
mLength - i >= 37)
|
||||
{
|
||||
// 8-4-4-4-6-6
|
||||
if (isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
mInput[i++] == '-' &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
mInput[i++] == '-' &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
mInput[i++] == '-' &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
mInput[i++] == '-' &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
mInput[i++] == '-' &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]) &&
|
||||
isxdigit (mInput[i++]))
|
||||
{
|
||||
result = mInput.substr (mCursor, 37);
|
||||
mCursor = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::skipN (const int quantity /* = 1 */)
|
||||
{
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
bool getNumber (double&);
|
||||
bool getLiteral (const std::string&);
|
||||
bool getRx (const std::string&, std::string&);
|
||||
bool getUUID (std::string&);
|
||||
|
||||
bool skipN (const int quantity = 1);
|
||||
bool skip (char);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue