PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: StringBufferManager.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_STRINGBUFFERMANAGER_H__ 00024 #define __PLCORE_STRINGBUFFERMANAGER_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/PLCore.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLCore { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Forward declarations ] 00042 //[-------------------------------------------------------] 00043 class StringBuffer; 00044 class StringBufferUTF8; 00045 class StringBufferASCII; 00046 class StringBufferUnicode; 00047 00048 00049 //[-------------------------------------------------------] 00050 //[ Classes ] 00051 //[-------------------------------------------------------] 00052 /** 00053 * @brief 00054 * String buffer manager 00055 */ 00056 class StringBufferManager { 00057 00058 00059 //[-------------------------------------------------------] 00060 //[ Friends ] 00061 //[-------------------------------------------------------] 00062 friend class String; 00063 friend class StringBuffer; 00064 friend class StringBufferUTF8; 00065 friend class StringBufferASCII; 00066 friend class StringBufferUnicode; 00067 00068 00069 //[-------------------------------------------------------] 00070 //[ Private static data ] 00071 //[-------------------------------------------------------] 00072 private: 00073 static const uint32 NumOfReservedCharacters = 64; /**< Number of reserved characters for future use to add when allocating a new string buffer */ 00074 static const uint32 MaxStringReuseLength = 256; /**< We don't want to keep alive long strings for later reuse... */ 00075 static const uint32 MaxStringsPerReuseLength = 4; /**< Number of reusable strings per string length */ 00076 00077 00078 //[-------------------------------------------------------] 00079 //[ Private functions ] 00080 //[-------------------------------------------------------] 00081 private: 00082 /** 00083 * @brief 00084 * Constructor 00085 */ 00086 StringBufferManager(); 00087 00088 /** 00089 * @brief 00090 * Destructor 00091 */ 00092 ~StringBufferManager(); 00093 00094 /** 00095 * @brief 00096 * Returns an instance of a ASCII string buffer 00097 * 00098 * @param[in] nLength 00099 * Minimum internal length of the string buffer (excluding the terminating zero, MUST be valid!) 00100 * 00101 * @return 00102 * Instance of a ASCII string buffer, a null pointer on error 00103 * 00104 * @note 00105 * - The length of the string buffer is 0, but it has already reserved memory for at least "nLength" characters (+ an additional terminating zero) 00106 */ 00107 StringBufferASCII *GetStringBufferASCII(uint32 nLength); 00108 00109 /** 00110 * @brief 00111 * Returns an instance of a unicode string buffer 00112 * 00113 * @param[in] nLength 00114 * Minimum internal length of the string buffer (excluding the terminating zero, MUST be valid!) 00115 * 00116 * @return 00117 * Instance of a unicode string buffer, a null pointer on error 00118 * 00119 * @note 00120 * - The length of the string buffer is 0, but it has already reserved memory for at least "nLength" characters (+ an additional terminating zero) 00121 */ 00122 StringBufferUnicode *GetStringBufferUnicode(uint32 nLength); 00123 00124 /** 00125 * @brief 00126 * Releases an instance of a string buffer 00127 * 00128 * @param[in] cStringBuffer 00129 * String buffer instance to release 00130 */ 00131 PLCORE_API void ReleaseStringBuffer(StringBuffer &cStringBuffer); 00132 00133 00134 //[-------------------------------------------------------] 00135 //[ Private data ] 00136 //[-------------------------------------------------------] 00137 private: 00138 StringBufferASCII **m_pStringBufferASCII; /**< Reusable ASCII string buffers, can be a null pointer */ 00139 StringBufferUnicode **m_pStringBufferUnicode; /**< Reusable unicode string buffers, can be a null pointer */ 00140 00141 00142 }; 00143 00144 00145 //[-------------------------------------------------------] 00146 //[ Namespace ] 00147 //[-------------------------------------------------------] 00148 } 00149 00150 00151 #endif // __PLCORE_STRINGBUFFERMANAGER_H__
|