PixelLightAPI  .
ParamsParserXml.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: ParamsParserXml.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_TOOLS_PARAMSPARSERXML_H__
00024 #define __PLCORE_TOOLS_PARAMSPARSERXML_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/String/String.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLCore {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Forward declarations                                  ]
00042 //[-------------------------------------------------------]
00043 class XmlElement;
00044 class XmlAttribute;
00045 
00046 
00047 //[-------------------------------------------------------]
00048 //[ Classes                                               ]
00049 //[-------------------------------------------------------]
00050 /**
00051 *  @brief
00052 *    Class for parsing parameters from XML
00053 *
00054 *  @remarks
00055 *    This class can parse parameter lists given as XML (e.g. "<Node Param0=\"Hello\" Param1=\"10\" />")
00056 */
00057 class ParamsParserXml {
00058 
00059 
00060     //[-------------------------------------------------------]
00061     //[ Public functions                                      ]
00062     //[-------------------------------------------------------]
00063     public:
00064         /**
00065         *  @brief
00066         *    Constructor
00067         */
00068         inline ParamsParserXml();
00069 
00070         /**
00071         *  @brief
00072         *    Destructor
00073         */
00074         inline ~ParamsParserXml();
00075 
00076         /**
00077         *  @brief
00078         *    Parse parameters from XML
00079         *
00080         *  @param[in] cElement
00081         *    XML element containing parameters
00082         *
00083         *  @return
00084         *    'true' if the element could be parsed, else 'false'
00085         *
00086         *  @remarks
00087         *    This will first check if the XML element has a valid parameter list
00088         *    and then parse the first parameter and value. If the parameter list
00089         *    is empty, the function will return 'false'.
00090         */
00091         PLCORE_API bool ParseXml(const XmlElement &cElement);
00092 
00093         /**
00094         *  @brief
00095         *    Parse next parameter
00096         *
00097         *  @return
00098         *    'true' if the next name/value pair could be parsed, else 'false'
00099         */
00100         PLCORE_API bool Next();
00101 
00102         /**
00103         *  @brief
00104         *    Check if the current (last parsed) parameter is valid
00105         *
00106         *  @return
00107         *    'true' if there is a current parameter, else 'false'
00108         */
00109         inline bool HasParam() const;
00110 
00111         /**
00112         *  @brief
00113         *    Get name of currently parsed parameter
00114         *
00115         *  @return
00116         *    Parameter name
00117         */
00118         inline String GetName() const;
00119 
00120         /**
00121         *  @brief
00122         *    Get value of currently parsed parameter
00123         *
00124         *  @return
00125         *    Parameter name
00126         */
00127         inline String GetValue() const;
00128 
00129 
00130     //[-------------------------------------------------------]
00131     //[ Private data                                          ]
00132     //[-------------------------------------------------------]
00133     private:
00134         const XmlElement    *m_pElement;    /**< XML element */
00135         const XmlAttribute  *m_pAttribute;  /**< XML attribute */
00136         String               m_sName;       /**< Name of next parameter */
00137         String               m_sValue;      /**< Value of next parameter */
00138 
00139 
00140 };
00141 
00142 
00143 //[-------------------------------------------------------]
00144 //[ Namespace                                             ]
00145 //[-------------------------------------------------------]
00146 } // PLCore
00147 
00148 
00149 //[-------------------------------------------------------]
00150 //[ Implementation                                        ]
00151 //[-------------------------------------------------------]
00152 #include "PLCore/Base/Tools/ParamsParserXml.inl"
00153 
00154 
00155 #endif // __PLCORE_TOOLS_PARAMSPARSERXML_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:58
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported