mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Rules: Added ::parseGroup
This commit is contained in:
parent
9403fa4974
commit
12adc97d6d
2 changed files with 22 additions and 0 deletions
|
@ -357,3 +357,24 @@ std::vector <std::string> Rules::tokenizeLine (const std::string& line)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// {"one","two:"} --> "two"
|
||||
// {"one two", ":"} --> "one two"
|
||||
// {"one"} --> ""
|
||||
std::string Rules::parseGroup (const std::vector <std::string>& tokens)
|
||||
{
|
||||
auto count = tokens.size ();
|
||||
if (count)
|
||||
{
|
||||
auto last = tokens.back ();
|
||||
|
||||
if (count >= 2 && last == ":")
|
||||
return tokens[count - 2];
|
||||
|
||||
else if (count >= 1 && last[last.length () - 1] == ':')
|
||||
return last.substr (0, last.length () - 1);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -63,6 +63,7 @@ private:
|
|||
|
||||
unsigned int getIndentation (const std::string&);
|
||||
std::vector <std::string> tokenizeLine (const std::string&);
|
||||
std::string parseGroup (const std::vector <std::string>&);
|
||||
|
||||
private:
|
||||
std::string _original_file {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue