From a15cf65c44d5c224169c32ef5495b68c758134b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 18 May 2014 16:08:14 +0200 Subject: Imported Upstream version 3.3.0.2 --- .../frontend-elements/token-stream.hxx | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 libfrontend-elements/frontend-elements/token-stream.hxx (limited to 'libfrontend-elements/frontend-elements/token-stream.hxx') diff --git a/libfrontend-elements/frontend-elements/token-stream.hxx b/libfrontend-elements/frontend-elements/token-stream.hxx new file mode 100644 index 0000000..023842f --- /dev/null +++ b/libfrontend-elements/frontend-elements/token-stream.hxx @@ -0,0 +1,99 @@ +// file : frontend-elements/token-stream.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef FRONTEND_ELEMENTS_TOKEN_STREAM_HXX +#define FRONTEND_ELEMENTS_TOKEN_STREAM_HXX + +#include + +#include // std::char_traits +#include + +namespace FrontendElements +{ + // + // + template + class TokenStream + { + public: + virtual + ~TokenStream () + { + } + + public: + virtual Token + next () = 0; + }; + + + // + // + template <> + class TokenStream + { + public: + typedef + std::char_traits + Traits; + + typedef + Traits::int_type + AsInt; + + typedef + Traits::char_type + AsChar; + + public: + virtual + ~TokenStream () + { + } + + public: + virtual AsInt + next () = 0; + + static AsChar + to_char (AsInt i) + { + return Traits::to_char_type (i); + } + + static AsInt + eos () + { + return Traits::eof (); + } + }; + + class InputStreamAdapter: public TokenStream + { + public: + virtual + ~InputStreamAdapter () + { + } + + InputStreamAdapter (std::istream& is) + : is_ (is) + { + } + + public: + virtual AsInt + next () + { + return is_.get (); + } + + private: + std::istream& is_; + }; +} + +#endif // FRONTEND_ELEMENTS_TOKEN_STREAM_HXX -- cgit v1.2.3