4 * Created on: Aug 26, 2012
8 #ifndef LOADER_INTERPRETER_H_
9 #define LOADER_INTERPRETER_H_
11 #include "../geometry/Vector.h"
12 #include "../graphics/ComplexAnimation.h"
29 class SimpleAnimation;
43 class Error: public std::runtime_error {
45 Error(const std::string &msg) : std::runtime_error("interpreter error: " + msg) { }
49 Interpreter(const ParsedSource &source) : source(source) { }
52 Interpreter(const Interpreter &);
53 Interpreter &operator =(const Interpreter &);
59 void ReadDefinition(const Definition &);
60 void ReadLiteral(const Definition &);
61 void ReadObject(const Definition &);
63 graphics::Animation *GetAnimation(const Value &);
64 const std::vector<Value *> &GetValueArray(const Value &);
65 const std::vector<PropertyList *> &GetPropertyListArray(const Value &);
66 bool GetBoolean(const Value &);
67 SDL_Surface *GetImage(const Value &);
68 int GetNumber(const Value &);
69 const PropertyList *GetPropertyList(const Value &);
70 graphics::Sprite *GetSprite(const Value &);
71 const char *GetString(const Value &);
72 geometry::Vector<int> GetVector(const Value &);
74 void ReadComplexAnimation(graphics::ComplexAnimation &, const PropertyList &);
75 void ReadComplexAnimationFrame(graphics::ComplexAnimation::FrameProp &, const PropertyList &);
76 void ReadHero(battle::Hero &, const PropertyList &);
77 void ReadMonster(battle::Monster &, const PropertyList &);
78 void ReadSimpleAnimation(graphics::SimpleAnimation &, const PropertyList &);
79 void ReadSprite(graphics::Sprite &, const PropertyList &);
80 void ReadStats(battle::Stats &, const PropertyList &);
83 const ParsedSource &source;
84 std::set<std::string> parsedDefinitions;
86 std::map<std::string, graphics::Animation *> animations;
87 std::map<std::string, battle::Hero *> heroes;
88 std::map<std::string, battle::Monster *> monsters;
89 std::map<std::string, int> numbers;
90 std::map<std::string, graphics::Sprite *> sprites;
96 #endif /* LOADER_INTERPRETER_H_ */