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 MEMORY_INPUT_STREAM_H_ 00026 #define MEMORY_INPUT_STREAM_H_ 00027 00028 #include <Core/InputOutput/InputStream.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * メモリ入力ストリーム 00035 */ 00036 class MemoryInputStream : public InputStream{ 00037 public: 00038 /** 00039 * コンストラクタ 00040 * @param buffer 読み込むバッファ。バッファの解放は行いません。 00041 * @param size バッファのサイズ 00042 */ 00043 MemoryInputStream(const char* buffer, int size); 00044 00045 /** 00046 * デストラクタ 00047 */ 00048 virtual ~MemoryInputStream(); 00049 00050 /** 00051 * メモリ入力ストリームの複製 00052 * @return 複製されたメモリ入力ストリーム 00053 */ 00054 virtual MemoryInputStream* cloneMemoryInputStream(); 00055 00056 /** 00057 * 入力ストリームの複製 00058 * @return 複製された入力ストリーム 00059 */ 00060 virtual InputStream* cloneInputStream(){ return cloneMemoryInputStream(); } 00061 00062 protected: 00063 /** 00064 * 終端かどうか 00065 * @return trueなら終端 00066 */ 00067 virtual bool isEnd(); 00068 00069 /** 00070 * バイトデータの読み出し 00071 * @param data 読み出し先アドレス 00072 * @param size 読み出すサイズ 00073 */ 00074 virtual void readBytes(void* data, int size); 00075 00076 /** 00077 * サイズの取得 00078 * @return ストリーム全体のバイト数 00079 */ 00080 virtual int getSize(); 00081 00082 /** 00083 * スキップ 00084 * 00085 * 指定されたバイト数、読み出しをスキップします。 00086 * @param size スキップするバイト数 00087 */ 00088 virtual void skip(int size); 00089 00090 /** 00091 * アライメントを取る 00092 * 00093 * 指定されたバイト数のアライメントまで読み飛ばします。 00094 * @param alignSize アライメントをとるバイト数 00095 * @return スキップしたバイト数 00096 */ 00097 virtual int align(int alignSize); 00098 00099 /** 00100 * 読み込み位置の取得 00101 * @return 読み込み位置 00102 */ 00103 virtual int getPosition(); 00104 00105 /** 00106 * 読み込み位置の設定 00107 * 00108 * 指定された位置に読み込み位置を変更します。 00109 * @param position 読み込み位置 00110 */ 00111 virtual void setPosition(int position); 00112 00113 private: 00114 // コピーコンストラクタの隠蔽 00115 MemoryInputStream(const MemoryInputStream& copy); 00116 00117 // 代入コピーの隠蔽 00118 void operator =(const MemoryInputStream& copy); 00119 00120 // バッファ 00121 const char* buffer_; 00122 // 位置 00123 int position_; 00124 // サイズ 00125 int size_; 00126 00127 }; 00128 00129 //------------------------------------------------------------------------------ 00130 } // End of namespace Lamp 00131 #endif // End of MEMORY_INPUT_STREAM_H_ 00132 //------------------------------------------------------------------------------