4 * Created on: Aug 26, 2012
8 #ifndef LOADER_PARSEDSOURCE_H_
9 #define LOADER_PARSEDSOURCE_H_
36 explicit Literal(const std::vector<Value *> &);
37 explicit Literal(const std::vector<PropertyList *> &);
38 explicit Literal(bool);
39 Literal(int r, int g, int b, int a = 255);
40 Literal(const std::string &);
41 Literal(int x, int y);
42 Literal(const std::string &typeName, PropertyList *properties);
47 std::vector<Value *> values;
48 std::vector<PropertyList *> propertyLists;
59 explicit Value(const std::string &identifier)
60 : literal(0), identifier(identifier), isLiteral(false) { }
61 explicit Value(Literal *literal)
62 : literal(literal), isLiteral(false) { }
66 std::string identifier;
78 void SetProperty(const std::string &name, Value *value) {
83 std::map<std::string, Value *> props;
91 Declaration(const std::string &typeName, const std::string &identifier)
92 : typeName(typeName), identifier(identifier) { }
93 virtual ~Declaration() { }
96 const std::string &TypeName() const { return typeName; }
97 const std::string &Identifier() const { return identifier; }
100 std::string typeName;
101 std::string identifier;
107 : public Declaration {
110 Definition(const std::string &typeName, const std::string &identifier)
111 : Declaration(typeName, identifier), value(0), isLiteral(false) { }
114 void SetValue(Literal *);
115 void SetValue(PropertyList *);
117 bool HasLiteralValue() const { return isLiteral && value; }
118 bool HasProperties() const { return !isLiteral && value; }
119 Literal *GetLiteral();
120 const Literal *GetLiteral() const;
121 PropertyList *GetProperties();
122 const PropertyList *GetProperties() const;
138 void AddDeclaration(Declaration *);
139 void ExportDeclaration(Declaration *);
140 void ExportIdentifier(const std::string &);
142 const std::map<std::string, Declaration *> Declarations() const { return declarations; }
143 const std::set<std::string> Exports() const { return exports; }
146 std::map<std::string, Declaration *> declarations;
147 std::set<std::string> exports;
156 ostream &operator <<(ostream &, const loader::ParsedSource &);
160 #endif /* LOADER_PARSEDSOURCE_H_ */