diff --git a/src/CLI.cpp b/src/CLI.cpp index be1921de..90f6751d 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -67,6 +67,18 @@ void A2::attribute (const std::string& name, const std::string& 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) { diff --git a/src/CLI.h b/src/CLI.h index 463e644a..6ac44b2a 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -41,6 +41,7 @@ public: void tag (const std::string&); void unTag (const std::string&); void attribute (const std::string&, const std::string&); + const std::string attribute (const std::string&) const; public: Lexer::Type _lextype {Lexer::Type::word};