Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccUTF16String Class Reference

#include <IccUtilXml.h>

+ Collaboration diagram for CIccUTF16String:

Public Member Functions

const icUInt16Numberc_str ()
 
 CIccUTF16String ()
 
 CIccUTF16String (const char *szStr)
 
 CIccUTF16String (const CIccUTF16String &str)
 
 CIccUTF16String (const icUInt16Number *uzStr)
 
void Clear ()
 
bool FromUtf8 (const char *szStr, size_t sizeSrc=0)
 
CIccUTF16Stringoperator= (const char *szStr)
 
CIccUTF16Stringoperator= (const CIccUTF16String &wstr)
 
CIccUTF16Stringoperator= (const icUInt16Number *uzStr)
 
icUInt16Number operator[] (size_t m_nIndex)
 
bool Resize (size_t len)
 
size_t Size ()
 
const char * ToUtf8 (std::string &buf)
 
const wchar_t * ToWString (std::wstring &buf)
 
virtual ~CIccUTF16String ()
 

Static Public Member Functions

static size_t WStrlen (const icUInt16Number *uzStr)
 

Static Protected Member Functions

static size_t AllocSize (size_t n)
 

Protected Attributes

size_t m_alloc
 
size_t m_len
 
icUInt16Numberm_str
 

Detailed Description

Definition at line 74 of file IccUtilXml.h.

Constructor & Destructor Documentation

◆ CIccUTF16String() [1/4]

CIccUTF16String::CIccUTF16String ( )

Definition at line 80 of file IccUtilXml.cpp.

81{
82 m_alloc=64;
83 m_len = 0;
84 m_str = (icUInt16Number*)calloc(m_alloc, sizeof(icUInt16Number));
85}
icUInt16Number * m_str
Definition IccUtilXml.h:105
unsigned short icUInt16Number

References m_alloc, m_len, and m_str.

◆ CIccUTF16String() [2/4]

CIccUTF16String::CIccUTF16String ( const icUInt16Number * uzStr)

Definition at line 87 of file IccUtilXml.cpp.

88{
89 m_len = WStrlen(uzStr);
91
92 m_str = (icUInt16Number *)malloc(m_alloc*sizeof(icUInt16Number));
93 memcpy(m_str, uzStr, m_len+1*sizeof(icUInt16Number));
94}
static size_t AllocSize(size_t n)
Definition IccUtilXml.h:102
static size_t WStrlen(const icUInt16Number *uzStr)

References AllocSize(), m_alloc, m_len, m_str, and WStrlen().

+ Here is the call graph for this function:

◆ CIccUTF16String() [3/4]

CIccUTF16String::CIccUTF16String ( const char * szStr)

Definition at line 96 of file IccUtilXml.cpp.

97{
98 size_t sizeSrc = strlen(szStr);
99
100 if (sizeSrc) {
101 m_alloc = AllocSize(sizeSrc*2);
102 m_str = (UTF16 *)calloc(m_alloc, sizeof(icUInt16Number)); //overallocate to allow for up to 4 bytes per character
103 UTF16 *szDest = m_str;
104 icConvertUTF8toUTF16((const UTF8 **)&szStr, (const UTF8 *)&szStr[sizeSrc], &szDest, &szDest[m_alloc], lenientConversion);
105 if (m_str[0]==0xfeff) {
106 size_t i;
107 for (i=1; m_str[i]; i++)
108 m_str[i-1] = m_str[i];
109 m_str[i-1] = 0;
110 }
112 }
113 else {
114 m_alloc = 64;
115 m_len = 0;
116 m_str = (icUInt16Number*)calloc(m_alloc, sizeof(icUInt16Number));
117 }
118}
icUtfConversionResult icConvertUTF8toUTF16(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, icUtfConversionFlags flags)
unsigned short UTF16
unsigned char UTF8
@ lenientConversion

References AllocSize(), icConvertUTF8toUTF16(), lenientConversion, m_alloc, m_len, m_str, and WStrlen().

+ Here is the call graph for this function:

◆ CIccUTF16String() [4/4]

CIccUTF16String::CIccUTF16String ( const CIccUTF16String & str)

Definition at line 120 of file IccUtilXml.cpp.

121{
122 m_alloc = str.m_alloc;
123 m_len = str.m_len;
124 m_str = (icUInt16Number*)malloc(m_alloc*sizeof(icUInt16Number));
125
126 memcpy(m_str, str.m_str, (m_alloc)*sizeof(icUInt16Number));
127}

References m_alloc, m_len, and m_str.

◆ ~CIccUTF16String()

CIccUTF16String::~CIccUTF16String ( )
virtual

Definition at line 129 of file IccUtilXml.cpp.

130{
131 free(m_str);
132}

References m_str.

Member Function Documentation

◆ AllocSize()

static size_t CIccUTF16String::AllocSize ( size_t n)
inlinestaticprotected

Definition at line 102 of file IccUtilXml.h.

102{ return (((n+64)/64)*64); }

Referenced by CIccUTF16String(), CIccUTF16String(), FromUtf8(), operator=(), and Resize().

+ Here is the caller graph for this function:

◆ c_str()

const icUInt16Number * CIccUTF16String::c_str ( )
inline

Definition at line 93 of file IccUtilXml.h.

93{ return m_str; }

References m_str.

Referenced by icUtf8ToUtf16(), CIccTagXmlDict::ParseXml(), CIccTagXmlMultiLocalizedUnicode::ParseXml(), and CIccTagXmlProfileSequenceId::ParseXml().

+ Here is the caller graph for this function:

◆ Clear()

void CIccUTF16String::Clear ( )

Definition at line 134 of file IccUtilXml.cpp.

135{
136 m_len = 0;
137 m_str[0] = 0;
138}

References m_len, and m_str.

◆ FromUtf8()

bool CIccUTF16String::FromUtf8 ( const char * szStr,
size_t sizeSrc = 0 )

Definition at line 223 of file IccUtilXml.cpp.

224{
225 if (!sizeSrc)
226 sizeSrc = strlen(szStr);
227
228 if (sizeSrc) {
229 size_t nAlloc = AllocSize(sizeSrc*2);
230 if (m_alloc<=nAlloc) {
231 m_str = (icUInt16Number*)icRealloc(m_str, nAlloc *sizeof(icUInt16Number));
232 m_alloc = nAlloc;
233 }
234 if (m_str) {
235 memset(m_str, 0, m_alloc * sizeof(icUInt16Number));
236 UTF16 *szDest = m_str;
237 icConvertUTF8toUTF16((const UTF8 **)&szStr, (const UTF8 *)&szStr[sizeSrc], &szDest, &szDest[m_alloc], lenientConversion);
238 if (m_str[0]==0xfeff) {
239 size_t i;
240 for (i=1; m_str[i]; i++)
241 m_str[i-1] = m_str[i];
242 m_str[i-1] = 0;
243 }
245 }
246 else {
247 m_len =0;
248 return false;
249 }
250 }
251 else {
252 m_len = 0;
253 m_str[0] = 0;
254 }
255 return true;
256}
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
Definition IccUtil.cpp:111

References AllocSize(), icConvertUTF8toUTF16(), icRealloc(), lenientConversion, m_alloc, m_len, m_str, and WStrlen().

Referenced by icUtf8ToUtf16(), and operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/3]

CIccUTF16String & CIccUTF16String::operator= ( const char * szStr)

Definition at line 191 of file IccUtilXml.cpp.

192{
193 FromUtf8(szStr, 0);
194
195 return *this;
196}
bool FromUtf8(const char *szStr, size_t sizeSrc=0)

References FromUtf8().

+ Here is the call graph for this function:

◆ operator=() [2/3]

CIccUTF16String & CIccUTF16String::operator= ( const CIccUTF16String & wstr)

Definition at line 170 of file IccUtilXml.cpp.

171{
172 if (m_alloc<=wstr.m_alloc) {
174 if (m_str)
175 m_alloc = wstr.m_alloc;
176 else
177 m_alloc = 0;
178 }
179 if (m_str) {
180 m_len = wstr.m_len;
181
182 memcpy(m_str, wstr.m_str, (m_len+1)*sizeof(icUInt16Number));
183 }
184 else {
185 m_len = 0;
186 }
187
188 return *this;
189}

References icRealloc(), m_alloc, m_len, and m_str.

+ Here is the call graph for this function:

◆ operator=() [3/3]

CIccUTF16String & CIccUTF16String::operator= ( const icUInt16Number * uzStr)

Definition at line 198 of file IccUtilXml.cpp.

199{
200 size_t n = WStrlen(uzStr);
201 size_t nAlloc = AllocSize(n);
202
203 if (m_alloc<=nAlloc) {
205 if (m_str)
206 m_alloc = nAlloc;
207 else
208 m_alloc = 0;
209 }
210 if (m_str) {
211 m_len = n;
212
213 memcpy(m_str, uzStr, (m_len+1)*sizeof(icUInt16Number));
214 }
215 else {
216 m_len = 0;
217 }
218
219 return *this;
220}

References AllocSize(), icRealloc(), m_alloc, m_len, m_str, and WStrlen().

+ Here is the call graph for this function:

◆ operator[]()

icUInt16Number CIccUTF16String::operator[] ( size_t m_nIndex)
inline

Definition at line 91 of file IccUtilXml.h.

91{ return m_str[m_nIndex]; }

References m_str.

◆ Resize()

bool CIccUTF16String::Resize ( size_t len)

Definition at line 140 of file IccUtilXml.cpp.

141{
142 if (len>m_alloc) {
143 size_t nAlloc = AllocSize(len);
144
146
147 if (!m_str) {
148 m_len = 0;
149 return false;
150 }
151 m_alloc = nAlloc;
152 }
153
154 if (len>m_len) {
155 memset(&m_str[m_len], 0x0020, (len-m_len)*sizeof(icUInt16Number));
156 }
157 m_len = len;
158 m_str[m_len] = 0;
159 return true;
160}

References AllocSize(), icRealloc(), m_alloc, m_len, and m_str.

+ Here is the call graph for this function:

◆ Size()

size_t CIccUTF16String::Size ( )
inline

Definition at line 84 of file IccUtilXml.h.

84{ return m_len; }

References m_len.

Referenced by CIccTagXmlTextDescription::ParseXml().

+ Here is the caller graph for this function:

◆ ToUtf8()

const char * CIccUTF16String::ToUtf8 ( std::string & buf)

Definition at line 258 of file IccUtilXml.cpp.

259{
260 return icUtf16ToUtf8(buf, m_str, (int)m_len);
261}
const char * icUtf16ToUtf8(std::string &buf, const icUInt16Number *szSrc, int sizeSrc=0)

References icUtf16ToUtf8(), m_len, and m_str.

+ Here is the call graph for this function:

◆ ToWString()

const wchar_t * CIccUTF16String::ToWString ( std::wstring & buf)

Definition at line 263 of file IccUtilXml.cpp.

264{
265 size_t i;
266
267 buf.clear();
268
269 for (i=0; i<m_len; i++) {
270 buf += (wchar_t)m_str[i];
271 }
272
273 return buf.c_str();
274}

References m_len, and m_str.

Referenced by CIccTagXmlDict::ParseXml().

+ Here is the caller graph for this function:

◆ WStrlen()

size_t CIccUTF16String::WStrlen ( const icUInt16Number * uzStr)
static

Definition at line 162 of file IccUtilXml.cpp.

163{
164 size_t n=0;
165 while(uzStr[n]) n++;
166
167 return n;
168}

Referenced by CIccUTF16String(), CIccUTF16String(), FromUtf8(), icUtf16ToUtf8(), and operator=().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_alloc

size_t CIccUTF16String::m_alloc
protected

◆ m_len

size_t CIccUTF16String::m_len
protected

◆ m_str


The documentation for this class was generated from the following files: