]> git.localhorst.tv Git - l2e.git/commitdiff
added getters for property lists
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 26 Aug 2012 22:02:57 +0000 (00:02 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 26 Aug 2012 22:02:57 +0000 (00:02 +0200)
src/loader/ParsedSource.cpp
src/loader/ParsedSource.h

index b019fe76bc4f5fb6c09ebae980c86a1319936481..1f7fc983053e68ab32047bdbba7abdc2f466d796 100644 (file)
@@ -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");
+       }
+}
+
 }
 
 
index d5347e55c201d5e02a9492369acdc519ec6740cc..e33796aa8601c0560b476972163dd47ec3581863 100644 (file)
@@ -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<std::string, Value *>::iterator Iterator;
+       typedef std::map<std::string, Value *>::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<std::string, Value *> props;