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(float &);
29 void ReadNumber(int &);
30 void ReadNumber(unsigned long &);
31 void ReadString(std::string &);
33 void ReadVec(glm::vec2 &);
34 void ReadVec(glm::vec3 &);
35 void ReadVec(glm::vec4 &);
37 void ReadVec(glm::ivec2 &);
38 void ReadVec(glm::ivec3 &);
39 void ReadVec(glm::ivec4 &);
41 void ReadQuat(glm::quat &);
43 // the Get* functions advance to the next token
44 // the As* functions try to cast the current token
45 // if the value could not be converted, a std::runtime_error is thrown
50 float AsFloat() const;
53 unsigned long GetULong();
54 unsigned long AsULong() const;
59 void Assert(Token::Type) const;
60 Token::Type GetType() const noexcept;
61 const std::string &GetValue() const noexcept;