namespace loader {
+ParsedSource::~ParsedSource() {
+ for (map<string, Declaration *>::const_iterator i(declarations.begin()), end(declarations.end()); i != end; ++i) {
+ delete i->second;
+ }
+}
+
void ParsedSource::AddDeclaration(Declaration *d) {
map<string, Declaration *>::iterator i(declarations.find(d->Identifier()));
if (i != declarations.end()) {
}
+Definition::~Definition() {
+ if (isLiteral) {
+ delete reinterpret_cast<Literal *>(value);
+ } else {
+ delete reinterpret_cast<PropertyList *>(value);
+ }
+}
+
void Definition::SetValue(Literal *v) {
value = v;
isLiteral = true;
Literal *Definition::GetLiteral() {
if (isLiteral) {
- return (Literal *)value;
+ return reinterpret_cast<Literal *>(value);
} else {
throw runtime_error("tried to access properties as literal");
}
const Literal *Definition::GetLiteral() const {
if (isLiteral) {
- return (Literal *)value;
+ return reinterpret_cast<Literal *>(value);
} else {
throw runtime_error("tried to access properties as literal");
}
PropertyList *Definition::GetProperties() {
if (!isLiteral) {
- return (PropertyList *)value;
+ return reinterpret_cast<PropertyList *>(value);
} else {
throw runtime_error("tried to access literal value as property list");
}
const PropertyList *Definition::GetProperties() const {
if (!isLiteral) {
- return (PropertyList *)value;
+ return reinterpret_cast<PropertyList *>(value);
} else {
throw runtime_error("tried to access literal value as property list");
}
}
+Literal::~Literal() {
+ switch (type) {
+ case ARRAY_VALUES:
+ for (vector<Value *>::const_iterator i(values.begin()), end(values.end()); i != end; ++i) {
+ delete *i;
+ }
+ break;
+ case ARRAY_PROPS:
+ for (vector<PropertyList *>::const_iterator i(propertyLists.begin()), end(propertyLists.end()); i != end; ++i) {
+ delete *i;
+ }
+ break;
+ case OBJECT:
+ delete props;
+ break;
+ default:
+ break;
+ }
+}
+
const vector<Value *> &Literal::GetValues() const {
if (type == ARRAY_VALUES) {
}
+Value::~Value() {
+ if (isLiteral) {
+ delete literal;
+ }
+}
+
const Literal &Value::GetLiteral() const {
if (isLiteral) {
return *literal;
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; }
: 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 *);