1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
|
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef _FX_STRING_H_
#define _FX_STRING_H_
#include <algorithm>
#include "fx_memory.h"
class CFX_ByteStringC;
class CFX_ByteString;
class CFX_WideStringC;
class CFX_WideString;
struct CFX_CharMap;
class CFX_BinaryBuf;
typedef int FX_STRSIZE;
class CFX_ByteStringL;
class CFX_WideStringL;
// An immutable string with caller-provided storage which must outlive the
// string itself.
class CFX_ByteStringC
{
public:
typedef FX_CHAR value_type;
CFX_ByteStringC()
{
m_Ptr = NULL;
m_Length = 0;
}
CFX_ByteStringC(FX_LPCBYTE ptr, FX_STRSIZE size)
{
m_Ptr = ptr;
m_Length = size;
}
CFX_ByteStringC(FX_LPCSTR ptr)
{
m_Ptr = (FX_LPCBYTE)ptr;
m_Length = ptr ? (FX_STRSIZE)FXSYS_strlen(ptr) : 0;
}
// |ch| must be an lvalue that outlives the the CFX_ByteStringC. However,
// the use of char rvalues are not caught at compile time. They are
// implicitly promoted to CFX_ByteString (see below) and then the
// CFX_ByteStringC is constructed from the CFX_ByteString via the alternate
// constructor below. The CFX_ByteString then typically goes out of scope
// and |m_Ptr| may be left pointing to invalid memory. Beware.
// TODO(tsepez): Mark single-argument string constructors as explicit.
CFX_ByteStringC(FX_CHAR& ch)
{
m_Ptr = (FX_LPCBYTE)&ch;
m_Length = 1;
}
CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len)
{
m_Ptr = (FX_LPCBYTE)ptr;
if (len == -1) {
m_Length = (FX_STRSIZE)FXSYS_strlen(ptr);
} else {
m_Length = len;
}
}
CFX_ByteStringC(const CFX_ByteStringC& src)
{
m_Ptr = src.m_Ptr;
m_Length = src.m_Length;
}
CFX_ByteStringC(const CFX_ByteString& src);
CFX_ByteStringC& operator = (FX_LPCSTR src)
{
m_Ptr = (FX_LPCBYTE)src;
m_Length = m_Ptr ? (FX_STRSIZE)FXSYS_strlen(src) : 0;
return *this;
}
CFX_ByteStringC& operator = (const CFX_ByteStringC& src)
{
m_Ptr = src.m_Ptr;
m_Length = src.m_Length;
return *this;
}
CFX_ByteStringC& operator = (const CFX_ByteString& src);
bool operator == (const CFX_ByteStringC& str) const
{
return str.m_Length == m_Length && FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) == 0;
}
bool operator != (const CFX_ByteStringC& str) const
{
return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) != 0;
}
FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
FX_LPCBYTE GetPtr() const
{
return m_Ptr;
}
FX_LPCSTR GetCStr() const
{
return (FX_LPCSTR)m_Ptr;
}
FX_STRSIZE GetLength() const
{
return m_Length;
}
bool IsEmpty() const
{
return m_Length == 0;
}
FX_BYTE GetAt(FX_STRSIZE index) const
{
return m_Ptr[index];
}
CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
{
if (index < 0) {
index = 0;
}
if (index > m_Length) {
return CFX_ByteStringC();
}
if (count < 0 || count > m_Length - index) {
count = m_Length - index;
}
return CFX_ByteStringC(m_Ptr + index, count);
}
const FX_BYTE& operator[] (size_t index) const
{
return m_Ptr[index];
}
bool operator< (const CFX_ByteStringC& that) const
{
int result = memcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
return result < 0 || (result == 0 && m_Length < that.m_Length);
}
protected:
FX_LPCBYTE m_Ptr;
FX_STRSIZE m_Length;
private:
void* operator new (size_t) throw()
{
return NULL;
}
};
typedef const CFX_ByteStringC& FX_BSTR;
#define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str-1)
#define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4))
struct CFX_StringData {
long m_nRefs;
FX_STRSIZE m_nDataLength;
FX_STRSIZE m_nAllocLength;
FX_CHAR m_String[1];
};
class CFX_ByteString
{
public:
typedef FX_CHAR value_type;
CFX_ByteString()
{
m_pData = NULL;
}
CFX_ByteString(const CFX_ByteString& str);
CFX_ByteString(char ch);
CFX_ByteString(FX_LPCSTR ptr, FX_STRSIZE len = -1);
CFX_ByteString(FX_LPCBYTE ptr, FX_STRSIZE len);
CFX_ByteString(FX_BSTR bstrc);
CFX_ByteString(FX_BSTR bstrc1, FX_BSTR bstrc2);
~CFX_ByteString();
static CFX_ByteString FromUnicode(FX_LPCWSTR ptr, FX_STRSIZE len = -1);
static CFX_ByteString FromUnicode(const CFX_WideString& str);
// Explicit conversion to raw string
FX_LPCSTR c_str() const
{
return m_pData ? m_pData->m_String : "";
}
// Implicit conversion to C-style string -- deprecated
operator FX_LPCSTR() const
{
return m_pData ? m_pData->m_String : "";
}
operator FX_LPCBYTE() const
{
return m_pData ? (FX_LPCBYTE)m_pData->m_String : NULL;
}
FX_STRSIZE GetLength() const
{
return m_pData ? m_pData->m_nDataLength : 0;
}
bool IsEmpty() const
{
return !GetLength();
}
int Compare(FX_BSTR str) const;
bool Equal(FX_BSTR str) const;
bool EqualNoCase(FX_BSTR str) const;
bool operator == (FX_LPCSTR str) const
{
return Equal(str);
}
bool operator == (FX_BSTR str) const
{
return Equal(str);
}
bool operator == (const CFX_ByteString& str) const;
bool operator != (FX_LPCSTR str) const
{
return !Equal(str);
}
bool operator != (FX_BSTR str) const
{
return !Equal(str);
}
bool operator != (const CFX_ByteString& str) const
{
return !operator==(str);
}
bool operator< (const CFX_ByteString& str) const
{
int result = FXSYS_memcmp32(c_str(), str.c_str(), std::min(GetLength(), str.GetLength()));
return result < 0 || (result == 0 && GetLength() < str.GetLength());
}
void Empty();
const CFX_ByteString& operator = (FX_LPCSTR str);
const CFX_ByteString& operator = (FX_BSTR bstrc);
const CFX_ByteString& operator = (const CFX_ByteString& stringSrc);
const CFX_ByteString& operator = (const CFX_BinaryBuf& buf);
void Load(FX_LPCBYTE str, FX_STRSIZE len);
const CFX_ByteString& operator += (FX_CHAR ch);
const CFX_ByteString& operator += (FX_LPCSTR str);
const CFX_ByteString& operator += (const CFX_ByteString& str);
const CFX_ByteString& operator += (FX_BSTR bstrc);
FX_BYTE GetAt(FX_STRSIZE nIndex) const
{
return m_pData ? m_pData->m_String[nIndex] : 0;
}
FX_BYTE operator[](FX_STRSIZE nIndex) const
{
return m_pData ? m_pData->m_String[nIndex] : 0;
}
void SetAt(FX_STRSIZE nIndex, FX_CHAR ch);
FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch);
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
void Format(FX_LPCSTR lpszFormat, ... );
void FormatV(FX_LPCSTR lpszFormat, va_list argList);
void Reserve(FX_STRSIZE len);
FX_LPSTR GetBuffer(FX_STRSIZE len);
FX_LPSTR LockBuffer();
void ReleaseBuffer(FX_STRSIZE len = -1);
CFX_ByteString Mid(FX_STRSIZE first) const;
CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
CFX_ByteString Left(FX_STRSIZE count) const;
CFX_ByteString Right(FX_STRSIZE count) const;
FX_STRSIZE Find(FX_BSTR lpszSub, FX_STRSIZE start = 0) const;
FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start = 0) const;
FX_STRSIZE ReverseFind(FX_CHAR ch) const;
void MakeLower();
void MakeUpper();
void TrimRight();
void TrimRight(FX_CHAR chTarget);
void TrimRight(FX_BSTR lpszTargets);
void TrimLeft();
void TrimLeft(FX_CHAR chTarget);
void TrimLeft(FX_BSTR lpszTargets);
FX_STRSIZE Replace(FX_BSTR lpszOld, FX_BSTR lpszNew);
FX_STRSIZE Remove(FX_CHAR ch);
CFX_WideString UTF8Decode() const;
void ConvertFrom(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL);
FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
#define FXFORMAT_SIGNED 1
#define FXFORMAT_HEX 2
#define FXFORMAT_CAPITAL 4
static CFX_ByteString FormatInteger(int i, FX_DWORD flags = 0);
static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
protected:
struct CFX_StringData* m_pData;
void AllocCopy(CFX_ByteString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const;
void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCSTR lpszSrc2Data);
void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
void CopyBeforeWrite();
void AllocBeforeWrite(FX_STRSIZE nLen);
};
inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src)
{
m_Ptr = (FX_LPCBYTE)src;
m_Length = src.GetLength();
}
inline CFX_ByteStringC& CFX_ByteStringC::operator = (const CFX_ByteString& src)
{
m_Ptr = (FX_LPCBYTE)src;
m_Length = src.GetLength();
return *this;
}
inline CFX_ByteString operator + (FX_BSTR str1, FX_BSTR str2)
{
return CFX_ByteString(str1, str2);
}
inline CFX_ByteString operator + (FX_BSTR str1, FX_LPCSTR str2)
{
return CFX_ByteString(str1, str2);
}
inline CFX_ByteString operator + (FX_LPCSTR str1, FX_BSTR str2)
{
return CFX_ByteString(str1, str2);
}
inline CFX_ByteString operator + (FX_BSTR str1, FX_CHAR ch)
{
return CFX_ByteString(str1, CFX_ByteStringC(ch));
}
inline CFX_ByteString operator + (FX_CHAR ch, FX_BSTR str2)
{
return CFX_ByteString(ch, str2);
}
inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteString& str2)
{
return CFX_ByteString(str1, str2);
}
inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch)
{
return CFX_ByteString(str1, CFX_ByteStringC(ch));
}
inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2)
{
return CFX_ByteString(ch, str2);
}
inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_LPCSTR str2)
{
return CFX_ByteString(str1, str2);
}
inline CFX_ByteString operator + (FX_LPCSTR str1, const CFX_ByteString& str2)
{
return CFX_ByteString(str1, str2);
}
inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2)
{
return CFX_ByteString(str1, str2);
}
inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2)
{
return CFX_ByteString(str1, str2);
}
class CFX_WideStringC
{
public:
typedef FX_WCHAR value_type;
CFX_WideStringC()
{
m_Ptr = NULL;
m_Length = 0;
}
CFX_WideStringC(FX_LPCWSTR ptr)
{
m_Ptr = ptr;
m_Length = ptr ? (FX_STRSIZE)FXSYS_wcslen(ptr) : 0;
}
CFX_WideStringC(FX_WCHAR& ch)
{
m_Ptr = &ch;
m_Length = 1;
}
CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
{
m_Ptr = ptr;
if (len == -1) {
m_Length = (FX_STRSIZE)FXSYS_wcslen(ptr);
} else {
m_Length = len;
}
}
CFX_WideStringC(const CFX_WideStringC& src)
{
m_Ptr = src.m_Ptr;
m_Length = src.m_Length;
}
CFX_WideStringC(const CFX_WideString& src);
CFX_WideStringC& operator = (FX_LPCWSTR src)
{
m_Ptr = src;
m_Length = (FX_STRSIZE)FXSYS_wcslen(src);
return *this;
}
CFX_WideStringC& operator = (const CFX_WideStringC& src)
{
m_Ptr = src.m_Ptr;
m_Length = src.m_Length;
return *this;
}
CFX_WideStringC& operator = (const CFX_WideString& src);
bool operator == (const CFX_WideStringC& str) const
{
return str.m_Length == m_Length && FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length * sizeof(FX_WCHAR)) == 0;
}
bool operator != (const CFX_WideStringC& str) const
{
return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length * sizeof(FX_WCHAR)) != 0;
}
FX_LPCWSTR GetPtr() const
{
return m_Ptr;
}
FX_STRSIZE GetLength() const
{
return m_Length;
}
bool IsEmpty() const
{
return m_Length == 0;
}
FX_WCHAR GetAt(FX_STRSIZE index) const
{
return m_Ptr[index];
}
CFX_WideStringC Left(FX_STRSIZE count) const
{
if (count < 1) {
return CFX_WideStringC();
}
if (count > m_Length) {
count = m_Length;
}
return CFX_WideStringC(m_Ptr, count);
}
CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
{
if (index < 0) {
index = 0;
}
if (index > m_Length) {
return CFX_WideStringC();
}
if (count < 0 || count > m_Length - index) {
count = m_Length - index;
}
return CFX_WideStringC(m_Ptr + index, count);
}
CFX_WideStringC Right(FX_STRSIZE count) const
{
if (count < 1) {
return CFX_WideStringC();
}
if (count > m_Length) {
count = m_Length;
}
return CFX_WideStringC(m_Ptr + m_Length - count, count);
}
const FX_WCHAR& operator[] (size_t index) const
{
return m_Ptr[index];
}
bool operator< (const CFX_WideStringC& that) const
{
int result = wmemcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
return result < 0 || (result == 0 && m_Length < that.m_Length);
}
protected:
FX_LPCWSTR m_Ptr;
FX_STRSIZE m_Length;
private:
void* operator new (size_t) throw()
{
return NULL;
}
};
typedef const CFX_WideStringC& FX_WSTR;
#define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1)
struct CFX_StringDataW {
long m_nRefs;
FX_STRSIZE m_nDataLength;
FX_STRSIZE m_nAllocLength;
FX_WCHAR m_String[1];
};
class CFX_WideString
{
public:
typedef FX_WCHAR value_type;
CFX_WideString()
{
m_pData = NULL;
}
CFX_WideString(const CFX_WideString& str);
CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len = -1)
{
InitStr(ptr, len);
}
CFX_WideString(FX_WCHAR ch);
CFX_WideString(const CFX_WideStringC& str);
CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
~CFX_WideString();
static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len);
static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len);
static FX_STRSIZE WStringLength(const unsigned short* str);
// Explicit conversion to raw string
FX_LPCWSTR c_str() const
{
return m_pData ? m_pData->m_String : L"";
}
void Empty();
FX_BOOL IsEmpty() const
{
return !GetLength();
}
FX_STRSIZE GetLength() const
{
return m_pData ? m_pData->m_nDataLength : 0;
}
const CFX_WideString& operator = (FX_LPCWSTR str);
const CFX_WideString& operator =(const CFX_WideString& stringSrc);
const CFX_WideString& operator =(const CFX_WideStringC& stringSrc);
const CFX_WideString& operator += (FX_LPCWSTR str);
const CFX_WideString& operator += (FX_WCHAR ch);
const CFX_WideString& operator += (const CFX_WideString& str);
const CFX_WideString& operator += (const CFX_WideStringC& str);
bool operator< (const CFX_WideString& str) const {
int result = wmemcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength()));
return result < 0 || (result == 0 && GetLength() < str.GetLength());
}
FX_WCHAR GetAt(FX_STRSIZE nIndex) const
{
return m_pData ? m_pData->m_String[nIndex] : 0;
}
FX_WCHAR operator[](FX_STRSIZE nIndex) const
{
return m_pData ? m_pData->m_String[nIndex] : 0;
}
void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
int Compare(FX_LPCWSTR str) const;
int Compare(const CFX_WideString& str) const;
int CompareNoCase(FX_LPCWSTR str) const;
bool Equal(const CFX_WideStringC& str) const;
CFX_WideString Mid(FX_STRSIZE first) const;
CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
CFX_WideString Left(FX_STRSIZE count) const;
CFX_WideString Right(FX_STRSIZE count) const;
FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
void Format(FX_LPCWSTR lpszFormat, ... );
void FormatV(FX_LPCWSTR lpszFormat, va_list argList);
void MakeLower();
void MakeUpper();
void TrimRight();
void TrimRight(FX_WCHAR chTarget);
void TrimRight(FX_LPCWSTR lpszTargets);
void TrimLeft();
void TrimLeft(FX_WCHAR chTarget);
void TrimLeft(FX_LPCWSTR lpszTargets);
void Reserve(FX_STRSIZE len);
FX_LPWSTR GetBuffer(FX_STRSIZE len);
FX_LPWSTR LockBuffer();
void ReleaseBuffer(FX_STRSIZE len = -1);
int GetInteger() const;
FX_FLOAT GetFloat() const;
FX_STRSIZE Find(FX_LPCWSTR lpszSub, FX_STRSIZE start = 0) const;
FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0) const;
FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew);
FX_STRSIZE Remove(FX_WCHAR ch);
CFX_ByteString UTF8Encode() const;
CFX_ByteString UTF16LE_Encode() const;
void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
protected:
void InitStr(FX_LPCWSTR ptr, int len);
CFX_StringDataW* m_pData;
void CopyBeforeWrite();
void AllocBeforeWrite(FX_STRSIZE nLen);
void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data);
void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const;
};
inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src)
{
m_Ptr = src.c_str();
m_Length = src.GetLength();
}
inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src)
{
m_Ptr = src.c_str();
m_Length = src.GetLength();
return *this;
}
inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStringC& str2)
{
return CFX_WideString(str1, str2);
}
inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_LPCWSTR str2)
{
return CFX_WideString(str1, str2);
}
inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideStringC& str2)
{
return CFX_WideString(str1, str2);
}
inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_WCHAR ch)
{
return CFX_WideString(str1, CFX_WideStringC(ch));
}
inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2)
{
return CFX_WideString(ch, str2);
}
inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideString& str2)
{
return CFX_WideString(str1, str2);
}
inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch)
{
return CFX_WideString(str1, CFX_WideStringC(ch));
}
inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2)
{
return CFX_WideString(ch, str2);
}
inline CFX_WideString operator + (const CFX_WideString& str1, FX_LPCWSTR str2)
{
return CFX_WideString(str1, str2);
}
inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideString& str2)
{
return CFX_WideString(str1, str2);
}
inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStringC& str2)
{
return CFX_WideString(str1, str2);
}
inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideString& str2)
{
return CFX_WideString(str1, str2);
}
bool operator==(const CFX_WideString& s1, const CFX_WideString& s2);
bool operator==(const CFX_WideString& s1, const CFX_WideStringC& s2);
bool operator==(const CFX_WideStringC& s1, const CFX_WideString& s2);
bool operator== (const CFX_WideString& s1, FX_LPCWSTR s2);
bool operator==(FX_LPCWSTR s1, const CFX_WideString& s2);
bool operator!=(const CFX_WideString& s1, const CFX_WideString& s2);
bool operator!=(const CFX_WideString& s1, const CFX_WideStringC& s2);
bool operator!=(const CFX_WideStringC& s1, const CFX_WideString& s2);
bool operator!= (const CFX_WideString& s1, FX_LPCWSTR s2);
bool operator!=(FX_LPCWSTR s1, const CFX_WideString& s2);
FX_FLOAT FX_atof(FX_BSTR str);
void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData);
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf);
CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len);
inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr)
{
return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());
}
inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr)
{
return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength());
}
#endif
|