PixelLightAPI  .
ParseTools.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: ParseTools.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_PARSETOOLS_H__
00024 #define __PLCORE_PARSETOOLS_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 //[ Classes                                               ]
00042 //[-------------------------------------------------------]
00043 /**
00044 *  @brief
00045 *    Static class with some useful string parse tool functions
00046 */
00047 class ParseTools {
00048 
00049 
00050     //[-------------------------------------------------------]
00051     //[ Public static functions                               ]
00052     //[-------------------------------------------------------]
00053     public:
00054         /**
00055         *  @brief
00056         *    Parse string containing a hex value to an integer (for example "FF" => "255")
00057         *
00058         *  @param[in] sString
00059         *    String containing a hex value
00060         *
00061         *  @return
00062         *    Integer representation of the given hex value
00063         */
00064         static PLCORE_API uint32 ParseHexValue(const String &sString);
00065 
00066         /**
00067         *  @brief
00068         *    Parse an array of integer values
00069         *
00070         *  @param[in]  sString
00071         *    String containing integer numbers
00072         *  @param[out] pnValues
00073         *    Pointer to C-array which will receive the integer values, if a null pointer nothing happens
00074         *  @param[in]  nMaxNumOfElements
00075         *    The maximum number of elements 'nValues' can hold
00076         *
00077         *  @return
00078         *    The number of read values
00079         *
00080         *  @note
00081         *    - Example string with three values: "0 5 34"
00082         */
00083         static PLCORE_API int ParseIntegerArray(const String &sString, int *pnValues, uint32 nMaxNumOfElements);
00084 
00085         /**
00086         *  @brief
00087         *    Parse an array of float values
00088         *
00089         *  @param[in]  sString
00090         *    String containing floating point numbers
00091         *  @param[out] pfValues
00092         *    Pointer to C-array which will receive the float values, if a null pointer nothing happens
00093         *  @param[in]  nMaxNumOfElements
00094         *    The maximum number of elements 'fValues' can hold
00095         *
00096         *  @return
00097         *    The number of read values
00098         *
00099         *  @note
00100         *    - Example string with three values: "0 0.0 34.245"
00101         */
00102         static PLCORE_API int ParseFloatArray(const String &sString, float *pfValues, uint32 nMaxNumOfElements);
00103 
00104         /**
00105         *  @brief
00106         *    Parse an array of double values
00107         *
00108         *  @param[in]  sString
00109         *    String containing double precision floating point numbers
00110         *  @param[out] pdValues
00111         *    Pointer to C-array which will receive the double values, if a null pointer nothing happens
00112         *  @param[in]  nMaxNumOfElements
00113         *    The maximum number of elements 'dValues' can hold
00114         *
00115         *  @return
00116         *    The number of read values
00117         *
00118         *  @note
00119         *    - Example string with three values: "0 0.0 34.245"
00120         */
00121         static PLCORE_API int ParseDoubleArray(const String &sString, double *pdValues, uint32 nMaxNumOfElements);
00122 
00123         //[-------------------------------------------------------]
00124         //[ Flags                                                 ]
00125         //[-------------------------------------------------------]
00126         /**
00127         *  @brief
00128         *    Returns the flags from a string
00129         *
00130         *  @param[in] sFlags
00131         *    String containing flags
00132         *
00133         *  @return
00134         *    The flags from the string
00135         *
00136         *  @remarks
00137         *    Flags can be stored in strings too. (easy to edit :)\n
00138         *    Example: "1|2|4|8"
00139         */
00140         static PLCORE_API uint32 GetFlagsFromString(const String &sFlags);
00141 
00142         /**
00143         *  @brief
00144         *    Creates a string from flags
00145         *
00146         *  @param[in] nFlags
00147         *    Flags value
00148         *
00149         *  @return
00150         *    String containing the flags in textual form
00151         *
00152         *  @see
00153         *    - GetFlagsFromString()
00154         */
00155         static PLCORE_API String GetStringFromFlags(uint32 nFlags);
00156 
00157 
00158 };
00159 
00160 
00161 //[-------------------------------------------------------]
00162 //[ Namespace                                             ]
00163 //[-------------------------------------------------------]
00164 } // PLCore
00165 
00166 
00167 #endif // __PLCORE_PARSETOOLS_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