X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fio%2FTokenStreamReader.hpp;fp=src%2Fio%2FTokenStreamReader.hpp;h=caa620705179c3e8ef51e10d04144d1c8043e2e0;hb=ede25c0a2f59e21521d1cd962e6ea9d78169ca12;hp=0000000000000000000000000000000000000000;hpb=d02daa5a4805dc3184884f3a7cd7620e5787adcb;p=blank.git diff --git a/src/io/TokenStreamReader.hpp b/src/io/TokenStreamReader.hpp new file mode 100644 index 0000000..caa6207 --- /dev/null +++ b/src/io/TokenStreamReader.hpp @@ -0,0 +1,57 @@ +#ifndef BLANK_IO_TOKENSTREAMREADER_HPP_ +#define BLANK_IO_TOKENSTREAMREADER_HPP_ + +#include "Token.hpp" +#include "Tokenizer.hpp" + +#include +#include +#include + + +namespace blank { + +class TokenStreamReader { + +public: + TokenStreamReader(std::istream &); + + bool HasMore(); + const Token &Next(); + const Token &Peek(); + + void Skip(Token::Type); + + void ReadBoolean(bool &); + void ReadIdentifier(std::string &); + void ReadNumber(float &); + void ReadNumber(int &); + void ReadNumber(unsigned long &); + void ReadString(std::string &); + + void ReadVec(glm::vec2 &); + void ReadVec(glm::vec3 &); + void ReadVec(glm::vec4 &); + + void ReadVec(glm::ivec2 &); + void ReadVec(glm::ivec3 &); + void ReadVec(glm::ivec4 &); + + bool GetBool(); + float GetFloat(); + int GetInt(); + unsigned long GetULong(); + +private: + void Assert(Token::Type); + Token::Type GetType() const noexcept; + const std::string &GetValue() const noexcept; + + Tokenizer in; + bool cached; + +}; + +} + +#endif