]> git.localhorst.tv Git - blank.git/blob - src/io/TokenStreamReader.hpp
some linting
[blank.git] / src / io / TokenStreamReader.hpp
1 #ifndef BLANK_IO_TOKENSTREAMREADER_HPP_
2 #define BLANK_IO_TOKENSTREAMREADER_HPP_
3
4 #include "Token.hpp"
5 #include "Tokenizer.hpp"
6 #include "../graphics/glm.hpp"
7
8 #include <iosfwd>
9 #include <string>
10
11
12 namespace blank {
13
14 class TokenStreamReader {
15
16 public:
17         explicit TokenStreamReader(std::istream &);
18
19         bool HasMore();
20         const Token &Next();
21         const Token &Peek();
22
23         void Skip(Token::Type);
24
25         void ReadBoolean(bool &);
26         void ReadIdentifier(std::string &);
27         void ReadNumber(float &);
28         void ReadNumber(int &);
29         void ReadNumber(unsigned long &);
30         void ReadString(std::string &);
31
32         void ReadVec(glm::vec2 &);
33         void ReadVec(glm::vec3 &);
34         void ReadVec(glm::vec4 &);
35
36         void ReadVec(glm::ivec2 &);
37         void ReadVec(glm::ivec3 &);
38         void ReadVec(glm::ivec4 &);
39
40         void ReadQuat(glm::quat &);
41
42         // the Get* functions advance to the next token
43         // the As* functions try to cast the current token
44         // if the value could not be converted, a std::runtime_error is thrown
45
46         bool GetBool();
47         bool AsBool() const;
48         float GetFloat();
49         float AsFloat() const;
50         int GetInt();
51         int AsInt() const;
52         unsigned long GetULong();
53         unsigned long AsULong() const;
54
55 private:
56         void SkipComments();
57
58         void Assert(Token::Type) const;
59         Token::Type GetType() const noexcept;
60         const std::string &GetValue() const noexcept;
61
62         Tokenizer in;
63         bool cached;
64
65 };
66
67 }
68
69 #endif