#ifndef LOADER_PARSEDSOURCE_H_
#define LOADER_PARSEDSOURCE_H_
+#include "fwd.h"
+
#include <iosfwd>
#include <map>
#include <set>
namespace loader {
-class PropertyList;
-class Value;
-
class Literal {
public:
BOOLEAN,
COLOR,
NUMBER,
+ PATH,
STRING,
VECTOR,
OBJECT
public:
explicit Literal(const std::vector<Value *> &);
- explicit Literal(const std::vector<PropertyList *> &);
+ Literal(const std::string &, const std::vector<PropertyList *> &);
explicit Literal(bool);
Literal(int r, int g, int b, int a = 255);
explicit Literal(int number);
+ Literal(const std::string &dir, const std::string &path);
Literal(const std::string &);
Literal(int x, int y);
Literal(const std::string &typeName, PropertyList *properties);
+ ~Literal();
+private:
+ Literal(const Literal &);
+ Literal &operator =(const Literal &);
public:
Type GetType() const { return type; }
+ bool IsArray() const { return GetType() == ARRAY_VALUES || GetType() == ARRAY_PROPS; }
+ bool IsObject() const { return GetType() == OBJECT; }
+ int ArraySize() const { return GetType() == ARRAY_VALUES ? GetValues().size() : GetPropertyLists().size(); }
const std::vector<Value *> &GetValues() const;
const std::vector<PropertyList *> &GetPropertyLists() const;
private:
PropertyList *props;
- std::string str;
+ std::string typeName, str;
std::vector<Value *> values;
std::vector<PropertyList *> propertyLists;
int i1, i2, i3, i4;
: literal(0), identifier(identifier), isLiteral(false) { }
explicit Value(Literal *literal)
: literal(literal), isLiteral(true) { }
+ ~Value();
+private:
+ Value(const Value &);
+ Value &operator =(const Value &);
public:
bool IsLiteral() const { return isLiteral; }
class PropertyList {
public:
+ PropertyList() { }
~PropertyList();
+private:
+ PropertyList(const PropertyList &);
+ PropertyList &operator =(const PropertyList &);
public:
void SetProperty(const std::string &name, Value *value) {
Declaration(const std::string &typeName, const std::string &identifier)
: typeName(typeName), identifier(identifier) { }
virtual ~Declaration() { }
+private:
+ Declaration(const Declaration &);
+ Declaration &operator =(const Declaration &);
public:
const std::string &TypeName() const { return typeName; }
public:
Definition(const std::string &typeName, const std::string &identifier)
: Declaration(typeName, identifier), value(0), isLiteral(false) { }
+ virtual ~Definition();
+private:
+ Definition(const Definition &);
+ Definition &operator =(const Definition &);
public:
void SetValue(Literal *);
public:
ParsedSource() { }
- ~ParsedSource() { }
+ ~ParsedSource();
+private:
+ ParsedSource(const ParsedSource &);
+ ParsedSource &operator =(const ParsedSource &);
public:
void AddDeclaration(Declaration *);
const std::map<std::string, Definition *> &Definitions() const { return definitions; }
const std::set<std::string> &Exports() const { return exports; }
+public:
+ void WriteHeader(std::ostream &) const;
+
private:
std::map<std::string, Declaration *> declarations;
std::map<std::string, Definition *> definitions;