PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: LocalizationGroup.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLCORE_LOCALIZATIONGROUP_H__ 00024 #define __PLCORE_LOCALIZATIONGROUP_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/Container/Array.h" 00032 #include "PLCore/Container/HashMap.h" 00033 #include "PLCore/Tools/Loadable.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Namespace ] 00038 //[-------------------------------------------------------] 00039 namespace PLCore { 00040 00041 00042 //[-------------------------------------------------------] 00043 //[ Forward declarations ] 00044 //[-------------------------------------------------------] 00045 class LocalizationText; 00046 00047 00048 //[-------------------------------------------------------] 00049 //[ Classes ] 00050 //[-------------------------------------------------------] 00051 /** 00052 * @brief 00053 * Localization group 00054 */ 00055 class LocalizationGroup : public Loadable { 00056 00057 00058 //[-------------------------------------------------------] 00059 //[ Friends ] 00060 //[-------------------------------------------------------] 00061 friend class Localization; 00062 00063 00064 //[-------------------------------------------------------] 00065 //[ Public static data ] 00066 //[-------------------------------------------------------] 00067 public: 00068 static PLCORE_API const String English; /**< "English" (default) */ 00069 00070 00071 //[-------------------------------------------------------] 00072 //[ Public functions ] 00073 //[-------------------------------------------------------] 00074 public: 00075 /** 00076 * @brief 00077 * Returns the name of the group 00078 * 00079 * @return 00080 * The name of the group 00081 */ 00082 inline String GetName() const; 00083 00084 /** 00085 * @brief 00086 * Returns the language used as 'from-key' 00087 * 00088 * @return 00089 * The language used as 'from-key' 00090 */ 00091 inline String GetFromLanguage() const; 00092 00093 /** 00094 * @brief 00095 * Sets the language used as 'from-key' 00096 * 00097 * @param[in] sFrom 00098 * The language used as 'from-key' 00099 */ 00100 inline void SetFromLanguage(const String &sFrom = English); 00101 00102 /** 00103 * @brief 00104 * Returns the language used as 'to-key' 00105 * 00106 * @return 00107 * The language used as 'to-key' 00108 */ 00109 inline String GetToLanguage() const; 00110 00111 /** 00112 * @brief 00113 * Sets the language used as 'to-key' 00114 * 00115 * @param[in] sTo 00116 * The language used as 'to-key' 00117 */ 00118 inline void SetToLanguage(const String &sTo = English); 00119 00120 /** 00121 * @brief 00122 * Returns the number of texts 00123 * 00124 * @return 00125 * The number of texts 00126 */ 00127 inline uint32 GetNumOfTexts() const; 00128 00129 /** 00130 * @brief 00131 * Returns a text by index 00132 * 00133 * @param[in] nIndex 00134 * Index of the text 00135 * 00136 * @return 00137 * The requested text, a null pointer on error 00138 */ 00139 inline LocalizationText *GetText(uint32 nIndex) const; 00140 00141 /** 00142 * @brief 00143 * Returns a text by name 00144 * 00145 * @param[in] sName 00146 * Name of the text 00147 * 00148 * @return 00149 * The requested text, a null pointer on error 00150 */ 00151 inline LocalizationText *GetText(const String &sName) const; 00152 00153 /** 00154 * @brief 00155 * Adds a new text 00156 * 00157 * @param[in] sName 00158 * Name of the new text 00159 * @param[in] sTranslation 00160 * The translation of the text 00161 * 00162 * @return 00163 * The new text, a null pointer on error (maybe there's already a text with the given name?) 00164 */ 00165 PLCORE_API LocalizationText *AddText(const String &sName, const String &sTranslation); 00166 00167 /** 00168 * @brief 00169 * Removes a text by index 00170 * 00171 * @param[in] nIndex 00172 * Index of the text 00173 * 00174 * @return 00175 * 'true' if all went fine, else 'false' (maybe there's no text with the given name?) 00176 */ 00177 PLCORE_API bool RemoveText(uint32 nIndex); 00178 00179 /** 00180 * @brief 00181 * Removes a text by name 00182 * 00183 * @param[in] sName 00184 * Name of the text 00185 * 00186 * @return 00187 * 'true' if all went fine, else 'false' (maybe there's no text with the given name?) 00188 */ 00189 PLCORE_API bool RemoveText(const String &sName); 00190 00191 /** 00192 * @brief 00193 * Removes all texts 00194 */ 00195 PLCORE_API void RemoveAllTexts(); 00196 00197 00198 //[-------------------------------------------------------] 00199 //[ Private functions ] 00200 //[-------------------------------------------------------] 00201 private: 00202 /** 00203 * @brief 00204 * Constructor 00205 * 00206 * @param[in] sName 00207 * Name of the group 00208 */ 00209 LocalizationGroup(const String &sName); 00210 00211 /** 00212 * @brief 00213 * Copy constructor 00214 * 00215 * @param[in] cSource 00216 * Source to copy from 00217 */ 00218 LocalizationGroup(const LocalizationGroup &cSource); 00219 00220 /** 00221 * @brief 00222 * Destructor 00223 */ 00224 virtual ~LocalizationGroup(); 00225 00226 /** 00227 * @brief 00228 * Copy operator 00229 * 00230 * @param[in] cSource 00231 * Source to copy from 00232 * 00233 * @return 00234 * Reference to this instance 00235 */ 00236 LocalizationGroup &operator =(const LocalizationGroup &cSource); 00237 00238 00239 //[-------------------------------------------------------] 00240 //[ Private data ] 00241 //[-------------------------------------------------------] 00242 private: 00243 String m_sName; /**< Name of the group */ 00244 String m_sFromLanguage; /**< The language used as 'from-key' */ 00245 String m_sToLanguage; /**< The language used as 'to-key' */ 00246 Array<LocalizationText*> m_lstTexts; /**< Localization texts list */ 00247 HashMap<String, LocalizationText*> m_mapTexts; /**< Localization texts map */ 00248 00249 00250 //[-------------------------------------------------------] 00251 //[ Public virtual Loadable functions ] 00252 //[-------------------------------------------------------] 00253 public: 00254 PLCORE_API virtual bool Unload() override; 00255 PLCORE_API virtual String GetLoadableTypeName() const override; 00256 00257 00258 }; 00259 00260 00261 //[-------------------------------------------------------] 00262 //[ Namespace ] 00263 //[-------------------------------------------------------] 00264 } // PLCore 00265 00266 00267 //[-------------------------------------------------------] 00268 //[ Implementation ] 00269 //[-------------------------------------------------------] 00270 #include "PLCore/Tools/LocalizationGroup.inl" 00271 00272 00273 #endif // __PLCORE_LOCALIZATIONGROUP_H__
|