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 CONFIGURATION_FILE_H_ 00026 #define CONFIGURATION_FILE_H_ 00027 00028 #include <Core/Container/HashMap.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * コンフィグレーションファイル 00035 */ 00036 class ConfigurationFile{ 00037 public: 00038 /** 00039 * コンストラクタ 00040 * @param fileName ロードするコンフィグファイル名 00041 */ 00042 explicit ConfigurationFile(const String& fileName); 00043 00044 /** 00045 * デストラクタ 00046 */ 00047 virtual ~ConfigurationFile(); 00048 00049 /** 00050 * データ数の取得 00051 */ 00052 virtual int getCount() const{ return database_.getCount(); } 00053 00054 /** 00055 * charデータの取得 00056 * @param key 取得するデータのキー 00057 * @param value [out] char化された値が代入されます 00058 * @return trueならデータの取得に成功 00059 */ 00060 virtual bool getChar(const String& key, char* value) const; 00061 00062 /** 00063 * u_charデータの取得 00064 * @param key 取得するデータのキー 00065 * @param value [out] u_char化された値が代入されます 00066 * @return trueならデータの取得に成功 00067 */ 00068 virtual bool getUChar(const String& key, u_char* value) const; 00069 00070 /** 00071 * shortデータの取得 00072 * @param key 取得するデータのキー 00073 * @param value [out] short化された値が代入されます 00074 * @return trueならデータの取得に成功 00075 */ 00076 virtual bool getShort(const String& key, short* value) const; 00077 00078 /** 00079 * u_shortデータの取得 00080 * @param key 取得するデータのキー 00081 * @param value [out] u_short化された値が代入されます 00082 * @return trueならデータの取得に成功 00083 */ 00084 virtual bool getUShort(const String& key, u_short* value) const; 00085 00086 /** 00087 * intデータの取得 00088 * @param key 取得するデータのキー 00089 * @param value [out] int化された値が代入されます 00090 * @return trueならデータの取得に成功 00091 */ 00092 virtual bool getInt(const String& key, int* value) const; 00093 00094 /** 00095 * u_intデータの取得 00096 * @param key 取得するデータのキー 00097 * @param value [out] u_int化された値が代入されます 00098 * @return trueならデータの取得に成功 00099 */ 00100 virtual bool getUInt(const String& key, u_int* value) const; 00101 00102 /** 00103 * floatデータの取得 00104 * @param key 取得するデータのキー 00105 * @param value [out] float化された値が代入されます 00106 * @return trueならデータの取得に成功 00107 */ 00108 virtual bool getFloat(const String& key, float* value) const; 00109 00110 /** 00111 * doubleデータの取得 00112 * @param key 取得するデータのキー 00113 * @param value [out] double化された値が代入されます 00114 * @return trueならデータの取得に成功 00115 */ 00116 virtual bool getDouble(const String& key, double* value) const; 00117 00118 /** 00119 * Stringデータの取得 00120 * @param key 取得するデータのキー 00121 * @param value [out] String値が代入されます 00122 * @return trueならデータの取得に成功 00123 */ 00124 virtual bool getString(const String& key, String* value) const; 00125 00126 private: 00127 /** 00128 * ロード 00129 * @param fileName ロードするコンフィグファイル名 00130 */ 00131 virtual void load(const String& fileName); 00132 00133 /** 00134 * データの追加 00135 * @param key 追加するデータのキー 00136 * @param value 追加するデータ 00137 */ 00138 virtual void add(const String& key, const String& value); 00139 00140 // コピーコンストラクタの隠蔽 00141 ConfigurationFile(const ConfigurationFile& copy); 00142 00143 // 代入コピーの隠蔽 00144 void operator =(const ConfigurationFile& copy); 00145 00146 // ファイル名 00147 String fileName_; 00148 // データベース 00149 HashMap<String, String> database_; 00150 }; 00151 00152 //------------------------------------------------------------------------------ 00153 } // End of namespace Lamp 00154 #endif // End of CONFIGURATION_FILE_H_ 00155 //------------------------------------------------------------------------------