mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Pig: Added ::getOneOf
This commit is contained in:
parent
544a1d67d0
commit
edda82fafe
2 changed files with 22 additions and 0 deletions
20
src/Pig.cpp
20
src/Pig.cpp
|
@ -263,6 +263,26 @@ bool Pig::getNumber (double& result)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Assumes that the options are sorted by decreasing length, so that if the
|
||||
// options contain 'fourteen' and 'four', the stream is first matched against
|
||||
// the longer entry.
|
||||
bool Pig::getOneOf (
|
||||
const std::vector <std::string>& options,
|
||||
std::string& found)
|
||||
{
|
||||
for (auto& option : options)
|
||||
{
|
||||
if (skipLiteral (option))
|
||||
{
|
||||
found = option;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Pig::getRemainder (std::string& result)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue