mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Lexer: Added ::dequote
This commit is contained in:
parent
a2e45b9297
commit
8b159d7225
2 changed files with 20 additions and 0 deletions
|
@ -329,6 +329,25 @@ bool Lexer::isPunctuation (int c)
|
||||||
! isAlpha (c);
|
! isAlpha (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Assumes that quotes is a string containing a non-trivial set of quote
|
||||||
|
// characters.
|
||||||
|
std::string Lexer::dequote (const std::string& input, const std::string& quotes)
|
||||||
|
{
|
||||||
|
if (input.length ())
|
||||||
|
{
|
||||||
|
int quote = input[0];
|
||||||
|
if (quotes.find (quote) != std::string::npos)
|
||||||
|
{
|
||||||
|
size_t len = input.length ();
|
||||||
|
if (quote == input[len - 1])
|
||||||
|
return input.substr (1, len - 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Lexer::isEOS () const
|
bool Lexer::isEOS () const
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
static std::string trimLeft (const std::string& in, const std::string& t = " ");
|
static std::string trimLeft (const std::string& in, const std::string& t = " ");
|
||||||
static std::string trimRight (const std::string& in, const std::string& t = " ");
|
static std::string trimRight (const std::string& in, const std::string& t = " ");
|
||||||
static std::string trim (const std::string& in, const std::string& t = " ");
|
static std::string trim (const std::string& in, const std::string& t = " ");
|
||||||
|
static std::string dequote (const std::string&, const std::string& quotes = "'\"");
|
||||||
|
|
||||||
// Stream Classifiers.
|
// Stream Classifiers.
|
||||||
bool isEOS () const;
|
bool isEOS () const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue