PixelLightAPI  .
StringBufferUTF8.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: StringBufferUTF8.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_STRINGBUFFER_UTF8_H__
00024 #define __PLCORE_STRINGBUFFER_UTF8_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/String/StringBuffer.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLCore {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Classes                                               ]
00042 //[-------------------------------------------------------]
00043 /**
00044 *  @brief
00045 *    Class that contains the buffer for a UTF8 string
00046 *
00047 *  @note
00048 *    - Unlike StringBufferASCII and StringBufferUnicode, the sole purpose of this implementation is to keep a cached UTF8 version of a string
00049 */
00050 class StringBufferUTF8 : public StringBuffer {
00051 
00052 
00053     //[-------------------------------------------------------]
00054     //[ Friends                                               ]
00055     //[-------------------------------------------------------]
00056     friend class String;
00057     friend class StringBufferManager;
00058     friend class StringBufferASCII;
00059     friend class StringBufferUnicode;
00060 
00061 
00062     //[-------------------------------------------------------]
00063     //[ Private functions                                     ]
00064     //[-------------------------------------------------------]
00065     private:
00066         /**
00067         *  @brief
00068         *    Constructor
00069         *
00070         *  @param[in] szString
00071         *    The string (converted to UTF8)
00072         *  @param[in] nLength
00073         *    Length of the string buffer (excluding the terminating zero)
00074         */
00075         StringBufferUTF8(char szString[], uint32 nLength);
00076 
00077         /**
00078         *  @brief
00079         *    Constructor
00080         *
00081         *  @param[in] szString
00082         *    The string (converted to UTF8)
00083         *  @param[in] nLength
00084         *    Length of the string buffer (excluding the terminating zero)
00085         */
00086         StringBufferUTF8(const wchar_t szString[], uint32 nLength);
00087 
00088         /**
00089         *  @brief
00090         *    Destructor
00091         */
00092         virtual ~StringBufferUTF8();
00093 
00094 
00095     //[-------------------------------------------------------]
00096     //[ Private data                                          ]
00097     //[-------------------------------------------------------]
00098     private:
00099         char   *m_pszString;    /**< The string itself (NEVER a null pointer!) */
00100         uint32  m_nNumOfBytes;  /**< Number of bytes of the string */
00101 
00102 
00103     //[-------------------------------------------------------]
00104     //[ Public virtual StringBuffer functions                 ]
00105     //[-------------------------------------------------------]
00106     public:
00107         virtual uint32 GetFormat() const override;
00108         virtual StringBufferASCII *GetASCII() override;
00109         virtual StringBufferUnicode *GetUnicode() override;
00110         virtual StringBufferUTF8 *GetUTF8() override;
00111         virtual uint32 GetNumOfBytes() const override;
00112         virtual StringBuffer *Clone() const override;
00113         virtual StringBuffer *Duplicate() override;
00114         virtual bool IsLessThan(const char szString[], uint32 nLength) const override;
00115         virtual bool IsLessThan(const wchar_t szString[], uint32 nLength) const override;
00116         virtual bool IsGreaterThan(const char szString[], uint32 nLength) const override;
00117         virtual bool IsGreaterThan(const wchar_t szString[], uint32 nLength) const override;
00118         virtual bool Compare(const char szString[], uint32 nLength, uint32 nPos, uint32 nCount) const override;
00119         virtual bool Compare(const wchar_t szString[], uint32 nLength, uint32 nPos, uint32 nCount) const override;
00120         virtual bool CompareNoCase(const char szString[], uint32 nLength, uint32 nPos, uint32 nCount) const override;
00121         virtual bool CompareNoCase(const wchar_t szString[], uint32 nLength, uint32 nPos, uint32 nCount) const override;
00122         virtual bool IsAlphabetic() const override;
00123         virtual bool IsAlphaNumeric() const override;
00124         virtual bool IsNumeric() const override;
00125         virtual bool IsSubstring(const char szString[], uint32 nLength) const override;
00126         virtual bool IsSubstring(const wchar_t szString[], uint32 nLength) const override;
00127         virtual int IndexOf(const char szString[], uint32 nPos, uint32 nLength) const override;
00128         virtual int IndexOf(const wchar_t szString[], uint32 nPos, uint32 nLength) const override;
00129         virtual int LastIndexOf(const char szString[], int nPos, uint32 nLength) const override;
00130         virtual int LastIndexOf(const wchar_t szString[], int nPos, uint32 nLength) const override;
00131         virtual StringBuffer *GetSubstring(uint32 nPos, uint32 nCount) const override;
00132         virtual StringBuffer *ToLower() override;
00133         virtual StringBuffer *ToUpper() override;
00134         virtual StringBuffer *Delete(uint32 nPos, uint32 nCount) override;
00135         virtual StringBuffer *Append(const char szString[], uint32 nCount) override;
00136         virtual StringBuffer *Append(const wchar_t szString[], uint32 nCount) override;
00137         virtual StringBuffer *Insert(const char szString[], uint32 nPos, uint32 nCount) override;
00138         virtual StringBuffer *Insert(const wchar_t szString[], uint32 nPos, uint32 nCount) override;
00139         virtual StringBuffer *Replace(char nOld, char nNew, uint32 &nReplaced) override;
00140         virtual StringBuffer *Replace(wchar_t nOld, wchar_t nNew, uint32 &nReplaced) override;
00141         virtual StringBuffer *Replace(const char szOld[], uint32 nOldLength, const char szNew[], uint32 nNewLength, uint32 &nReplaced) override;
00142         virtual StringBuffer *Replace(const wchar_t szOld[], uint32 nOldLength, const wchar_t szNew[], uint32 nNewLength, uint32 &nReplaced) override;
00143         virtual StringBuffer *SetCharacter(uint32 nIndex, char nCharacter) override;
00144         virtual StringBuffer *SetCharacter(uint32 nIndex, wchar_t nCharacter) override;
00145         virtual StringBuffer *TrimLeading() override;
00146         virtual StringBuffer *TrimTrailing() override;
00147         virtual StringBuffer *RemoveLineEndings() override;
00148 
00149 
00150 };
00151 
00152 
00153 //[-------------------------------------------------------]
00154 //[ Namespace                                             ]
00155 //[-------------------------------------------------------]
00156 } // PLCore
00157 
00158 
00159 #endif // __PLCORE_STRINGBUFFER_UTF8_H__


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