}
}
+
+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");
+ }
+}
+
}
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;
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;