| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_INCLUDE_FXCRT_FX_STRING_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_STRING_H_ |
| 8 #define CORE_INCLUDE_FXCRT_FX_STRING_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_STRING_H_ |
| 9 | 9 |
| 10 #include <stdint.h> // For intptr_t. | 10 #include <stdint.h> // For intptr_t. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 { | 24 { |
| 25 public: | 25 public: |
| 26 typedef FX_CHAR value_type; | 26 typedef FX_CHAR value_type; |
| 27 | 27 |
| 28 CFX_ByteStringC() | 28 CFX_ByteStringC() |
| 29 { | 29 { |
| 30 m_Ptr = NULL; | 30 m_Ptr = NULL; |
| 31 m_Length = 0; | 31 m_Length = 0; |
| 32 } | 32 } |
| 33 | 33 |
| 34 CFX_ByteStringC(FX_LPCBYTE ptr, FX_STRSIZE size) | 34 CFX_ByteStringC(const uint8_t* ptr, FX_STRSIZE size) |
| 35 { | 35 { |
| 36 m_Ptr = ptr; | 36 m_Ptr = ptr; |
| 37 m_Length = size; | 37 m_Length = size; |
| 38 } | 38 } |
| 39 | 39 |
| 40 CFX_ByteStringC(FX_LPCSTR ptr) | 40 CFX_ByteStringC(const FX_CHAR* ptr) |
| 41 { | 41 { |
| 42 m_Ptr = (FX_LPCBYTE)ptr; | 42 m_Ptr = (const uint8_t*)ptr; |
| 43 m_Length = ptr ? FXSYS_strlen(ptr) : 0; | 43 m_Length = ptr ? FXSYS_strlen(ptr) : 0; |
| 44 } | 44 } |
| 45 | 45 |
| 46 // |ch| must be an lvalue that outlives the the CFX_ByteStringC. However, | 46 // |ch| must be an lvalue that outlives the the CFX_ByteStringC. However, |
| 47 // the use of char rvalues are not caught at compile time. They are | 47 // the use of char rvalues are not caught at compile time. They are |
| 48 // implicitly promoted to CFX_ByteString (see below) and then the | 48 // implicitly promoted to CFX_ByteString (see below) and then the |
| 49 // CFX_ByteStringC is constructed from the CFX_ByteString via the alternate | 49 // CFX_ByteStringC is constructed from the CFX_ByteString via the alternate |
| 50 // constructor below. The CFX_ByteString then typically goes out of scope | 50 // constructor below. The CFX_ByteString then typically goes out of scope |
| 51 // and |m_Ptr| may be left pointing to invalid memory. Beware. | 51 // and |m_Ptr| may be left pointing to invalid memory. Beware. |
| 52 // TODO(tsepez): Mark single-argument string constructors as explicit. | 52 // TODO(tsepez): Mark single-argument string constructors as explicit. |
| 53 CFX_ByteStringC(FX_CHAR& ch) | 53 CFX_ByteStringC(FX_CHAR& ch) |
| 54 { | 54 { |
| 55 m_Ptr = (FX_LPCBYTE)&ch; | 55 m_Ptr = (const uint8_t*)&ch; |
| 56 m_Length = 1; | 56 m_Length = 1; |
| 57 } | 57 } |
| 58 | 58 |
| 59 CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len) | 59 CFX_ByteStringC(const FX_CHAR* ptr, FX_STRSIZE len) |
| 60 { | 60 { |
| 61 m_Ptr = (FX_LPCBYTE)ptr; | 61 m_Ptr = (const uint8_t*)ptr; |
| 62 m_Length = (len == -1) ? FXSYS_strlen(ptr) : len; | 62 m_Length = (len == -1) ? FXSYS_strlen(ptr) : len; |
| 63 } | 63 } |
| 64 | 64 |
| 65 CFX_ByteStringC(const CFX_ByteStringC& src) | 65 CFX_ByteStringC(const CFX_ByteStringC& src) |
| 66 { | 66 { |
| 67 m_Ptr = src.m_Ptr; | 67 m_Ptr = src.m_Ptr; |
| 68 m_Length = src.m_Length; | 68 m_Length = src.m_Length; |
| 69 } | 69 } |
| 70 | 70 |
| 71 CFX_ByteStringC(const CFX_ByteString& src); | 71 CFX_ByteStringC(const CFX_ByteString& src); |
| 72 | 72 |
| 73 CFX_ByteStringC& operator = (FX_LPCSTR src) | 73 CFX_ByteStringC& operator = (const FX_CHAR* src) |
| 74 { | 74 { |
| 75 m_Ptr = (FX_LPCBYTE)src; | 75 m_Ptr = (const uint8_t*)src; |
| 76 m_Length = m_Ptr ? FXSYS_strlen(src) : 0; | 76 m_Length = m_Ptr ? FXSYS_strlen(src) : 0; |
| 77 return *this; | 77 return *this; |
| 78 } | 78 } |
| 79 | 79 |
| 80 CFX_ByteStringC& operator = (const CFX_ByteStringC& src) | 80 CFX_ByteStringC& operator = (const CFX_ByteStringC& src) |
| 81 { | 81 { |
| 82 m_Ptr = src.m_Ptr; | 82 m_Ptr = src.m_Ptr; |
| 83 m_Length = src.m_Length; | 83 m_Length = src.m_Length; |
| 84 return *this; | 84 return *this; |
| 85 } | 85 } |
| 86 | 86 |
| 87 CFX_ByteStringC& operator = (const CFX_ByteString& src); | 87 CFX_ByteStringC& operator = (const CFX_ByteString& src); |
| 88 | 88 |
| 89 bool operator== (const char* ptr) const { | 89 bool operator== (const char* ptr) const { |
| 90 return FXSYS_strlen(ptr) == m_Length && | 90 return FXSYS_strlen(ptr) == m_Length && |
| 91 FXSYS_memcmp32(ptr, m_Ptr, m_Length) == 0; | 91 FXSYS_memcmp32(ptr, m_Ptr, m_Length) == 0; |
| 92 } | 92 } |
| 93 bool operator== (const CFX_ByteStringC& other) const { | 93 bool operator== (const CFX_ByteStringC& other) const { |
| 94 return other.m_Length == m_Length && | 94 return other.m_Length == m_Length && |
| 95 FXSYS_memcmp32(other.m_Ptr, m_Ptr, m_Length) == 0; | 95 FXSYS_memcmp32(other.m_Ptr, m_Ptr, m_Length) == 0; |
| 96 } | 96 } |
| 97 bool operator!= (const char* ptr) const { return !(*this == ptr); } | 97 bool operator!= (const char* ptr) const { return !(*this == ptr); } |
| 98 bool operator!= (const CFX_ByteStringC& other) const { | 98 bool operator!= (const CFX_ByteStringC& other) const { |
| 99 return !(*this == other); | 99 return !(*this == other); |
| 100 } | 100 } |
| 101 | 101 |
| 102 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const; | 102 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const; |
| 103 | 103 |
| 104 FX_LPCBYTE» » GetPtr() const | 104 const uint8_t*» » GetPtr() const |
| 105 { | 105 { |
| 106 return m_Ptr; | 106 return m_Ptr; |
| 107 } | 107 } |
| 108 | 108 |
| 109 FX_LPCSTR» » GetCStr() const | 109 const FX_CHAR*» » GetCStr() const |
| 110 { | 110 { |
| 111 return (FX_LPCSTR)m_Ptr; | 111 return (const FX_CHAR*)m_Ptr; |
| 112 } | 112 } |
| 113 | 113 |
| 114 FX_STRSIZE GetLength() const | 114 FX_STRSIZE GetLength() const |
| 115 { | 115 { |
| 116 return m_Length; | 116 return m_Length; |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool IsEmpty() const | 119 bool IsEmpty() const |
| 120 { | 120 { |
| 121 return m_Length == 0; | 121 return m_Length == 0; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 145 return m_Ptr[index]; | 145 return m_Ptr[index]; |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool operator< (const CFX_ByteStringC& that) const | 148 bool operator< (const CFX_ByteStringC& that) const |
| 149 { | 149 { |
| 150 int result = memcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length)
); | 150 int result = memcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length)
); |
| 151 return result < 0 || (result == 0 && m_Length < that.m_Length); | 151 return result < 0 || (result == 0 && m_Length < that.m_Length); |
| 152 } | 152 } |
| 153 | 153 |
| 154 protected: | 154 protected: |
| 155 FX_LPCBYTE» » m_Ptr; | 155 const uint8_t*» » m_Ptr; |
| 156 FX_STRSIZE m_Length; | 156 FX_STRSIZE m_Length; |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 void* operator new (size_t) throw() | 159 void* operator new (size_t) throw() |
| 160 { | 160 { |
| 161 return NULL; | 161 return NULL; |
| 162 } | 162 } |
| 163 }; | 163 }; |
| 164 inline bool operator== (const char* lhs, const CFX_ByteStringC& rhs) { | 164 inline bool operator== (const char* lhs, const CFX_ByteStringC& rhs) { |
| 165 return rhs == lhs; | 165 return rhs == lhs; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 183 // Copy constructor. | 183 // Copy constructor. |
| 184 CFX_ByteString(const CFX_ByteString& str); | 184 CFX_ByteString(const CFX_ByteString& str); |
| 185 | 185 |
| 186 // Move constructor. | 186 // Move constructor. |
| 187 inline CFX_ByteString(CFX_ByteString&& other) { | 187 inline CFX_ByteString(CFX_ByteString&& other) { |
| 188 this->m_pData = other.m_pData; | 188 this->m_pData = other.m_pData; |
| 189 other.m_pData = nullptr; | 189 other.m_pData = nullptr; |
| 190 } | 190 } |
| 191 | 191 |
| 192 CFX_ByteString(char ch); | 192 CFX_ByteString(char ch); |
| 193 CFX_ByteString(FX_LPCSTR ptr) | 193 CFX_ByteString(const FX_CHAR* ptr) |
| 194 : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) { } | 194 : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) { } |
| 195 | 195 |
| 196 CFX_ByteString(FX_LPCSTR ptr, FX_STRSIZE len); | 196 CFX_ByteString(const FX_CHAR* ptr, FX_STRSIZE len); |
| 197 CFX_ByteString(FX_LPCBYTE ptr, FX_STRSIZE len); | 197 CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len); |
| 198 | 198 |
| 199 CFX_ByteString(FX_BSTR bstrc); | 199 CFX_ByteString(FX_BSTR bstrc); |
| 200 CFX_ByteString(FX_BSTR bstrc1, FX_BSTR bstrc2); | 200 CFX_ByteString(FX_BSTR bstrc1, FX_BSTR bstrc2); |
| 201 | 201 |
| 202 ~CFX_ByteString(); | 202 ~CFX_ByteString(); |
| 203 | 203 |
| 204 static CFX_ByteString» FromUnicode(FX_LPCWSTR ptr, FX_STRSIZE len = -1)
; | 204 static CFX_ByteString» FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len
= -1); |
| 205 | 205 |
| 206 static CFX_ByteString FromUnicode(const CFX_WideString& str); | 206 static CFX_ByteString FromUnicode(const CFX_WideString& str); |
| 207 | 207 |
| 208 // Explicit conversion to raw string | 208 // Explicit conversion to raw string |
| 209 FX_LPCSTR c_str() const | 209 const FX_CHAR* c_str() const |
| 210 { | 210 { |
| 211 return m_pData ? m_pData->m_String : ""; | 211 return m_pData ? m_pData->m_String : ""; |
| 212 } | 212 } |
| 213 | 213 |
| 214 // Implicit conversion to C-style string -- deprecated | 214 // Implicit conversion to C-style string -- deprecated |
| 215 operator» » » » FX_LPCSTR() const | 215 operator» » » » const FX_CHAR*() const |
| 216 { | 216 { |
| 217 return m_pData ? m_pData->m_String : ""; | 217 return m_pData ? m_pData->m_String : ""; |
| 218 } | 218 } |
| 219 | 219 |
| 220 operator» » » » FX_LPCBYTE() const | 220 operator» » » » const uint8_t*() const |
| 221 { | 221 { |
| 222 return m_pData ? (FX_LPCBYTE)m_pData->m_String : NULL; | 222 return m_pData ? (const uint8_t*)m_pData->m_String : NULL; |
| 223 } | 223 } |
| 224 | 224 |
| 225 FX_STRSIZE GetLength() const | 225 FX_STRSIZE GetLength() const |
| 226 { | 226 { |
| 227 return m_pData ? m_pData->m_nDataLength : 0; | 227 return m_pData ? m_pData->m_nDataLength : 0; |
| 228 } | 228 } |
| 229 | 229 |
| 230 bool IsEmpty() const | 230 bool IsEmpty() const |
| 231 { | 231 { |
| 232 return !GetLength(); | 232 return !GetLength(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool operator< (const CFX_ByteString& str) const | 256 bool operator< (const CFX_ByteString& str) const |
| 257 { | 257 { |
| 258 int result = FXSYS_memcmp32(c_str(), str.c_str(), std::min(GetLength(),
str.GetLength())); | 258 int result = FXSYS_memcmp32(c_str(), str.c_str(), std::min(GetLength(),
str.GetLength())); |
| 259 return result < 0 || (result == 0 && GetLength() < str.GetLength()); | 259 return result < 0 || (result == 0 && GetLength() < str.GetLength()); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void Empty(); | 262 void Empty(); |
| 263 | 263 |
| 264 const CFX_ByteString&» operator = (FX_LPCSTR str); | 264 const CFX_ByteString&» operator = (const FX_CHAR* str); |
| 265 | 265 |
| 266 const CFX_ByteString& operator = (FX_BSTR bstrc); | 266 const CFX_ByteString& operator = (FX_BSTR bstrc); |
| 267 | 267 |
| 268 const CFX_ByteString& operator = (const CFX_ByteString& stringSrc); | 268 const CFX_ByteString& operator = (const CFX_ByteString& stringSrc); |
| 269 | 269 |
| 270 const CFX_ByteString& operator = (const CFX_BinaryBuf& buf); | 270 const CFX_ByteString& operator = (const CFX_BinaryBuf& buf); |
| 271 | 271 |
| 272 void» » » » » Load(FX_LPCBYTE str, FX_STRSIZE
len); | 272 void» » » » » Load(const uint8_t* str, FX_STRS
IZE len); |
| 273 | 273 |
| 274 const CFX_ByteString& operator += (FX_CHAR ch); | 274 const CFX_ByteString& operator += (FX_CHAR ch); |
| 275 | 275 |
| 276 const CFX_ByteString&» operator += (FX_LPCSTR str); | 276 const CFX_ByteString&» operator += (const FX_CHAR* str); |
| 277 | 277 |
| 278 const CFX_ByteString& operator += (const CFX_ByteString& str); | 278 const CFX_ByteString& operator += (const CFX_ByteString& str); |
| 279 | 279 |
| 280 const CFX_ByteString& operator += (FX_BSTR bstrc); | 280 const CFX_ByteString& operator += (FX_BSTR bstrc); |
| 281 | 281 |
| 282 uint8_t GetAt(FX_STRSIZE nIndex) const | 282 uint8_t GetAt(FX_STRSIZE nIndex) const |
| 283 { | 283 { |
| 284 return m_pData ? m_pData->m_String[nIndex] : 0; | 284 return m_pData ? m_pData->m_String[nIndex] : 0; |
| 285 } | 285 } |
| 286 | 286 |
| 287 uint8_t operator[](FX_STRSIZE nIndex) co
nst | 287 uint8_t operator[](FX_STRSIZE nIndex) co
nst |
| 288 { | 288 { |
| 289 return m_pData ? m_pData->m_String[nIndex] : 0; | 289 return m_pData ? m_pData->m_String[nIndex] : 0; |
| 290 } | 290 } |
| 291 | 291 |
| 292 void SetAt(FX_STRSIZE nIndex, FX_CHAR
ch); | 292 void SetAt(FX_STRSIZE nIndex, FX_CHAR
ch); |
| 293 | 293 |
| 294 FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch); | 294 FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch); |
| 295 | 295 |
| 296 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE coun
t = 1); | 296 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE coun
t = 1); |
| 297 | 297 |
| 298 | 298 |
| 299 void» » » » » Format(FX_LPCSTR lpszFormat, ...
); | 299 void» » » » » Format(const FX_CHAR* lpszFormat
, ... ); |
| 300 | 300 |
| 301 void» » » » » FormatV(FX_LPCSTR lpszFormat, va
_list argList); | 301 void» » » » » FormatV(const FX_CHAR* lpszForma
t, va_list argList); |
| 302 | 302 |
| 303 | 303 |
| 304 void Reserve(FX_STRSIZE len); | 304 void Reserve(FX_STRSIZE len); |
| 305 | 305 |
| 306 FX_LPSTR» » » » GetBuffer(FX_STRSIZE len); | 306 FX_CHAR*» » » » GetBuffer(FX_STRSIZE len); |
| 307 | 307 |
| 308 void ReleaseBuffer(FX_STRSIZE len = -
1); | 308 void ReleaseBuffer(FX_STRSIZE len = -
1); |
| 309 | 309 |
| 310 CFX_ByteString Mid(FX_STRSIZE first) const; | 310 CFX_ByteString Mid(FX_STRSIZE first) const; |
| 311 | 311 |
| 312 CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count)
const; | 312 CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count)
const; |
| 313 | 313 |
| 314 CFX_ByteString Left(FX_STRSIZE count) const; | 314 CFX_ByteString Left(FX_STRSIZE count) const; |
| 315 | 315 |
| 316 CFX_ByteString Right(FX_STRSIZE count) const; | 316 CFX_ByteString Right(FX_STRSIZE count) const; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) { | 377 : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) { |
| 378 FXSYS_assert(dataLen >= 0); | 378 FXSYS_assert(dataLen >= 0); |
| 379 FXSYS_assert(allocLen >= 0); | 379 FXSYS_assert(allocLen >= 0); |
| 380 FXSYS_assert(dataLen <= allocLen); | 380 FXSYS_assert(dataLen <= allocLen); |
| 381 m_String[dataLen] = 0; | 381 m_String[dataLen] = 0; |
| 382 } | 382 } |
| 383 ~StringData() = delete; | 383 ~StringData() = delete; |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 void AllocCopy(CFX_ByteString& dest,
FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const; | 386 void AllocCopy(CFX_ByteString& dest,
FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const; |
| 387 void» » » » » AssignCopy(FX_STRSIZE nSrcLen, F
X_LPCSTR lpszSrcData); | 387 void» » » » » AssignCopy(FX_STRSIZE nSrcLen, c
onst FX_CHAR* lpszSrcData); |
| 388 void» » » » » ConcatCopy(FX_STRSIZE nSrc1Len,
FX_LPCSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCSTR lpszSrc2Data); | 388 void» » » » » ConcatCopy(FX_STRSIZE nSrc1Len,
const FX_CHAR* lpszSrc1Data, FX_STRSIZE nSrc2Len, const FX_CHAR* lpszSrc2Data); |
| 389 void» » » » » ConcatInPlace(FX_STRSIZE nSrcLen
, FX_LPCSTR lpszSrcData); | 389 void» » » » » ConcatInPlace(FX_STRSIZE nSrcLen
, const FX_CHAR* lpszSrcData); |
| 390 void CopyBeforeWrite(); | 390 void CopyBeforeWrite(); |
| 391 void AllocBeforeWrite(FX_STRSIZE nLen
); | 391 void AllocBeforeWrite(FX_STRSIZE nLen
); |
| 392 | 392 |
| 393 StringData* m_pData; | 393 StringData* m_pData; |
| 394 friend class fxcrt_ByteStringConcatInPlace_Test; | 394 friend class fxcrt_ByteStringConcatInPlace_Test; |
| 395 }; | 395 }; |
| 396 inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src) | 396 inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src) |
| 397 { | 397 { |
| 398 m_Ptr = (FX_LPCBYTE)src; | 398 m_Ptr = (const uint8_t*)src; |
| 399 m_Length = src.GetLength(); | 399 m_Length = src.GetLength(); |
| 400 } | 400 } |
| 401 inline CFX_ByteStringC& CFX_ByteStringC::operator = (const CFX_ByteString& src) | 401 inline CFX_ByteStringC& CFX_ByteStringC::operator = (const CFX_ByteString& src) |
| 402 { | 402 { |
| 403 m_Ptr = (FX_LPCBYTE)src; | 403 m_Ptr = (const uint8_t*)src; |
| 404 m_Length = src.GetLength(); | 404 m_Length = src.GetLength(); |
| 405 return *this; | 405 return *this; |
| 406 } | 406 } |
| 407 | 407 |
| 408 inline bool operator== (const char* lhs, const CFX_ByteString& rhs) { | 408 inline bool operator== (const char* lhs, const CFX_ByteString& rhs) { |
| 409 return rhs == lhs; | 409 return rhs == lhs; |
| 410 } | 410 } |
| 411 inline bool operator== (const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) { | 411 inline bool operator== (const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) { |
| 412 return rhs == lhs; | 412 return rhs == lhs; |
| 413 } | 413 } |
| 414 inline bool operator!= (const char* lhs, const CFX_ByteString& rhs) { | 414 inline bool operator!= (const char* lhs, const CFX_ByteString& rhs) { |
| 415 return rhs != lhs; | 415 return rhs != lhs; |
| 416 } | 416 } |
| 417 inline bool operator!= (const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) { | 417 inline bool operator!= (const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) { |
| 418 return rhs != lhs; | 418 return rhs != lhs; |
| 419 } | 419 } |
| 420 | 420 |
| 421 inline CFX_ByteString operator + (FX_BSTR str1, FX_BSTR str2) | 421 inline CFX_ByteString operator + (FX_BSTR str1, FX_BSTR str2) |
| 422 { | 422 { |
| 423 return CFX_ByteString(str1, str2); | 423 return CFX_ByteString(str1, str2); |
| 424 } | 424 } |
| 425 inline CFX_ByteString operator + (FX_BSTR str1, FX_LPCSTR str2) | 425 inline CFX_ByteString operator + (FX_BSTR str1, const FX_CHAR* str2) |
| 426 { | 426 { |
| 427 return CFX_ByteString(str1, str2); | 427 return CFX_ByteString(str1, str2); |
| 428 } | 428 } |
| 429 inline CFX_ByteString operator + (FX_LPCSTR str1, FX_BSTR str2) | 429 inline CFX_ByteString operator + (const FX_CHAR* str1, FX_BSTR str2) |
| 430 { | 430 { |
| 431 return CFX_ByteString(str1, str2); | 431 return CFX_ByteString(str1, str2); |
| 432 } | 432 } |
| 433 inline CFX_ByteString operator + (FX_BSTR str1, FX_CHAR ch) | 433 inline CFX_ByteString operator + (FX_BSTR str1, FX_CHAR ch) |
| 434 { | 434 { |
| 435 return CFX_ByteString(str1, CFX_ByteStringC(ch)); | 435 return CFX_ByteString(str1, CFX_ByteStringC(ch)); |
| 436 } | 436 } |
| 437 inline CFX_ByteString operator + (FX_CHAR ch, FX_BSTR str2) | 437 inline CFX_ByteString operator + (FX_CHAR ch, FX_BSTR str2) |
| 438 { | 438 { |
| 439 return CFX_ByteString(ch, str2); | 439 return CFX_ByteString(ch, str2); |
| 440 } | 440 } |
| 441 inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteStri
ng& str2) | 441 inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteStri
ng& str2) |
| 442 { | 442 { |
| 443 return CFX_ByteString(str1, str2); | 443 return CFX_ByteString(str1, str2); |
| 444 } | 444 } |
| 445 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch) | 445 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch) |
| 446 { | 446 { |
| 447 return CFX_ByteString(str1, CFX_ByteStringC(ch)); | 447 return CFX_ByteString(str1, CFX_ByteStringC(ch)); |
| 448 } | 448 } |
| 449 inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2) | 449 inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2) |
| 450 { | 450 { |
| 451 return CFX_ByteString(ch, str2); | 451 return CFX_ByteString(ch, str2); |
| 452 } | 452 } |
| 453 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_LPCSTR str2) | 453 inline CFX_ByteString operator + (const CFX_ByteString& str1, const FX_CHAR* str
2) |
| 454 { | 454 { |
| 455 return CFX_ByteString(str1, str2); | 455 return CFX_ByteString(str1, str2); |
| 456 } | 456 } |
| 457 inline CFX_ByteString operator + (FX_LPCSTR str1, const CFX_ByteString& str2) | 457 inline CFX_ByteString operator + (const FX_CHAR* str1, const CFX_ByteString& str
2) |
| 458 { | 458 { |
| 459 return CFX_ByteString(str1, str2); | 459 return CFX_ByteString(str1, str2); |
| 460 } | 460 } |
| 461 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2) | 461 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2) |
| 462 { | 462 { |
| 463 return CFX_ByteString(str1, str2); | 463 return CFX_ByteString(str1, str2); |
| 464 } | 464 } |
| 465 inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2) | 465 inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2) |
| 466 { | 466 { |
| 467 return CFX_ByteString(str1, str2); | 467 return CFX_ByteString(str1, str2); |
| 468 } | 468 } |
| 469 class CFX_WideStringC | 469 class CFX_WideStringC |
| 470 { | 470 { |
| 471 public: | 471 public: |
| 472 typedef FX_WCHAR value_type; | 472 typedef FX_WCHAR value_type; |
| 473 | 473 |
| 474 CFX_WideStringC() | 474 CFX_WideStringC() |
| 475 { | 475 { |
| 476 m_Ptr = NULL; | 476 m_Ptr = NULL; |
| 477 m_Length = 0; | 477 m_Length = 0; |
| 478 } | 478 } |
| 479 | 479 |
| 480 CFX_WideStringC(FX_LPCWSTR ptr) | 480 CFX_WideStringC(const FX_WCHAR* ptr) |
| 481 { | 481 { |
| 482 m_Ptr = ptr; | 482 m_Ptr = ptr; |
| 483 m_Length = ptr ? FXSYS_wcslen(ptr) : 0; | 483 m_Length = ptr ? FXSYS_wcslen(ptr) : 0; |
| 484 } | 484 } |
| 485 | 485 |
| 486 CFX_WideStringC(FX_WCHAR& ch) | 486 CFX_WideStringC(FX_WCHAR& ch) |
| 487 { | 487 { |
| 488 m_Ptr = &ch; | 488 m_Ptr = &ch; |
| 489 m_Length = 1; | 489 m_Length = 1; |
| 490 } | 490 } |
| 491 | 491 |
| 492 CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len) | 492 CFX_WideStringC(const FX_WCHAR* ptr, FX_STRSIZE len) |
| 493 { | 493 { |
| 494 m_Ptr = ptr; | 494 m_Ptr = ptr; |
| 495 m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len; | 495 m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len; |
| 496 } | 496 } |
| 497 | 497 |
| 498 CFX_WideStringC(const CFX_WideStringC& src) | 498 CFX_WideStringC(const CFX_WideStringC& src) |
| 499 { | 499 { |
| 500 m_Ptr = src.m_Ptr; | 500 m_Ptr = src.m_Ptr; |
| 501 m_Length = src.m_Length; | 501 m_Length = src.m_Length; |
| 502 } | 502 } |
| 503 | 503 |
| 504 CFX_WideStringC(const CFX_WideString& src); | 504 CFX_WideStringC(const CFX_WideString& src); |
| 505 | 505 |
| 506 CFX_WideStringC& operator = (FX_LPCWSTR src) | 506 CFX_WideStringC& operator = (const FX_WCHAR* src) |
| 507 { | 507 { |
| 508 m_Ptr = src; | 508 m_Ptr = src; |
| 509 m_Length = FXSYS_wcslen(src); | 509 m_Length = FXSYS_wcslen(src); |
| 510 return *this; | 510 return *this; |
| 511 } | 511 } |
| 512 | 512 |
| 513 CFX_WideStringC& operator = (const CFX_WideStringC& src) | 513 CFX_WideStringC& operator = (const CFX_WideStringC& src) |
| 514 { | 514 { |
| 515 m_Ptr = src.m_Ptr; | 515 m_Ptr = src.m_Ptr; |
| 516 m_Length = src.m_Length; | 516 m_Length = src.m_Length; |
| 517 return *this; | 517 return *this; |
| 518 } | 518 } |
| 519 | 519 |
| 520 CFX_WideStringC& operator = (const CFX_WideString& src); | 520 CFX_WideStringC& operator = (const CFX_WideString& src); |
| 521 | 521 |
| 522 bool operator== (const wchar_t* ptr) const { | 522 bool operator== (const wchar_t* ptr) const { |
| 523 return FXSYS_wcslen(ptr) == m_Length && | 523 return FXSYS_wcslen(ptr) == m_Length && |
| 524 wmemcmp(ptr, m_Ptr, m_Length) == 0; | 524 wmemcmp(ptr, m_Ptr, m_Length) == 0; |
| 525 } | 525 } |
| 526 bool operator== (const CFX_WideStringC& str) const { | 526 bool operator== (const CFX_WideStringC& str) const { |
| 527 return str.m_Length == m_Length && | 527 return str.m_Length == m_Length && |
| 528 wmemcmp(str.m_Ptr, m_Ptr, m_Length) == 0; | 528 wmemcmp(str.m_Ptr, m_Ptr, m_Length) == 0; |
| 529 } | 529 } |
| 530 bool operator!= (const wchar_t* ptr) const { return !(*this == ptr); } | 530 bool operator!= (const wchar_t* ptr) const { return !(*this == ptr); } |
| 531 bool operator!= (const CFX_WideStringC& str) const { | 531 bool operator!= (const CFX_WideStringC& str) const { |
| 532 return !(*this == str); | 532 return !(*this == str); |
| 533 } | 533 } |
| 534 | 534 |
| 535 FX_LPCWSTR» » GetPtr() const | 535 const FX_WCHAR*» » GetPtr() const |
| 536 { | 536 { |
| 537 return m_Ptr; | 537 return m_Ptr; |
| 538 } | 538 } |
| 539 | 539 |
| 540 FX_STRSIZE GetLength() const | 540 FX_STRSIZE GetLength() const |
| 541 { | 541 { |
| 542 return m_Length; | 542 return m_Length; |
| 543 } | 543 } |
| 544 | 544 |
| 545 bool IsEmpty() const | 545 bool IsEmpty() const |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 return m_Ptr[index]; | 593 return m_Ptr[index]; |
| 594 } | 594 } |
| 595 | 595 |
| 596 bool operator< (const CFX_WideStringC& that) const | 596 bool operator< (const CFX_WideStringC& that) const |
| 597 { | 597 { |
| 598 int result = wmemcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length
)); | 598 int result = wmemcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length
)); |
| 599 return result < 0 || (result == 0 && m_Length < that.m_Length); | 599 return result < 0 || (result == 0 && m_Length < that.m_Length); |
| 600 } | 600 } |
| 601 | 601 |
| 602 protected: | 602 protected: |
| 603 FX_LPCWSTR» » m_Ptr; | 603 const FX_WCHAR*» » m_Ptr; |
| 604 FX_STRSIZE m_Length; | 604 FX_STRSIZE m_Length; |
| 605 | 605 |
| 606 private: | 606 private: |
| 607 void* operator new (size_t) throw() | 607 void* operator new (size_t) throw() |
| 608 { | 608 { |
| 609 return NULL; | 609 return NULL; |
| 610 } | 610 } |
| 611 }; | 611 }; |
| 612 inline bool operator== (const wchar_t* lhs, const CFX_WideStringC& rhs) { | 612 inline bool operator== (const wchar_t* lhs, const CFX_WideStringC& rhs) { |
| 613 return rhs == lhs; | 613 return rhs == lhs; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 629 | 629 |
| 630 // Copy constructor. | 630 // Copy constructor. |
| 631 CFX_WideString(const CFX_WideString& str); | 631 CFX_WideString(const CFX_WideString& str); |
| 632 | 632 |
| 633 // Move constructor. | 633 // Move constructor. |
| 634 inline CFX_WideString(CFX_WideString&& other) { | 634 inline CFX_WideString(CFX_WideString&& other) { |
| 635 this->m_pData = other.m_pData; | 635 this->m_pData = other.m_pData; |
| 636 other.m_pData = nullptr; | 636 other.m_pData = nullptr; |
| 637 } | 637 } |
| 638 | 638 |
| 639 CFX_WideString(FX_LPCWSTR ptr) | 639 CFX_WideString(const FX_WCHAR* ptr) |
| 640 : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) { } | 640 : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) { } |
| 641 | 641 |
| 642 CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len); | 642 CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len); |
| 643 | 643 |
| 644 CFX_WideString(FX_WCHAR ch); | 644 CFX_WideString(FX_WCHAR ch); |
| 645 | 645 |
| 646 CFX_WideString(const CFX_WideStringC& str); | 646 CFX_WideString(const CFX_WideStringC& str); |
| 647 | 647 |
| 648 CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2); | 648 CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2); |
| 649 | 649 |
| 650 ~CFX_WideString(); | 650 ~CFX_WideString(); |
| 651 | 651 |
| 652 static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1); | 652 static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1); |
| 653 | 653 |
| 654 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len); | 654 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len); |
| 655 | 655 |
| 656 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZ
E len); | 656 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZ
E len); |
| 657 | 657 |
| 658 static FX_STRSIZE WStringLength(const unsigned short* str); | 658 static FX_STRSIZE WStringLength(const unsigned short* str); |
| 659 | 659 |
| 660 // Explicit conversion to raw string | 660 // Explicit conversion to raw string |
| 661 FX_LPCWSTR c_str() const | 661 const FX_WCHAR* c_str() const |
| 662 { | 662 { |
| 663 return m_pData ? m_pData->m_String : L""; | 663 return m_pData ? m_pData->m_String : L""; |
| 664 } | 664 } |
| 665 | 665 |
| 666 // Implicit conversion to C-style wide string -- deprecated | 666 // Implicit conversion to C-style wide string -- deprecated |
| 667 operator FX_LPCWSTR() const | 667 operator const FX_WCHAR*() const |
| 668 { | 668 { |
| 669 return m_pData ? m_pData->m_String : L""; | 669 return m_pData ? m_pData->m_String : L""; |
| 670 } | 670 } |
| 671 | 671 |
| 672 void Empty(); | 672 void Empty(); |
| 673 | 673 |
| 674 | 674 |
| 675 FX_BOOL IsEmpty() const | 675 FX_BOOL IsEmpty() const |
| 676 { | 676 { |
| 677 return !GetLength(); | 677 return !GetLength(); |
| 678 } | 678 } |
| 679 | 679 |
| 680 FX_STRSIZE GetLength() const | 680 FX_STRSIZE GetLength() const |
| 681 { | 681 { |
| 682 return m_pData ? m_pData->m_nDataLength : 0; | 682 return m_pData ? m_pData->m_nDataLength : 0; |
| 683 } | 683 } |
| 684 | 684 |
| 685 const CFX_WideString&» operator = (FX_LPCWSTR str); | 685 const CFX_WideString&» operator = (const FX_WCHAR* str); |
| 686 | 686 |
| 687 const CFX_WideString& operator =(const CFX_WideString& stringSrc); | 687 const CFX_WideString& operator =(const CFX_WideString& stringSrc); |
| 688 | 688 |
| 689 const CFX_WideString& operator =(const CFX_WideStringC& stringSrc); | 689 const CFX_WideString& operator =(const CFX_WideStringC& stringSrc); |
| 690 | 690 |
| 691 const CFX_WideString&» operator += (FX_LPCWSTR str); | 691 const CFX_WideString&» operator += (const FX_WCHAR* str); |
| 692 | 692 |
| 693 const CFX_WideString& operator += (FX_WCHAR ch); | 693 const CFX_WideString& operator += (FX_WCHAR ch); |
| 694 | 694 |
| 695 const CFX_WideString& operator += (const CFX_WideString& str); | 695 const CFX_WideString& operator += (const CFX_WideString& str); |
| 696 | 696 |
| 697 const CFX_WideString& operator += (const CFX_WideStringC& str); | 697 const CFX_WideString& operator += (const CFX_WideStringC& str); |
| 698 | 698 |
| 699 bool operator== (const wchar_t* ptr) const { return Equal(ptr); } | 699 bool operator== (const wchar_t* ptr) const { return Equal(ptr); } |
| 700 bool operator== (const CFX_WideStringC& str) const { return Equal(str); } | 700 bool operator== (const CFX_WideStringC& str) const { return Equal(str); } |
| 701 bool operator== (const CFX_WideString& other) const { return Equal(other); } | 701 bool operator== (const CFX_WideString& other) const { return Equal(other); } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 718 return m_pData ? m_pData->m_String[nIndex] : 0; | 718 return m_pData ? m_pData->m_String[nIndex] : 0; |
| 719 } | 719 } |
| 720 | 720 |
| 721 FX_WCHAR operator[](FX_STRSIZE nIndex) const | 721 FX_WCHAR operator[](FX_STRSIZE nIndex) const |
| 722 { | 722 { |
| 723 return m_pData ? m_pData->m_String[nIndex] : 0; | 723 return m_pData ? m_pData->m_String[nIndex] : 0; |
| 724 } | 724 } |
| 725 | 725 |
| 726 void SetAt(FX_STRSIZE nIndex, FX_WCHA
R ch); | 726 void SetAt(FX_STRSIZE nIndex, FX_WCHA
R ch); |
| 727 | 727 |
| 728 int»» » » » » Compare(FX_LPCWSTR str) const; | 728 int»» » » » » Compare(const FX_WCHAR* str) con
st; |
| 729 | 729 |
| 730 int Compare(const CFX_WideString& st
r) const; | 730 int Compare(const CFX_WideString& st
r) const; |
| 731 | 731 |
| 732 int»» » » » » CompareNoCase(FX_LPCWSTR str) co
nst; | 732 int»» » » » » CompareNoCase(const FX_WCHAR* st
r) const; |
| 733 | 733 |
| 734 bool Equal(const wchar_t* ptr) const; | 734 bool Equal(const wchar_t* ptr) const; |
| 735 bool Equal(const CFX_WideStringC& str) const; | 735 bool Equal(const CFX_WideStringC& str) const; |
| 736 bool Equal(const CFX_WideString& other) const; | 736 bool Equal(const CFX_WideString& other) const; |
| 737 | 737 |
| 738 CFX_WideString Mid(FX_STRSIZE first) const; | 738 CFX_WideString Mid(FX_STRSIZE first) const; |
| 739 | 739 |
| 740 CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count)
const; | 740 CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count)
const; |
| 741 | 741 |
| 742 CFX_WideString Left(FX_STRSIZE count) const; | 742 CFX_WideString Left(FX_STRSIZE count) const; |
| 743 | 743 |
| 744 CFX_WideString Right(FX_STRSIZE count) const; | 744 CFX_WideString Right(FX_STRSIZE count) const; |
| 745 | 745 |
| 746 FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch); | 746 FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch); |
| 747 | 747 |
| 748 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE coun
t = 1); | 748 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE coun
t = 1); |
| 749 | 749 |
| 750 void» » » » » Format(FX_LPCWSTR lpszFormat, ..
. ); | 750 void» » » » » Format(const FX_WCHAR* lpszForma
t, ... ); |
| 751 | 751 |
| 752 void» » » » » FormatV(FX_LPCWSTR lpszFormat, v
a_list argList); | 752 void» » » » » FormatV(const FX_WCHAR* lpszForm
at, va_list argList); |
| 753 | 753 |
| 754 void MakeLower(); | 754 void MakeLower(); |
| 755 | 755 |
| 756 void MakeUpper(); | 756 void MakeUpper(); |
| 757 | 757 |
| 758 void TrimRight(); | 758 void TrimRight(); |
| 759 | 759 |
| 760 void TrimRight(FX_WCHAR chTarget); | 760 void TrimRight(FX_WCHAR chTarget); |
| 761 | 761 |
| 762 void» » » » » TrimRight(FX_LPCWSTR lpszTargets
); | 762 void» » » » » TrimRight(const FX_WCHAR* lpszTa
rgets); |
| 763 | 763 |
| 764 void TrimLeft(); | 764 void TrimLeft(); |
| 765 | 765 |
| 766 void TrimLeft(FX_WCHAR chTarget); | 766 void TrimLeft(FX_WCHAR chTarget); |
| 767 | 767 |
| 768 void» » » » » TrimLeft(FX_LPCWSTR lpszTargets)
; | 768 void» » » » » TrimLeft(const FX_WCHAR* lpszTar
gets); |
| 769 | 769 |
| 770 void Reserve(FX_STRSIZE len); | 770 void Reserve(FX_STRSIZE len); |
| 771 | 771 |
| 772 FX_LPWSTR» » » » GetBuffer(FX_STRSIZE len); | 772 FX_WCHAR*» » » » GetBuffer(FX_STRSIZE len); |
| 773 | 773 |
| 774 void ReleaseBuffer(FX_STRSIZE len = -
1); | 774 void ReleaseBuffer(FX_STRSIZE len = -
1); |
| 775 | 775 |
| 776 int GetInteger() const; | 776 int GetInteger() const; |
| 777 | 777 |
| 778 FX_FLOAT GetFloat() const; | 778 FX_FLOAT GetFloat() const; |
| 779 | 779 |
| 780 FX_STRSIZE» » » » Find(FX_LPCWSTR lpszSub, FX_STRSIZE star
t = 0) const; | 780 FX_STRSIZE» » » » Find(const FX_WCHAR* lpszSub, FX_STRSIZE
start = 0) const; |
| 781 | 781 |
| 782 FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0)
const; | 782 FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0)
const; |
| 783 | 783 |
| 784 FX_STRSIZE» » » » Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR l
pszNew); | 784 FX_STRSIZE» » » » Replace(const FX_WCHAR* lpszOld, const F
X_WCHAR* lpszNew); |
| 785 | 785 |
| 786 FX_STRSIZE Remove(FX_WCHAR ch); | 786 FX_STRSIZE Remove(FX_WCHAR ch); |
| 787 | 787 |
| 788 CFX_ByteString UTF8Encode() const; | 788 CFX_ByteString UTF8Encode() const; |
| 789 | 789 |
| 790 CFX_ByteString UTF16LE_Encode() const; | 790 CFX_ByteString UTF16LE_Encode() const; |
| 791 | 791 |
| 792 void ConvertFrom(const CFX_ByteString
& str, CFX_CharMap* pCharMap = NULL); | 792 void ConvertFrom(const CFX_ByteString
& str, CFX_CharMap* pCharMap = NULL); |
| 793 | 793 |
| 794 protected: | 794 protected: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 809 FXSYS_assert(dataLen >= 0); | 809 FXSYS_assert(dataLen >= 0); |
| 810 FXSYS_assert(allocLen >= 0); | 810 FXSYS_assert(allocLen >= 0); |
| 811 FXSYS_assert(dataLen <= allocLen); | 811 FXSYS_assert(dataLen <= allocLen); |
| 812 m_String[dataLen] = 0; | 812 m_String[dataLen] = 0; |
| 813 } | 813 } |
| 814 ~StringData() = delete; | 814 ~StringData() = delete; |
| 815 }; | 815 }; |
| 816 | 816 |
| 817 void CopyBeforeWrite(); | 817 void CopyBeforeWrite(); |
| 818 void AllocBeforeWrite(FX_STRSIZE nLen); | 818 void AllocBeforeWrite(FX_STRSIZE nLen); |
| 819 void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrc
Data); | 819 void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_WCHAR* lp
szSrcData); |
| 820 void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCWSTR lpszSrc1D
ata, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data); | 820 void ConcatCopy(FX_STRSIZE nSrc1Len, const FX_WCHAR* lpsz
Src1Data, FX_STRSIZE nSrc2Len, const FX_WCHAR* lpszSrc2Data); |
| 821 void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcDat
a); | 821 void AssignCopy(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszS
rcData); |
| 822 void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen,
FX_STRSIZE nCopyIndex) const; | 822 void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen,
FX_STRSIZE nCopyIndex) const; |
| 823 | 823 |
| 824 StringData* m_pData; | 824 StringData* m_pData; |
| 825 friend class fxcrt_WideStringConcatInPlace_Test; | 825 friend class fxcrt_WideStringConcatInPlace_Test; |
| 826 }; | 826 }; |
| 827 inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src) | 827 inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src) |
| 828 { | 828 { |
| 829 m_Ptr = src.c_str(); | 829 m_Ptr = src.c_str(); |
| 830 m_Length = src.GetLength(); | 830 m_Length = src.GetLength(); |
| 831 } | 831 } |
| 832 inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src) | 832 inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src) |
| 833 { | 833 { |
| 834 m_Ptr = src.c_str(); | 834 m_Ptr = src.c_str(); |
| 835 m_Length = src.GetLength(); | 835 m_Length = src.GetLength(); |
| 836 return *this; | 836 return *this; |
| 837 } | 837 } |
| 838 | 838 |
| 839 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStr
ingC& str2) | 839 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStr
ingC& str2) |
| 840 { | 840 { |
| 841 return CFX_WideString(str1, str2); | 841 return CFX_WideString(str1, str2); |
| 842 } | 842 } |
| 843 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_LPCWSTR str2) | 843 inline CFX_WideString operator + (const CFX_WideStringC& str1, const FX_WCHAR* s
tr2) |
| 844 { | 844 { |
| 845 return CFX_WideString(str1, str2); | 845 return CFX_WideString(str1, str2); |
| 846 } | 846 } |
| 847 inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideStringC& str2) | 847 inline CFX_WideString operator + (const FX_WCHAR* str1, const CFX_WideStringC& s
tr2) |
| 848 { | 848 { |
| 849 return CFX_WideString(str1, str2); | 849 return CFX_WideString(str1, str2); |
| 850 } | 850 } |
| 851 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_WCHAR ch) | 851 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_WCHAR ch) |
| 852 { | 852 { |
| 853 return CFX_WideString(str1, CFX_WideStringC(ch)); | 853 return CFX_WideString(str1, CFX_WideStringC(ch)); |
| 854 } | 854 } |
| 855 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2) | 855 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2) |
| 856 { | 856 { |
| 857 return CFX_WideString(ch, str2); | 857 return CFX_WideString(ch, str2); |
| 858 } | 858 } |
| 859 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStri
ng& str2) | 859 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStri
ng& str2) |
| 860 { | 860 { |
| 861 return CFX_WideString(str1, str2); | 861 return CFX_WideString(str1, str2); |
| 862 } | 862 } |
| 863 inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch) | 863 inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch) |
| 864 { | 864 { |
| 865 return CFX_WideString(str1, CFX_WideStringC(ch)); | 865 return CFX_WideString(str1, CFX_WideStringC(ch)); |
| 866 } | 866 } |
| 867 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2) | 867 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2) |
| 868 { | 868 { |
| 869 return CFX_WideString(ch, str2); | 869 return CFX_WideString(ch, str2); |
| 870 } | 870 } |
| 871 inline CFX_WideString operator + (const CFX_WideString& str1, FX_LPCWSTR str2) | 871 inline CFX_WideString operator + (const CFX_WideString& str1, const FX_WCHAR* st
r2) |
| 872 { | 872 { |
| 873 return CFX_WideString(str1, str2); | 873 return CFX_WideString(str1, str2); |
| 874 } | 874 } |
| 875 inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideString& str2) | 875 inline CFX_WideString operator + (const FX_WCHAR* str1, const CFX_WideString& st
r2) |
| 876 { | 876 { |
| 877 return CFX_WideString(str1, str2); | 877 return CFX_WideString(str1, str2); |
| 878 } | 878 } |
| 879 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStri
ngC& str2) | 879 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStri
ngC& str2) |
| 880 { | 880 { |
| 881 return CFX_WideString(str1, str2); | 881 return CFX_WideString(str1, str2); |
| 882 } | 882 } |
| 883 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStr
ing& str2) | 883 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStr
ing& str2) |
| 884 { | 884 { |
| 885 return CFX_WideString(str1, str2); | 885 return CFX_WideString(str1, str2); |
| 886 } | 886 } |
| 887 inline bool operator== (const wchar_t* lhs, const CFX_WideString& rhs) { | 887 inline bool operator== (const wchar_t* lhs, const CFX_WideString& rhs) { |
| 888 return rhs == lhs; | 888 return rhs == lhs; |
| 889 } | 889 } |
| 890 inline bool operator== (const CFX_WideStringC& lhs, const CFX_WideString& rhs) { | 890 inline bool operator== (const CFX_WideStringC& lhs, const CFX_WideString& rhs) { |
| 891 return rhs == lhs; | 891 return rhs == lhs; |
| 892 } | 892 } |
| 893 inline bool operator!= (const wchar_t* lhs, const CFX_WideString& rhs) { | 893 inline bool operator!= (const wchar_t* lhs, const CFX_WideString& rhs) { |
| 894 return rhs != lhs; | 894 return rhs != lhs; |
| 895 } | 895 } |
| 896 inline bool operator!= (const CFX_WideStringC& lhs, const CFX_WideString& rhs) { | 896 inline bool operator!= (const CFX_WideStringC& lhs, const CFX_WideString& rhs) { |
| 897 return rhs != lhs; | 897 return rhs != lhs; |
| 898 } | 898 } |
| 899 FX_FLOAT FX_atof(FX_BSTR str); | 899 FX_FLOAT FX_atof(FX_BSTR str); |
| 900 void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData); | 900 void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData); |
| 901 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf); | 901 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); |
| 902 CFX_ByteString» FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len); | 902 CFX_ByteString» FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len); |
| 903 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) | 903 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) |
| 904 { | 904 { |
| 905 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()); | 905 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()); |
| 906 } | 906 } |
| 907 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) | 907 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) |
| 908 { | 908 { |
| 909 return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()); | 909 return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()); |
| 910 } | 910 } |
| 911 | 911 |
| 912 #endif // CORE_INCLUDE_FXCRT_FX_STRING_H_ | 912 #endif // CORE_INCLUDE_FXCRT_FX_STRING_H_ |
| OLD | NEW |