1 #ifndef BLOBS_IO_TOKENSTREAMREADER_HPP_
2 #define BLOBS_IO_TOKENSTREAMREADER_HPP_
5 #include "Tokenizer.hpp"
6 #include "../graphics/glm.hpp"
15 class TokenStreamReader {
18 explicit TokenStreamReader(std::istream &);
24 void Skip(Token::Type);
26 void ReadBoolean(bool &);
27 void ReadIdentifier(std::string &);
28 void ReadNumber(double &);
29 void ReadNumber(float &);
30 void ReadNumber(int &);
31 void ReadNumber(unsigned long &);
32 void ReadString(std::string &);
34 void ReadVec(glm::vec2 &);
35 void ReadVec(glm::vec3 &);
36 void ReadVec(glm::vec4 &);
38 void ReadVec(glm::dvec2 &);
39 void ReadVec(glm::dvec3 &);
40 void ReadVec(glm::dvec4 &);
42 void ReadVec(glm::ivec2 &);
43 void ReadVec(glm::ivec3 &);
44 void ReadVec(glm::ivec4 &);
46 void ReadQuat(glm::quat &);
47 void ReadQuat(glm::dquat &);
49 // the Get* functions advance to the next token
50 // the As* functions try to cast the current token
51 // if the value could not be converted, a std::runtime_error is thrown
56 float AsDouble() const;
58 float AsFloat() const;
61 unsigned long GetULong();
62 unsigned long AsULong() const;
67 void Assert(Token::Type) const;
68 Token::Type GetType() const noexcept;
69 const std::string &GetValue() const noexcept;