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