From 2bd2e92a227af66386af1dfca2f52df6941f0f94 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Mon, 27 Aug 2012 00:02:57 +0200 Subject: [PATCH] added getters for property lists --- src/loader/ParsedSource.cpp | 17 +++++++++++++++++ src/loader/ParsedSource.h | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/loader/ParsedSource.cpp b/src/loader/ParsedSource.cpp index b019fe7..1f7fc98 100644 --- a/src/loader/ParsedSource.cpp +++ b/src/loader/ParsedSource.cpp @@ -327,6 +327,23 @@ const PropertyList *Literal::GetProperties() const { } } + +const Literal &Value::GetLiteral() const { + if (isLiteral) { + return *literal; + } else { + throw runtime_error("tried to access literal of identifier value"); + } +} + +const std::string &Value::GetIdentifier() const { + if (!isLiteral) { + return identifier; + } else { + throw runtime_error("tried to access identifier of literal value"); + } +} + } diff --git a/src/loader/ParsedSource.h b/src/loader/ParsedSource.h index d5347e5..e33796a 100644 --- a/src/loader/ParsedSource.h +++ b/src/loader/ParsedSource.h @@ -80,6 +80,11 @@ public: explicit Value(Literal *literal) : literal(literal), isLiteral(false) { } +public: + bool IsLiteral() const { return isLiteral; } + const Literal &GetLiteral() const; + const std::string &GetIdentifier() const; + private: Literal *literal; std::string identifier; @@ -98,6 +103,13 @@ public: props[name] = value; } + typedef std::map::iterator Iterator; + typedef std::map::const_iterator ConstIterator; + Iterator Begin() { return props.begin(); } + ConstIterator Begin() const { return props.begin(); } + Iterator End() { return props.end(); } + ConstIterator End() const { return props.end(); } + private: std::map props; -- 2.39.2