From: Daniel Karbach Date: Sun, 26 Aug 2012 22:02:57 +0000 (+0200) Subject: added getters for property lists X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;ds=sidebyside;h=2bd2e92a227af66386af1dfca2f52df6941f0f94;p=l2e.git added getters for property lists --- 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;