X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fio%2FTokenStreamReader.hpp;h=f1b73491447c5c662aa37b219b2e42b0d5c283db;hb=958ad20b247bbf6a0105bf246d57fc06416ebb58;hp=c702703f6915c3e201bf71f759afb5b25794e966;hpb=dcd54cacda98c2c0f7cf0c7a9131fb858d8ee10a;p=blank.git diff --git a/src/io/TokenStreamReader.hpp b/src/io/TokenStreamReader.hpp index c702703..f1b7349 100644 --- a/src/io/TokenStreamReader.hpp +++ b/src/io/TokenStreamReader.hpp @@ -14,7 +14,7 @@ namespace blank { class TokenStreamReader { public: - TokenStreamReader(std::istream &); + explicit TokenStreamReader(std::istream &); bool HasMore(); const Token &Next(); @@ -39,15 +39,23 @@ public: void ReadQuat(glm::quat &); + // the Get* functions advance to the next token + // the As* functions try to cast the current token + // if the value could not be converted, a std::runtime_error is thrown + bool GetBool(); + bool AsBool() const; float GetFloat(); + float AsFloat() const; int GetInt(); + int AsInt() const; unsigned long GetULong(); + unsigned long AsULong() const; private: void SkipComments(); - void Assert(Token::Type); + void Assert(Token::Type) const; Token::Type GetType() const noexcept; const std::string &GetValue() const noexcept;