From 8913eaf96fd53c087d5c1fcda87f2846fe87f62d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 2 Apr 2016 15:18:19 -0400 Subject: [PATCH] CLI: Added A2::dump --- src/CLI.cpp | 20 ++++++++++++++++++++ src/CLI.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/CLI.cpp b/src/CLI.cpp index 8be1a5bf..a1cc1575 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -79,6 +79,26 @@ const std::string A2::attribute (const std::string& name) const return ""; } +//////////////////////////////////////////////////////////////////////////////// +const std::string A2::dump () const +{ + auto output = Lexer::typeToString (_lextype); + + // Dump attributes. + std::string atts; + for (const auto& a : _attributes) + atts += a.first + "='\033[33m" + a.second + "\033[0m' "; + + // Dump tags. + std::string tags; + for (const auto& tag : _tags) + { + tags += "\033[32m" + tag + "\033[0m "; + } + + return output + " " + atts + tags; +} + //////////////////////////////////////////////////////////////////////////////// void CLI::entity (const std::string& category, const std::string& name) { diff --git a/src/CLI.h b/src/CLI.h index 7b431201..c305f5ff 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -42,6 +42,7 @@ public: void unTag (const std::string&); void attribute (const std::string&, const std::string&); const std::string attribute (const std::string&) const; + const std::string dump () const; public: Lexer::Type _lextype {Lexer::Type::word};