4 * Created on: Aug 26, 2012
8 #ifndef LOADER_PARSEDSOURCE_H_
9 #define LOADER_PARSEDSOURCE_H_
35 explicit Literal(const std::vector<Value *> &);
36 explicit Literal(bool);
37 Literal(int r, int g, int b, int a = 255);
38 Literal(const std::string &);
39 Literal(int x, int y);
40 Literal(const std::string &typeName, PropertyList *properties);
45 std::vector<Value *> values;
56 explicit Value(const std::string &identifier)
57 : literal(0), identifier(identifier), isLiteral(false) { }
58 explicit Value(Literal *literal)
59 : literal(literal), isLiteral(false) { }
63 std::string identifier;
75 void SetProperty(const std::string &name, Value *value) {
80 std::map<std::string, Value *> props;
88 Declaration(const std::string &typeName, const std::string &identifier)
89 : typeName(typeName), identifier(identifier) { }
90 virtual ~Declaration() { }
93 const std::string &TypeName() const { return typeName; }
94 const std::string &Identifier() const { return identifier; }
98 std::string identifier;
104 : public Declaration {
107 Definition(const std::string &typeName, const std::string &identifier)
108 : Declaration(typeName, identifier), value(0), isLiteral(false) { }
111 void SetValue(Literal *);
112 void SetValue(PropertyList *);
114 bool HasLiteralValue() const { return isLiteral && value; }
115 bool HasProperties() const { return !isLiteral && value; }
116 Literal *GetLiteral();
117 const Literal *GetLiteral() const;
118 PropertyList *GetProperties();
119 const PropertyList *GetProperties() const;
135 void AddDeclaration(Declaration *);
136 void ExportDeclaration(Declaration *);
137 void ExportIdentifier(const std::string &);
139 const std::map<std::string, Declaration *> Declarations() const { return declarations; }
140 const std::set<std::string> Exports() const { return exports; }
143 std::map<std::string, Declaration *> declarations;
144 std::set<std::string> exports;
153 ostream &operator <<(ostream &, const loader::ParsedSource &);
157 #endif /* LOADER_PARSEDSOURCE_H_ */