CLI: A2 gains tags and attributes

This commit is contained in:
Paul Beckingham 2016-04-02 13:56:28 -04:00
parent cb6d7b0abe
commit 91b943a26c
2 changed files with 31 additions and 0 deletions

View file

@ -26,11 +26,34 @@
#include <cmake.h>
#include <CLI.h>
#include <algorithm>
#include <shared.h>
////////////////////////////////////////////////////////////////////////////////
A2::A2 (const std::string& raw, Lexer::Type lextype)
{
_lextype = lextype;
attribute ("raw", raw);
}
////////////////////////////////////////////////////////////////////////////////
bool A2::hasTag (const std::string& tag) const
{
return std::find (_tags.begin (), _tags.end (), tag) != _tags.end ();
}
////////////////////////////////////////////////////////////////////////////////
void A2::tag (const std::string& tag)
{
if (! hasTag (tag))
_tags.push_back (tag);
}
////////////////////////////////////////////////////////////////////////////////
// Accessor for attributes.
void A2::attribute (const std::string& name, const std::string& value)
{
_attributes[name] = value;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -37,6 +37,14 @@ class A2
{
public:
A2 (const std::string&, Lexer::Type);
bool hasTag (const std::string&) const;
void tag (const std::string&);
void attribute (const std::string&, const std::string&);
public:
Lexer::Type _lextype {Lexer::Type::word};
std::vector <std::string> _tags {};
std::map <std::string, std::string> _attributes {};
};
// Represents the command line.