CLI: A2::attribute accessor added

This commit is contained in:
Paul Beckingham 2016-04-02 14:02:53 -04:00
parent d799d553fc
commit e695b0773b
2 changed files with 13 additions and 0 deletions

View file

@ -67,6 +67,18 @@ void A2::attribute (const std::string& name, const std::string& value)
_attributes[name] = value; _attributes[name] = value;
} }
////////////////////////////////////////////////////////////////////////////////
// Accessor for attributes.
const std::string A2::attribute (const std::string& name) const
{
// Prevent autovivification.
auto i = _attributes.find (name);
if (i != _attributes.end ())
return i->second;
return "";
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI::entity (const std::string& category, const std::string& name) void CLI::entity (const std::string& category, const std::string& name)
{ {

View file

@ -41,6 +41,7 @@ public:
void tag (const std::string&); void tag (const std::string&);
void unTag (const std::string&); void unTag (const std::string&);
void attribute (const std::string&, const std::string&); void attribute (const std::string&, const std::string&);
const std::string attribute (const std::string&) const;
public: public:
Lexer::Type _lextype {Lexer::Type::word}; Lexer::Type _lextype {Lexer::Type::word};