PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: ConfigLoaderPL.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_CONFIGLOADER_PL_H__ 00024 #define __PLCORE_CONFIGLOADER_PL_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/Config/ConfigLoader.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLCore { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Forward declarations ] 00042 //[-------------------------------------------------------] 00043 class XmlElement; 00044 class ConfigGroup; 00045 00046 00047 //[-------------------------------------------------------] 00048 //[ Classes ] 00049 //[-------------------------------------------------------] 00050 /** 00051 * @brief 00052 * Config loader implementation for the PixelLight config XML file format 00053 */ 00054 class ConfigLoaderPL : public ConfigLoader { 00055 00056 00057 //[-------------------------------------------------------] 00058 //[ RTTI interface ] 00059 //[-------------------------------------------------------] 00060 pl_class(PLCORE_RTTI_EXPORT, ConfigLoaderPL, "PLCore", PLCore::ConfigLoader, "Config loader implementation for the PixelLight config XML file format") 00061 // Properties 00062 pl_properties 00063 pl_property("Formats", "cfg,CFG") 00064 pl_property("Load", "1") 00065 pl_property("Save", "1") 00066 pl_properties_end 00067 // Constructors 00068 pl_constructor_0(DefaultConstructor, "Default constructor", "") 00069 // Methods 00070 pl_method_2(Load, pl_ret_type(bool), Config&, File&, "Load method", "") 00071 pl_method_2(Save, pl_ret_type(bool), const Config&, File&, "Save method. Saves all configuration groups and includes default values, too.", "") 00072 pl_method_4(SaveParams, pl_ret_type(bool), const Config&, File&, String, bool, "Save method. Parameters: Configuration group to save as 'String', no default values as 'bool'.", "") 00073 pl_class_end 00074 00075 00076 //[-------------------------------------------------------] 00077 //[ Public RTTI methods ] 00078 //[-------------------------------------------------------] 00079 public: 00080 PLCORE_API bool Load(Config &cConfig, File &cFile); 00081 PLCORE_API bool Save(const Config &cConfig, File &cFile); 00082 PLCORE_API bool SaveParams(const Config &cConfig, File &cFile, String sGroup, bool bNoDefault); 00083 00084 00085 //[-------------------------------------------------------] 00086 //[ Public functions ] 00087 //[-------------------------------------------------------] 00088 public: 00089 /** 00090 * @brief 00091 * Default constructor 00092 */ 00093 PLCORE_API ConfigLoaderPL(); 00094 00095 /** 00096 * @brief 00097 * Destructor 00098 */ 00099 PLCORE_API virtual ~ConfigLoaderPL(); 00100 00101 00102 //[-------------------------------------------------------] 00103 //[ Private functions ] 00104 //[-------------------------------------------------------] 00105 private: 00106 /** 00107 * @brief 00108 * Loader implementation for format version 1 00109 * 00110 * @param[in] cConfig 00111 * Configuration to load into 00112 * @param[in] cConfigElement 00113 * Configuration XML element to read the data from 00114 * 00115 * @return 00116 * 'true' if all went fine, else 'false' 00117 */ 00118 bool LoadV1(Config &cConfig, const XmlElement &cConfigElement) const; 00119 00120 /** 00121 * @brief 00122 * Save configuration group settings 00123 * 00124 * @param[in] cConfigElement 00125 * Configuration element to write in 00126 * @param[in] cGroup 00127 * Configuration group to save 00128 * @param[in] bNoDefault 00129 * If 'true', variables with default values will be ignored 00130 * 00131 * @return 00132 * 'true' if all went fine, else 'false' 00133 */ 00134 bool SaveGroup(XmlElement &cConfigElement, const ConfigGroup &cGroup, bool bNoDefault = false) const; 00135 00136 00137 }; 00138 00139 00140 //[-------------------------------------------------------] 00141 //[ Namespace ] 00142 //[-------------------------------------------------------] 00143 } // PLCore 00144 00145 00146 #endif // __PLCORE_CONFIGLOADER_PL_H__
|