00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * テキストライタヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef TEXT_WRITER_H_ 00026 #define TEXT_WRITER_H_ 00027 00028 #include <Core/InputOutput/Writer.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * テキストライタ 00035 */ 00036 class TextWriter : public Writer{ 00037 public: 00038 /** 00039 * デストラクタ 00040 */ 00041 virtual ~TextWriter(); 00042 00043 /** 00044 * テキストの書き出し 00045 * 00046 * Stringをテキストデータとして書き出します。 00047 * \\nは\\r\\nに変換して出力されます。 00048 * NULL文字は出力しません。 00049 * @param text 書き出すテキスト 00050 */ 00051 virtual void writeText(const String& text); 00052 00053 /** 00054 * テキストの書き出し 00055 * 00056 * NULL文字で終わるchar配列をテキストデータとして書き出します。 00057 * \\nは\\r\\nに変換して出力されます。 00058 * NULL文字は出力しません。 00059 * @param text 書き出すテキスト 00060 */ 00061 virtual void writeText(const char* text); 00062 00063 /** 00064 * テキストの書き出し 00065 * 00066 * 指定されたサイズ分、char配列をテキストデータとして書き出します。 00067 * \\nは\\r\\nに変換して出力されます。 00068 * @param text 書き出すテキスト 00069 * @param size 書き出すサイズ 00070 */ 00071 // ファイル以外のストリームに対して改行変換を必要としないのであれば 00072 // もっとシンプルにできる 00073 virtual void writeText(const char* text, int size); 00074 00075 /** 00076 * フォーマットテキストの書き出し 00077 * 00078 * printf()構文でフォーマットしたテキストデータを書き出します。 00079 * \\nは\\r\\nに変換して出力されます。 00080 * @param format フォーマット 00081 * @param ... 可変長引数 00082 */ 00083 virtual void writeFormat(const char* format, ...); 00084 00085 protected: 00086 /** 00087 * コンストラクタ 00088 */ 00089 TextWriter(); 00090 00091 private: 00092 // デフォルトバッファサイズ 00093 static const int defaultBufferSize = 1024; 00094 // フォーマットデフォルトバッファサイズ 00095 static const int formatDefaultBufferSize = 1024; 00096 00097 // バッファ 00098 char* buffer_; 00099 // バッファサイズ 00100 int bufferSize_; 00101 }; 00102 00103 //------------------------------------------------------------------------------ 00104 } // End of namespace Lamp 00105 #endif // End of TEXT_WRITER_H_ 00106 //------------------------------------------------------------------------------