1 // Copyright (C) 2005 Universitat d'Alacant / Universidad de Alicante 2 // 3 // This program is free software; you can redistribute it and/or 4 // modify it under the terms of the GNU General Public License as 5 // published by the Free Software Foundation; either version 2 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, but 9 // WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 // General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, see <http://www.gnu.org/licenses/>. 15 16 #ifndef STREAM_H 17 #define STREAM_H 18 19 #include "basic_tagger.h" 20 #include "optional.h" 21 #include "streamed_type.h" 22 23 #include <cstddef> 24 #include <istream> 25 #include <sstream> 26 #include <string> 27 28 namespace Apertium { 29 class Stream { 30 public: 31 Stream(basic_Tagger::Flags &Flags_); 32 Stream(basic_Tagger::Flags &Flags_, std::wifstream &CharacterStream_, 33 const char *const Filename_); 34 Stream(basic_Tagger::Flags &Flags_, std::wifstream &CharacterStream_, 35 const std::string &Filename_); 36 Stream(basic_Tagger::Flags &Flags_, std::wifstream &CharacterStream_, 37 const std::stringstream &Filename_); 38 StreamedType get(); 39 StreamedType peek(); 40 bool peekIsBlank(); 41 bool flush_() const; 42 43 static void outputLexicalUnit( 44 const LexicalUnit &lexical_unit, const Optional<Analysis> analysis, 45 std::wostream &output, basic_Tagger::Flags &flags); 46 47 std::size_t TheLineNumber; 48 private: 49 class PreviousCaseType { 50 public: 51 PreviousCaseType(const wchar_t &PreviousCase_); 52 wchar_t ThePreviousCase; 53 bool isPreviousCharacter : 1; 54 }; 55 bool is_eof_throw_if_not_TheCharacterStream_good() const; 56 std::wstring Message_what(const std::wstringstream &Message) const; 57 bool is_eof_throw_if_not_TheCharacterStream_good(StreamedType &StreamedType_, 58 std::wstring &Lemma, 59 const wchar_t &Character_); 60 bool isTheCharacterStream_eof(StreamedType &StreamedType_, 61 std::wstring &Lemma, const wchar_t &Character_); 62 void push_back_Character(StreamedType &StreamedType_, std::wstring &Lemma, 63 const wchar_t &Character_); 64 void case_0x5c(StreamedType &StreamedType_, std::wstring &Lemma, 65 const wchar_t &Character_); 66 std::wistream &TheCharacterStream; 67 Optional<std::string> TheFilename; 68 std::wstring TheLine; 69 basic_Tagger::Flags &TheFlags; 70 bool private_flush_ : 1; 71 Optional<PreviousCaseType> ThePreviousCase; 72 }; 73 } 74 75 #endif // STREAM_H 76