1 /* 2 BStone: A Source port of 3 Blake Stone: Aliens of Gold and Blake Stone: Planet Strike 4 5 Copyright (c) 1992-2013 Apogee Entertainment, LLC 6 Copyright (c) 2013-2015 Boris I. Bendovsky (bibendovsky@hotmail.com) 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the 20 Free Software Foundation, Inc., 21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 */ 23 24 25 // 26 // A text writer for a stream. 27 // 28 29 30 #ifndef BSTONE_TEXT_WRITER_INCLUDED 31 #define BSTONE_TEXT_WRITER_INCLUDED 32 33 34 #include <string> 35 #include <type_traits> 36 #include "bstone_istream.h" 37 #include "bstone_string_helper.h" 38 39 40 namespace bstone 41 { 42 43 44 // A binary reader for a block of memory. 45 class TextWriter 46 { 47 public: 48 TextWriter(); 49 50 TextWriter( 51 IStream* stream); 52 53 54 // Opens the writer. 55 bool open( 56 IStream* stream); 57 58 // Closes the writer. 59 void close(); 60 61 // Returns true if the writer is initialized or 62 // false otherwise. 63 bool is_initialized() const; 64 65 // Writes a string. 66 // 67 // Returns true on success or false otherwise. 68 bool write( 69 const std::string& string); 70 71 72 private: 73 IStream* stream_; 74 }; // TextWriter 75 76 77 } // bstone 78 79 80 #endif // BSTONE_TEXT_WRITER_INCLUDED 81