xref: /aosp_15_r20/external/lzma/CPP/Common/MyString.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1*f6dc9357SAndroid Build Coastguard Worker // Common/MyString.h
2*f6dc9357SAndroid Build Coastguard Worker 
3*f6dc9357SAndroid Build Coastguard Worker #ifndef ZIP7_INC_COMMON_MY_STRING_H
4*f6dc9357SAndroid Build Coastguard Worker #define ZIP7_INC_COMMON_MY_STRING_H
5*f6dc9357SAndroid Build Coastguard Worker 
6*f6dc9357SAndroid Build Coastguard Worker #include <string.h>
7*f6dc9357SAndroid Build Coastguard Worker 
8*f6dc9357SAndroid Build Coastguard Worker #ifndef _WIN32
9*f6dc9357SAndroid Build Coastguard Worker #include <wctype.h>
10*f6dc9357SAndroid Build Coastguard Worker #include <wchar.h>
11*f6dc9357SAndroid Build Coastguard Worker #endif
12*f6dc9357SAndroid Build Coastguard Worker 
13*f6dc9357SAndroid Build Coastguard Worker #include "Common.h"
14*f6dc9357SAndroid Build Coastguard Worker #include "MyWindows.h"
15*f6dc9357SAndroid Build Coastguard Worker #include "MyTypes.h"
16*f6dc9357SAndroid Build Coastguard Worker #include "MyVector.h"
17*f6dc9357SAndroid Build Coastguard Worker 
18*f6dc9357SAndroid Build Coastguard Worker 
19*f6dc9357SAndroid Build Coastguard Worker /* if (DEBUG_FSTRING_INHERITS_ASTRING is defined), then
20*f6dc9357SAndroid Build Coastguard Worker      FString inherits from AString, so we can find bugs related to FString at compile time.
21*f6dc9357SAndroid Build Coastguard Worker    DON'T define DEBUG_FSTRING_INHERITS_ASTRING in release code */
22*f6dc9357SAndroid Build Coastguard Worker 
23*f6dc9357SAndroid Build Coastguard Worker // #define DEBUG_FSTRING_INHERITS_ASTRING
24*f6dc9357SAndroid Build Coastguard Worker 
25*f6dc9357SAndroid Build Coastguard Worker #ifdef DEBUG_FSTRING_INHERITS_ASTRING
26*f6dc9357SAndroid Build Coastguard Worker class FString;
27*f6dc9357SAndroid Build Coastguard Worker #endif
28*f6dc9357SAndroid Build Coastguard Worker 
29*f6dc9357SAndroid Build Coastguard Worker 
30*f6dc9357SAndroid Build Coastguard Worker #ifdef _MSC_VER
31*f6dc9357SAndroid Build Coastguard Worker   #ifdef _NATIVE_WCHAR_T_DEFINED
32*f6dc9357SAndroid Build Coastguard Worker     #define MY_NATIVE_WCHAR_T_DEFINED
33*f6dc9357SAndroid Build Coastguard Worker   #endif
34*f6dc9357SAndroid Build Coastguard Worker #else
35*f6dc9357SAndroid Build Coastguard Worker     #define MY_NATIVE_WCHAR_T_DEFINED
36*f6dc9357SAndroid Build Coastguard Worker #endif
37*f6dc9357SAndroid Build Coastguard Worker 
38*f6dc9357SAndroid Build Coastguard Worker /*
39*f6dc9357SAndroid Build Coastguard Worker   native support for wchar_t:
40*f6dc9357SAndroid Build Coastguard Worker  _MSC_VER == 1600 : /Zc:wchar_t is not supported
41*f6dc9357SAndroid Build Coastguard Worker  _MSC_VER == 1310 (VS2003)
42*f6dc9357SAndroid Build Coastguard Worker  ? _MSC_VER == 1400 (VS2005) : wchar_t <- unsigned short
43*f6dc9357SAndroid Build Coastguard Worker               /Zc:wchar_t  : wchar_t <- __wchar_t, _WCHAR_T_DEFINED and _NATIVE_WCHAR_T_DEFINED
44*f6dc9357SAndroid Build Coastguard Worker  _MSC_VER > 1400 (VS2008+)
45*f6dc9357SAndroid Build Coastguard Worker               /Zc:wchar_t[-]
46*f6dc9357SAndroid Build Coastguard Worker               /Zc:wchar_t is on by default
47*f6dc9357SAndroid Build Coastguard Worker */
48*f6dc9357SAndroid Build Coastguard Worker 
49*f6dc9357SAndroid Build Coastguard Worker #ifdef _WIN32
50*f6dc9357SAndroid Build Coastguard Worker #define IS_PATH_SEPAR(c) ((c) == '\\' || (c) == '/')
51*f6dc9357SAndroid Build Coastguard Worker #else
52*f6dc9357SAndroid Build Coastguard Worker #define IS_PATH_SEPAR(c) ((c) == CHAR_PATH_SEPARATOR)
53*f6dc9357SAndroid Build Coastguard Worker #endif
54*f6dc9357SAndroid Build Coastguard Worker 
IsPathSepar(char c)55*f6dc9357SAndroid Build Coastguard Worker inline bool IsPathSepar(char    c) { return IS_PATH_SEPAR(c); }
IsPathSepar(wchar_t c)56*f6dc9357SAndroid Build Coastguard Worker inline bool IsPathSepar(wchar_t c) { return IS_PATH_SEPAR(c); }
57*f6dc9357SAndroid Build Coastguard Worker 
MyStringLen(const char * s)58*f6dc9357SAndroid Build Coastguard Worker inline unsigned MyStringLen(const char *s)
59*f6dc9357SAndroid Build Coastguard Worker {
60*f6dc9357SAndroid Build Coastguard Worker   unsigned i;
61*f6dc9357SAndroid Build Coastguard Worker   for (i = 0; s[i] != 0; i++);
62*f6dc9357SAndroid Build Coastguard Worker   return i;
63*f6dc9357SAndroid Build Coastguard Worker }
64*f6dc9357SAndroid Build Coastguard Worker 
MyStringCopy(char * dest,const char * src)65*f6dc9357SAndroid Build Coastguard Worker inline void MyStringCopy(char *dest, const char *src)
66*f6dc9357SAndroid Build Coastguard Worker {
67*f6dc9357SAndroid Build Coastguard Worker   while ((*dest++ = *src++) != 0);
68*f6dc9357SAndroid Build Coastguard Worker }
69*f6dc9357SAndroid Build Coastguard Worker 
MyStpCpy(char * dest,const char * src)70*f6dc9357SAndroid Build Coastguard Worker inline char *MyStpCpy(char *dest, const char *src)
71*f6dc9357SAndroid Build Coastguard Worker {
72*f6dc9357SAndroid Build Coastguard Worker   for (;;)
73*f6dc9357SAndroid Build Coastguard Worker   {
74*f6dc9357SAndroid Build Coastguard Worker     const char c = *src;
75*f6dc9357SAndroid Build Coastguard Worker     *dest = c;
76*f6dc9357SAndroid Build Coastguard Worker     if (c == 0)
77*f6dc9357SAndroid Build Coastguard Worker       return dest;
78*f6dc9357SAndroid Build Coastguard Worker     src++;
79*f6dc9357SAndroid Build Coastguard Worker     dest++;
80*f6dc9357SAndroid Build Coastguard Worker   }
81*f6dc9357SAndroid Build Coastguard Worker }
82*f6dc9357SAndroid Build Coastguard Worker 
MyStringCat(char * dest,const char * src)83*f6dc9357SAndroid Build Coastguard Worker inline void MyStringCat(char *dest, const char *src)
84*f6dc9357SAndroid Build Coastguard Worker {
85*f6dc9357SAndroid Build Coastguard Worker   for (; *dest != 0; dest++);
86*f6dc9357SAndroid Build Coastguard Worker   while ((*dest++ = *src++) != 0);
87*f6dc9357SAndroid Build Coastguard Worker   // MyStringCopy(dest + MyStringLen(dest), src);
88*f6dc9357SAndroid Build Coastguard Worker }
89*f6dc9357SAndroid Build Coastguard Worker 
MyStringLen(const wchar_t * s)90*f6dc9357SAndroid Build Coastguard Worker inline unsigned MyStringLen(const wchar_t *s)
91*f6dc9357SAndroid Build Coastguard Worker {
92*f6dc9357SAndroid Build Coastguard Worker   unsigned i;
93*f6dc9357SAndroid Build Coastguard Worker   for (i = 0; s[i] != 0; i++);
94*f6dc9357SAndroid Build Coastguard Worker   return i;
95*f6dc9357SAndroid Build Coastguard Worker }
96*f6dc9357SAndroid Build Coastguard Worker 
MyStringCopy(wchar_t * dest,const wchar_t * src)97*f6dc9357SAndroid Build Coastguard Worker inline void MyStringCopy(wchar_t *dest, const wchar_t *src)
98*f6dc9357SAndroid Build Coastguard Worker {
99*f6dc9357SAndroid Build Coastguard Worker   while ((*dest++ = *src++) != 0);
100*f6dc9357SAndroid Build Coastguard Worker }
101*f6dc9357SAndroid Build Coastguard Worker 
MyStringCat(wchar_t * dest,const wchar_t * src)102*f6dc9357SAndroid Build Coastguard Worker inline void MyStringCat(wchar_t *dest, const wchar_t *src)
103*f6dc9357SAndroid Build Coastguard Worker {
104*f6dc9357SAndroid Build Coastguard Worker   for (; *dest != 0; dest++);
105*f6dc9357SAndroid Build Coastguard Worker   while ((*dest++ = *src++) != 0);
106*f6dc9357SAndroid Build Coastguard Worker   // MyStringCopy(dest + MyStringLen(dest), src);
107*f6dc9357SAndroid Build Coastguard Worker }
108*f6dc9357SAndroid Build Coastguard Worker 
109*f6dc9357SAndroid Build Coastguard Worker 
110*f6dc9357SAndroid Build Coastguard Worker /*
111*f6dc9357SAndroid Build Coastguard Worker inline wchar_t *MyWcpCpy(wchar_t *dest, const wchar_t *src)
112*f6dc9357SAndroid Build Coastguard Worker {
113*f6dc9357SAndroid Build Coastguard Worker   for (;;)
114*f6dc9357SAndroid Build Coastguard Worker   {
115*f6dc9357SAndroid Build Coastguard Worker     const wchar_t c = *src;
116*f6dc9357SAndroid Build Coastguard Worker     *dest = c;
117*f6dc9357SAndroid Build Coastguard Worker     if (c == 0)
118*f6dc9357SAndroid Build Coastguard Worker       return dest;
119*f6dc9357SAndroid Build Coastguard Worker     src++;
120*f6dc9357SAndroid Build Coastguard Worker     dest++;
121*f6dc9357SAndroid Build Coastguard Worker   }
122*f6dc9357SAndroid Build Coastguard Worker }
123*f6dc9357SAndroid Build Coastguard Worker */
124*f6dc9357SAndroid Build Coastguard Worker 
125*f6dc9357SAndroid Build Coastguard Worker int FindCharPosInString(const char *s, char c) throw();
126*f6dc9357SAndroid Build Coastguard Worker int FindCharPosInString(const wchar_t *s, wchar_t c) throw();
127*f6dc9357SAndroid Build Coastguard Worker 
128*f6dc9357SAndroid Build Coastguard Worker #ifdef _WIN32
129*f6dc9357SAndroid Build Coastguard Worker   #ifndef _UNICODE
130*f6dc9357SAndroid Build Coastguard Worker     #define STRING_UNICODE_THROW
131*f6dc9357SAndroid Build Coastguard Worker   #endif
132*f6dc9357SAndroid Build Coastguard Worker #endif
133*f6dc9357SAndroid Build Coastguard Worker 
134*f6dc9357SAndroid Build Coastguard Worker #ifndef STRING_UNICODE_THROW
135*f6dc9357SAndroid Build Coastguard Worker   #define STRING_UNICODE_THROW throw()
136*f6dc9357SAndroid Build Coastguard Worker #endif
137*f6dc9357SAndroid Build Coastguard Worker 
138*f6dc9357SAndroid Build Coastguard Worker 
MyCharUpper_Ascii(char c)139*f6dc9357SAndroid Build Coastguard Worker inline char MyCharUpper_Ascii(char c)
140*f6dc9357SAndroid Build Coastguard Worker {
141*f6dc9357SAndroid Build Coastguard Worker   if (c >= 'a' && c <= 'z')
142*f6dc9357SAndroid Build Coastguard Worker     return (char)((unsigned char)c - 0x20);
143*f6dc9357SAndroid Build Coastguard Worker   return c;
144*f6dc9357SAndroid Build Coastguard Worker }
145*f6dc9357SAndroid Build Coastguard Worker 
146*f6dc9357SAndroid Build Coastguard Worker /*
147*f6dc9357SAndroid Build Coastguard Worker inline wchar_t MyCharUpper_Ascii(wchar_t c)
148*f6dc9357SAndroid Build Coastguard Worker {
149*f6dc9357SAndroid Build Coastguard Worker   if (c >= 'a' && c <= 'z')
150*f6dc9357SAndroid Build Coastguard Worker     return (wchar_t)(c - 0x20);
151*f6dc9357SAndroid Build Coastguard Worker   return c;
152*f6dc9357SAndroid Build Coastguard Worker }
153*f6dc9357SAndroid Build Coastguard Worker */
154*f6dc9357SAndroid Build Coastguard Worker 
MyCharLower_Ascii(char c)155*f6dc9357SAndroid Build Coastguard Worker inline char MyCharLower_Ascii(char c)
156*f6dc9357SAndroid Build Coastguard Worker {
157*f6dc9357SAndroid Build Coastguard Worker   if (c >= 'A' && c <= 'Z')
158*f6dc9357SAndroid Build Coastguard Worker     return (char)((unsigned char)c + 0x20);
159*f6dc9357SAndroid Build Coastguard Worker   return c;
160*f6dc9357SAndroid Build Coastguard Worker }
161*f6dc9357SAndroid Build Coastguard Worker 
MyCharLower_Ascii(wchar_t c)162*f6dc9357SAndroid Build Coastguard Worker inline wchar_t MyCharLower_Ascii(wchar_t c)
163*f6dc9357SAndroid Build Coastguard Worker {
164*f6dc9357SAndroid Build Coastguard Worker   if (c >= 'A' && c <= 'Z')
165*f6dc9357SAndroid Build Coastguard Worker     return (wchar_t)(c + 0x20);
166*f6dc9357SAndroid Build Coastguard Worker   return c;
167*f6dc9357SAndroid Build Coastguard Worker }
168*f6dc9357SAndroid Build Coastguard Worker 
169*f6dc9357SAndroid Build Coastguard Worker wchar_t MyCharUpper_WIN(wchar_t c) throw();
170*f6dc9357SAndroid Build Coastguard Worker 
MyCharUpper(wchar_t c)171*f6dc9357SAndroid Build Coastguard Worker inline wchar_t MyCharUpper(wchar_t c) throw()
172*f6dc9357SAndroid Build Coastguard Worker {
173*f6dc9357SAndroid Build Coastguard Worker   if (c < 'a') return c;
174*f6dc9357SAndroid Build Coastguard Worker   if (c <= 'z') return (wchar_t)(c - 0x20);
175*f6dc9357SAndroid Build Coastguard Worker   if (c <= 0x7F) return c;
176*f6dc9357SAndroid Build Coastguard Worker   #ifdef _WIN32
177*f6dc9357SAndroid Build Coastguard Worker     #ifdef _UNICODE
178*f6dc9357SAndroid Build Coastguard Worker       return (wchar_t)(unsigned)(UINT_PTR)CharUpperW((LPWSTR)(UINT_PTR)(unsigned)c);
179*f6dc9357SAndroid Build Coastguard Worker     #else
180*f6dc9357SAndroid Build Coastguard Worker       return (wchar_t)MyCharUpper_WIN(c);
181*f6dc9357SAndroid Build Coastguard Worker     #endif
182*f6dc9357SAndroid Build Coastguard Worker   #else
183*f6dc9357SAndroid Build Coastguard Worker     return (wchar_t)towupper((wint_t)c);
184*f6dc9357SAndroid Build Coastguard Worker   #endif
185*f6dc9357SAndroid Build Coastguard Worker }
186*f6dc9357SAndroid Build Coastguard Worker 
187*f6dc9357SAndroid Build Coastguard Worker /*
188*f6dc9357SAndroid Build Coastguard Worker wchar_t MyCharLower_WIN(wchar_t c) throw();
189*f6dc9357SAndroid Build Coastguard Worker 
190*f6dc9357SAndroid Build Coastguard Worker inline wchar_t MyCharLower(wchar_t c) throw()
191*f6dc9357SAndroid Build Coastguard Worker {
192*f6dc9357SAndroid Build Coastguard Worker   if (c < 'A') return c;
193*f6dc9357SAndroid Build Coastguard Worker   if (c <= 'Z') return (wchar_t)(c + 0x20);
194*f6dc9357SAndroid Build Coastguard Worker   if (c <= 0x7F) return c;
195*f6dc9357SAndroid Build Coastguard Worker   #ifdef _WIN32
196*f6dc9357SAndroid Build Coastguard Worker     #ifdef _UNICODE
197*f6dc9357SAndroid Build Coastguard Worker       return (wchar_t)(unsigned)(UINT_PTR)CharLowerW((LPWSTR)(UINT_PTR)(unsigned)c);
198*f6dc9357SAndroid Build Coastguard Worker     #else
199*f6dc9357SAndroid Build Coastguard Worker       return (wchar_t)MyCharLower_WIN(c);
200*f6dc9357SAndroid Build Coastguard Worker     #endif
201*f6dc9357SAndroid Build Coastguard Worker   #else
202*f6dc9357SAndroid Build Coastguard Worker     return (wchar_t)tolower(c);
203*f6dc9357SAndroid Build Coastguard Worker   #endif
204*f6dc9357SAndroid Build Coastguard Worker }
205*f6dc9357SAndroid Build Coastguard Worker */
206*f6dc9357SAndroid Build Coastguard Worker 
207*f6dc9357SAndroid Build Coastguard Worker // char *MyStringUpper(char *s) throw();
208*f6dc9357SAndroid Build Coastguard Worker // char *MyStringLower(char *s) throw();
209*f6dc9357SAndroid Build Coastguard Worker 
210*f6dc9357SAndroid Build Coastguard Worker // void MyStringUpper_Ascii(char *s) throw();
211*f6dc9357SAndroid Build Coastguard Worker // void MyStringUpper_Ascii(wchar_t *s) throw();
212*f6dc9357SAndroid Build Coastguard Worker void MyStringLower_Ascii(char *s) throw();
213*f6dc9357SAndroid Build Coastguard Worker void MyStringLower_Ascii(wchar_t *s) throw();
214*f6dc9357SAndroid Build Coastguard Worker // wchar_t *MyStringUpper(wchar_t *s) STRING_UNICODE_THROW;
215*f6dc9357SAndroid Build Coastguard Worker // wchar_t *MyStringLower(wchar_t *s) STRING_UNICODE_THROW;
216*f6dc9357SAndroid Build Coastguard Worker 
217*f6dc9357SAndroid Build Coastguard Worker bool StringsAreEqualNoCase(const wchar_t *s1, const wchar_t *s2) throw();
218*f6dc9357SAndroid Build Coastguard Worker 
219*f6dc9357SAndroid Build Coastguard Worker bool IsString1PrefixedByString2(const char *s1, const char *s2) throw();
220*f6dc9357SAndroid Build Coastguard Worker bool IsString1PrefixedByString2(const wchar_t *s1, const wchar_t *s2) throw();
221*f6dc9357SAndroid Build Coastguard Worker bool IsString1PrefixedByString2(const wchar_t *s1, const char *s2) throw();
222*f6dc9357SAndroid Build Coastguard Worker bool IsString1PrefixedByString2_NoCase_Ascii(const char *s1, const char *s2) throw();
223*f6dc9357SAndroid Build Coastguard Worker bool IsString1PrefixedByString2_NoCase_Ascii(const wchar_t *u, const char *a) throw();
224*f6dc9357SAndroid Build Coastguard Worker bool IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_t *s2) throw();
225*f6dc9357SAndroid Build Coastguard Worker 
226*f6dc9357SAndroid Build Coastguard Worker #define MyStringCompare(s1, s2) wcscmp(s1, s2)
227*f6dc9357SAndroid Build Coastguard Worker int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2) throw();
228*f6dc9357SAndroid Build Coastguard Worker // int MyStringCompareNoCase_N(const wchar_t *s1, const wchar_t *s2, unsigned num) throw();
229*f6dc9357SAndroid Build Coastguard Worker 
230*f6dc9357SAndroid Build Coastguard Worker // ---------- ASCII ----------
231*f6dc9357SAndroid Build Coastguard Worker // char values in ASCII strings must be less then 128
232*f6dc9357SAndroid Build Coastguard Worker bool StringsAreEqual_Ascii(const char *u, const char *a) throw();
233*f6dc9357SAndroid Build Coastguard Worker bool StringsAreEqual_Ascii(const wchar_t *u, const char *a) throw();
234*f6dc9357SAndroid Build Coastguard Worker bool StringsAreEqualNoCase_Ascii(const char *s1, const char *s2) throw();
235*f6dc9357SAndroid Build Coastguard Worker bool StringsAreEqualNoCase_Ascii(const wchar_t *s1, const char *s2) throw();
236*f6dc9357SAndroid Build Coastguard Worker bool StringsAreEqualNoCase_Ascii(const wchar_t *s1, const wchar_t *s2) throw();
237*f6dc9357SAndroid Build Coastguard Worker 
238*f6dc9357SAndroid Build Coastguard Worker #define MY_STRING_DELETE(_p_) { delete [](_p_); }
239*f6dc9357SAndroid Build Coastguard Worker // #define MY_STRING_DELETE(_p_) my_delete(_p_);
240*f6dc9357SAndroid Build Coastguard Worker 
241*f6dc9357SAndroid Build Coastguard Worker 
242*f6dc9357SAndroid Build Coastguard Worker #define FORBID_STRING_OPS_2(cls, t) \
243*f6dc9357SAndroid Build Coastguard Worker   void Find(t) const; \
244*f6dc9357SAndroid Build Coastguard Worker   void Find(t, unsigned startIndex) const; \
245*f6dc9357SAndroid Build Coastguard Worker   void ReverseFind(t) const; \
246*f6dc9357SAndroid Build Coastguard Worker   void InsertAtFront(t); \
247*f6dc9357SAndroid Build Coastguard Worker   void RemoveChar(t); \
248*f6dc9357SAndroid Build Coastguard Worker   void Replace(t, t); \
249*f6dc9357SAndroid Build Coastguard Worker 
250*f6dc9357SAndroid Build Coastguard Worker #define FORBID_STRING_OPS(cls, t) \
251*f6dc9357SAndroid Build Coastguard Worker   explicit cls(t); \
252*f6dc9357SAndroid Build Coastguard Worker   explicit cls(const t *); \
253*f6dc9357SAndroid Build Coastguard Worker   cls &operator=(t); \
254*f6dc9357SAndroid Build Coastguard Worker   cls &operator=(const t *); \
255*f6dc9357SAndroid Build Coastguard Worker   cls &operator+=(t); \
256*f6dc9357SAndroid Build Coastguard Worker   cls &operator+=(const t *); \
257*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_2(cls, t) \
258*f6dc9357SAndroid Build Coastguard Worker 
259*f6dc9357SAndroid Build Coastguard Worker /*
260*f6dc9357SAndroid Build Coastguard Worker   cls &operator+(t); \
261*f6dc9357SAndroid Build Coastguard Worker   cls &operator+(const t *); \
262*f6dc9357SAndroid Build Coastguard Worker */
263*f6dc9357SAndroid Build Coastguard Worker 
264*f6dc9357SAndroid Build Coastguard Worker #define FORBID_STRING_OPS_AString(t) FORBID_STRING_OPS(AString, t)
265*f6dc9357SAndroid Build Coastguard Worker #define FORBID_STRING_OPS_UString(t) FORBID_STRING_OPS(UString, t)
266*f6dc9357SAndroid Build Coastguard Worker #define FORBID_STRING_OPS_UString2(t) FORBID_STRING_OPS(UString2, t)
267*f6dc9357SAndroid Build Coastguard Worker 
268*f6dc9357SAndroid Build Coastguard Worker class AString
269*f6dc9357SAndroid Build Coastguard Worker {
270*f6dc9357SAndroid Build Coastguard Worker   char *_chars;
271*f6dc9357SAndroid Build Coastguard Worker   unsigned _len;
272*f6dc9357SAndroid Build Coastguard Worker   unsigned _limit;
273*f6dc9357SAndroid Build Coastguard Worker 
MoveItems(unsigned dest,unsigned src)274*f6dc9357SAndroid Build Coastguard Worker   void MoveItems(unsigned dest, unsigned src)
275*f6dc9357SAndroid Build Coastguard Worker   {
276*f6dc9357SAndroid Build Coastguard Worker     memmove(_chars + dest, _chars + src, (size_t)(_len - src + 1) * sizeof(char));
277*f6dc9357SAndroid Build Coastguard Worker   }
278*f6dc9357SAndroid Build Coastguard Worker 
279*f6dc9357SAndroid Build Coastguard Worker   void InsertSpace(unsigned &index, unsigned size);
280*f6dc9357SAndroid Build Coastguard Worker 
281*f6dc9357SAndroid Build Coastguard Worker   void ReAlloc(unsigned newLimit);
282*f6dc9357SAndroid Build Coastguard Worker   void ReAlloc2(unsigned newLimit);
283*f6dc9357SAndroid Build Coastguard Worker   void SetStartLen(unsigned len);
284*f6dc9357SAndroid Build Coastguard Worker 
285*f6dc9357SAndroid Build Coastguard Worker   Z7_NO_INLINE
286*f6dc9357SAndroid Build Coastguard Worker   void Grow_1();
287*f6dc9357SAndroid Build Coastguard Worker   void Grow(unsigned n);
288*f6dc9357SAndroid Build Coastguard Worker 
289*f6dc9357SAndroid Build Coastguard Worker   AString(unsigned num, const char *s);
290*f6dc9357SAndroid Build Coastguard Worker   AString(unsigned num, const AString &s);
291*f6dc9357SAndroid Build Coastguard Worker   AString(const AString &s, char c); // it's for String + char
292*f6dc9357SAndroid Build Coastguard Worker   AString(const char *s1, unsigned num1, const char *s2, unsigned num2);
293*f6dc9357SAndroid Build Coastguard Worker 
294*f6dc9357SAndroid Build Coastguard Worker   friend AString operator+(const AString &s, char c) { return AString(s, c); }
295*f6dc9357SAndroid Build Coastguard Worker   // friend AString operator+(char c, const AString &s); // is not supported
296*f6dc9357SAndroid Build Coastguard Worker 
297*f6dc9357SAndroid Build Coastguard Worker   friend AString operator+(const AString &s1, const AString &s2);
298*f6dc9357SAndroid Build Coastguard Worker   friend AString operator+(const AString &s1, const char    *s2);
299*f6dc9357SAndroid Build Coastguard Worker   friend AString operator+(const char    *s1, const AString &s2);
300*f6dc9357SAndroid Build Coastguard Worker 
301*f6dc9357SAndroid Build Coastguard Worker   // ---------- forbidden functions ----------
302*f6dc9357SAndroid Build Coastguard Worker 
303*f6dc9357SAndroid Build Coastguard Worker   #ifdef MY_NATIVE_WCHAR_T_DEFINED
304*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_AString(wchar_t)
305*f6dc9357SAndroid Build Coastguard Worker   #endif
306*f6dc9357SAndroid Build Coastguard Worker 
307*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_AString(signed char)
308*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_AString(unsigned char)
309*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_AString(short)
310*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_AString(unsigned short)
311*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_AString(int)
312*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_AString(unsigned)
313*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_AString(long)
314*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_AString(unsigned long)
315*f6dc9357SAndroid Build Coastguard Worker 
316*f6dc9357SAndroid Build Coastguard Worker  #ifdef DEBUG_FSTRING_INHERITS_ASTRING
317*f6dc9357SAndroid Build Coastguard Worker   AString(const FString &s);
318*f6dc9357SAndroid Build Coastguard Worker   AString &operator=(const FString &s);
319*f6dc9357SAndroid Build Coastguard Worker   AString &operator+=(const FString &s);
320*f6dc9357SAndroid Build Coastguard Worker  #endif
321*f6dc9357SAndroid Build Coastguard Worker 
322*f6dc9357SAndroid Build Coastguard Worker public:
323*f6dc9357SAndroid Build Coastguard Worker   explicit AString();
324*f6dc9357SAndroid Build Coastguard Worker   explicit AString(char c);
325*f6dc9357SAndroid Build Coastguard Worker   explicit AString(const char *s);
326*f6dc9357SAndroid Build Coastguard Worker   AString(const AString &s);
~AString()327*f6dc9357SAndroid Build Coastguard Worker   ~AString() { MY_STRING_DELETE(_chars) }
328*f6dc9357SAndroid Build Coastguard Worker 
Len()329*f6dc9357SAndroid Build Coastguard Worker   unsigned Len() const { return _len; }
IsEmpty()330*f6dc9357SAndroid Build Coastguard Worker   bool IsEmpty() const { return _len == 0; }
Empty()331*f6dc9357SAndroid Build Coastguard Worker   void Empty() { _len = 0; _chars[0] = 0; }
332*f6dc9357SAndroid Build Coastguard Worker 
333*f6dc9357SAndroid Build Coastguard Worker   operator const char *() const { return _chars; }
Ptr_non_const()334*f6dc9357SAndroid Build Coastguard Worker   char *Ptr_non_const() const { return _chars; }
Ptr()335*f6dc9357SAndroid Build Coastguard Worker   const char *Ptr() const { return _chars; }
Ptr(unsigned pos)336*f6dc9357SAndroid Build Coastguard Worker   const char *Ptr(unsigned pos) const { return _chars + pos; }
Ptr(int pos)337*f6dc9357SAndroid Build Coastguard Worker   const char *Ptr(int pos) const { return _chars + (unsigned)pos; }
RightPtr(unsigned num)338*f6dc9357SAndroid Build Coastguard Worker   const char *RightPtr(unsigned num) const { return _chars + _len - num; }
Back()339*f6dc9357SAndroid Build Coastguard Worker   char Back() const { return _chars[(size_t)_len - 1]; }
340*f6dc9357SAndroid Build Coastguard Worker 
ReplaceOneCharAtPos(unsigned pos,char c)341*f6dc9357SAndroid Build Coastguard Worker   void ReplaceOneCharAtPos(unsigned pos, char c) { _chars[pos] = c; }
342*f6dc9357SAndroid Build Coastguard Worker 
GetBuf()343*f6dc9357SAndroid Build Coastguard Worker   char *GetBuf() { return _chars; }
344*f6dc9357SAndroid Build Coastguard Worker   /* GetBuf(minLen): provides the buffer that can store
345*f6dc9357SAndroid Build Coastguard Worker      at least (minLen) characters and additional null terminator.
346*f6dc9357SAndroid Build Coastguard Worker      9.35: GetBuf doesn't preserve old characters and terminator */
GetBuf(unsigned minLen)347*f6dc9357SAndroid Build Coastguard Worker   char *GetBuf(unsigned minLen)
348*f6dc9357SAndroid Build Coastguard Worker   {
349*f6dc9357SAndroid Build Coastguard Worker     if (minLen > _limit)
350*f6dc9357SAndroid Build Coastguard Worker       ReAlloc2(minLen);
351*f6dc9357SAndroid Build Coastguard Worker     return _chars;
352*f6dc9357SAndroid Build Coastguard Worker   }
GetBuf_SetEnd(unsigned minLen)353*f6dc9357SAndroid Build Coastguard Worker   char *GetBuf_SetEnd(unsigned minLen)
354*f6dc9357SAndroid Build Coastguard Worker   {
355*f6dc9357SAndroid Build Coastguard Worker     if (minLen > _limit)
356*f6dc9357SAndroid Build Coastguard Worker       ReAlloc2(minLen);
357*f6dc9357SAndroid Build Coastguard Worker     char *chars = _chars;
358*f6dc9357SAndroid Build Coastguard Worker     chars[minLen] = 0;
359*f6dc9357SAndroid Build Coastguard Worker     _len = minLen;
360*f6dc9357SAndroid Build Coastguard Worker     return chars;
361*f6dc9357SAndroid Build Coastguard Worker   }
362*f6dc9357SAndroid Build Coastguard Worker 
ReleaseBuf_SetLen(unsigned newLen)363*f6dc9357SAndroid Build Coastguard Worker   void ReleaseBuf_SetLen(unsigned newLen) { _len = newLen; }
ReleaseBuf_SetEnd(unsigned newLen)364*f6dc9357SAndroid Build Coastguard Worker   void ReleaseBuf_SetEnd(unsigned newLen) { _len = newLen; _chars[newLen] = 0; }
ReleaseBuf_CalcLen(unsigned maxLen)365*f6dc9357SAndroid Build Coastguard Worker   void ReleaseBuf_CalcLen(unsigned maxLen)
366*f6dc9357SAndroid Build Coastguard Worker   {
367*f6dc9357SAndroid Build Coastguard Worker     char *chars = _chars;
368*f6dc9357SAndroid Build Coastguard Worker     chars[maxLen] = 0;
369*f6dc9357SAndroid Build Coastguard Worker     _len = MyStringLen(chars);
370*f6dc9357SAndroid Build Coastguard Worker   }
371*f6dc9357SAndroid Build Coastguard Worker 
372*f6dc9357SAndroid Build Coastguard Worker   AString &operator=(char c);
373*f6dc9357SAndroid Build Coastguard Worker   AString &operator=(const char *s);
374*f6dc9357SAndroid Build Coastguard Worker   AString &operator=(const AString &s);
375*f6dc9357SAndroid Build Coastguard Worker   void SetFromWStr_if_Ascii(const wchar_t *s);
376*f6dc9357SAndroid Build Coastguard Worker   // void SetFromBstr_if_Ascii(BSTR s);
377*f6dc9357SAndroid Build Coastguard Worker 
378*f6dc9357SAndroid Build Coastguard Worker // private:
379*f6dc9357SAndroid Build Coastguard Worker   Z7_FORCE_INLINE
380*f6dc9357SAndroid Build Coastguard Worker   AString &operator+=(char c)
381*f6dc9357SAndroid Build Coastguard Worker   {
382*f6dc9357SAndroid Build Coastguard Worker     if (_limit == _len)
383*f6dc9357SAndroid Build Coastguard Worker       Grow_1();
384*f6dc9357SAndroid Build Coastguard Worker     unsigned len = _len;
385*f6dc9357SAndroid Build Coastguard Worker     char *chars = _chars;
386*f6dc9357SAndroid Build Coastguard Worker     chars[len++] = c;
387*f6dc9357SAndroid Build Coastguard Worker     chars[len] = 0;
388*f6dc9357SAndroid Build Coastguard Worker     _len = len;
389*f6dc9357SAndroid Build Coastguard Worker     return *this;
390*f6dc9357SAndroid Build Coastguard Worker   }
391*f6dc9357SAndroid Build Coastguard Worker public:
392*f6dc9357SAndroid Build Coastguard Worker   void Add_Space();
393*f6dc9357SAndroid Build Coastguard Worker   void Add_Space_if_NotEmpty();
394*f6dc9357SAndroid Build Coastguard Worker   void Add_OptSpaced(const char *s);
395*f6dc9357SAndroid Build Coastguard Worker   void Add_Char(char c);
396*f6dc9357SAndroid Build Coastguard Worker   void Add_LF();
397*f6dc9357SAndroid Build Coastguard Worker   void Add_Slash();
398*f6dc9357SAndroid Build Coastguard Worker   void Add_Dot();
399*f6dc9357SAndroid Build Coastguard Worker   void Add_Minus();
400*f6dc9357SAndroid Build Coastguard Worker   void Add_Colon();
Add_PathSepar()401*f6dc9357SAndroid Build Coastguard Worker   void Add_PathSepar() { operator+=(CHAR_PATH_SEPARATOR); }
402*f6dc9357SAndroid Build Coastguard Worker 
403*f6dc9357SAndroid Build Coastguard Worker   AString &operator+=(const char *s);
404*f6dc9357SAndroid Build Coastguard Worker   AString &operator+=(const AString &s);
405*f6dc9357SAndroid Build Coastguard Worker 
406*f6dc9357SAndroid Build Coastguard Worker   void Add_UInt32(UInt32 v);
407*f6dc9357SAndroid Build Coastguard Worker   void Add_UInt64(UInt64 v);
408*f6dc9357SAndroid Build Coastguard Worker 
409*f6dc9357SAndroid Build Coastguard Worker   void AddFrom(const char *s, unsigned len); // no check
410*f6dc9357SAndroid Build Coastguard Worker   void SetFrom(const char *s, unsigned len); // no check
411*f6dc9357SAndroid Build Coastguard Worker   void SetFrom_Chars_SizeT(const char* s, size_t len); // no check
SetFrom(const char * s,int len)412*f6dc9357SAndroid Build Coastguard Worker   void SetFrom(const char* s, int len) // no check
413*f6dc9357SAndroid Build Coastguard Worker   {
414*f6dc9357SAndroid Build Coastguard Worker     SetFrom(s, (unsigned)len); // no check
415*f6dc9357SAndroid Build Coastguard Worker   }
416*f6dc9357SAndroid Build Coastguard Worker   void SetFrom_CalcLen(const char *s, unsigned len);
417*f6dc9357SAndroid Build Coastguard Worker 
Mid(unsigned startIndex,unsigned count)418*f6dc9357SAndroid Build Coastguard Worker   AString Mid(unsigned startIndex, unsigned count) const { return AString(count, _chars + startIndex); }
Left(unsigned count)419*f6dc9357SAndroid Build Coastguard Worker   AString Left(unsigned count) const { return AString(count, *this); }
420*f6dc9357SAndroid Build Coastguard Worker   // void MakeUpper() { MyStringUpper(_chars); }
421*f6dc9357SAndroid Build Coastguard Worker   // void MakeLower() { MyStringLower(_chars); }
MakeLower_Ascii()422*f6dc9357SAndroid Build Coastguard Worker   void MakeLower_Ascii() { MyStringLower_Ascii(_chars); }
423*f6dc9357SAndroid Build Coastguard Worker 
424*f6dc9357SAndroid Build Coastguard Worker 
IsEqualTo(const char * s)425*f6dc9357SAndroid Build Coastguard Worker   bool IsEqualTo(const char *s) const { return strcmp(_chars, s) == 0; }
IsEqualTo_Ascii_NoCase(const char * s)426*f6dc9357SAndroid Build Coastguard Worker   bool IsEqualTo_Ascii_NoCase(const char *s) const { return StringsAreEqualNoCase_Ascii(_chars, s); }
427*f6dc9357SAndroid Build Coastguard Worker   // int Compare(const char *s) const { return MyStringCompare(_chars, s); }
428*f6dc9357SAndroid Build Coastguard Worker   // int Compare(const AString &s) const { return MyStringCompare(_chars, s._chars); }
429*f6dc9357SAndroid Build Coastguard Worker   // int CompareNoCase(const char *s) const { return MyStringCompareNoCase(_chars, s); }
430*f6dc9357SAndroid Build Coastguard Worker   // int CompareNoCase(const AString &s) const { return MyStringCompareNoCase(_chars, s._chars); }
IsPrefixedBy(const char * s)431*f6dc9357SAndroid Build Coastguard Worker   bool IsPrefixedBy(const char *s) const { return IsString1PrefixedByString2(_chars, s); }
432*f6dc9357SAndroid Build Coastguard Worker   bool IsPrefixedBy_Ascii_NoCase(const char *s) const throw();
433*f6dc9357SAndroid Build Coastguard Worker 
IsAscii()434*f6dc9357SAndroid Build Coastguard Worker   bool IsAscii() const
435*f6dc9357SAndroid Build Coastguard Worker   {
436*f6dc9357SAndroid Build Coastguard Worker     unsigned len = Len();
437*f6dc9357SAndroid Build Coastguard Worker     const char *s = _chars;
438*f6dc9357SAndroid Build Coastguard Worker     for (unsigned i = 0; i < len; i++)
439*f6dc9357SAndroid Build Coastguard Worker       if ((unsigned char)s[i] >= 0x80)
440*f6dc9357SAndroid Build Coastguard Worker         return false;
441*f6dc9357SAndroid Build Coastguard Worker     return true;
442*f6dc9357SAndroid Build Coastguard Worker   }
Find(char c)443*f6dc9357SAndroid Build Coastguard Worker   int Find(char c) const { return FindCharPosInString(_chars, c); }
Find(char c,unsigned startIndex)444*f6dc9357SAndroid Build Coastguard Worker   int Find(char c, unsigned startIndex) const
445*f6dc9357SAndroid Build Coastguard Worker   {
446*f6dc9357SAndroid Build Coastguard Worker     const int pos = FindCharPosInString(_chars + startIndex, c);
447*f6dc9357SAndroid Build Coastguard Worker     return pos < 0 ? -1 : (int)startIndex + pos;
448*f6dc9357SAndroid Build Coastguard Worker   }
Find(char c,int startIndex)449*f6dc9357SAndroid Build Coastguard Worker   int Find(char c, int startIndex) const
450*f6dc9357SAndroid Build Coastguard Worker   {
451*f6dc9357SAndroid Build Coastguard Worker     return Find(c, (unsigned)startIndex);
452*f6dc9357SAndroid Build Coastguard Worker   }
453*f6dc9357SAndroid Build Coastguard Worker 
454*f6dc9357SAndroid Build Coastguard Worker   int ReverseFind(char c) const throw();
ReverseFind_Dot()455*f6dc9357SAndroid Build Coastguard Worker   int ReverseFind_Dot() const throw() { return ReverseFind('.'); }
456*f6dc9357SAndroid Build Coastguard Worker   int ReverseFind_PathSepar() const throw();
457*f6dc9357SAndroid Build Coastguard Worker 
Find(const char * s)458*f6dc9357SAndroid Build Coastguard Worker   int Find(const char *s) const { return Find(s, 0); }
459*f6dc9357SAndroid Build Coastguard Worker   int Find(const char *s, unsigned startIndex) const throw();
460*f6dc9357SAndroid Build Coastguard Worker 
461*f6dc9357SAndroid Build Coastguard Worker   void TrimLeft() throw();
462*f6dc9357SAndroid Build Coastguard Worker   void TrimRight() throw();
Trim()463*f6dc9357SAndroid Build Coastguard Worker   void Trim()
464*f6dc9357SAndroid Build Coastguard Worker   {
465*f6dc9357SAndroid Build Coastguard Worker     TrimRight();
466*f6dc9357SAndroid Build Coastguard Worker     TrimLeft();
467*f6dc9357SAndroid Build Coastguard Worker   }
468*f6dc9357SAndroid Build Coastguard Worker 
469*f6dc9357SAndroid Build Coastguard Worker   void InsertAtFront(char c);
470*f6dc9357SAndroid Build Coastguard Worker   // void Insert(unsigned index, char c);
471*f6dc9357SAndroid Build Coastguard Worker   void Insert(unsigned index, const char *s);
472*f6dc9357SAndroid Build Coastguard Worker   void Insert(unsigned index, const AString &s);
473*f6dc9357SAndroid Build Coastguard Worker 
474*f6dc9357SAndroid Build Coastguard Worker   void RemoveChar(char ch) throw();
475*f6dc9357SAndroid Build Coastguard Worker 
476*f6dc9357SAndroid Build Coastguard Worker   void Replace(char oldChar, char newChar) throw();
477*f6dc9357SAndroid Build Coastguard Worker   void Replace(const AString &oldString, const AString &newString);
478*f6dc9357SAndroid Build Coastguard Worker 
479*f6dc9357SAndroid Build Coastguard Worker   void Delete(unsigned index) throw();
480*f6dc9357SAndroid Build Coastguard Worker   void Delete(unsigned index, unsigned count) throw();
481*f6dc9357SAndroid Build Coastguard Worker   void DeleteFrontal(unsigned num) throw();
DeleteBack()482*f6dc9357SAndroid Build Coastguard Worker   void DeleteBack() { _chars[--_len] = 0; }
DeleteFrom(unsigned index)483*f6dc9357SAndroid Build Coastguard Worker   void DeleteFrom(unsigned index)
484*f6dc9357SAndroid Build Coastguard Worker   {
485*f6dc9357SAndroid Build Coastguard Worker     if (index < _len)
486*f6dc9357SAndroid Build Coastguard Worker     {
487*f6dc9357SAndroid Build Coastguard Worker       _len = index;
488*f6dc9357SAndroid Build Coastguard Worker       _chars[index] = 0;
489*f6dc9357SAndroid Build Coastguard Worker     }
490*f6dc9357SAndroid Build Coastguard Worker   }
DeleteFrom(int index)491*f6dc9357SAndroid Build Coastguard Worker   void DeleteFrom(int index)
492*f6dc9357SAndroid Build Coastguard Worker   {
493*f6dc9357SAndroid Build Coastguard Worker     DeleteFrom((unsigned)index);
494*f6dc9357SAndroid Build Coastguard Worker   }
495*f6dc9357SAndroid Build Coastguard Worker 
496*f6dc9357SAndroid Build Coastguard Worker 
Wipe_and_Empty()497*f6dc9357SAndroid Build Coastguard Worker   void Wipe_and_Empty()
498*f6dc9357SAndroid Build Coastguard Worker   {
499*f6dc9357SAndroid Build Coastguard Worker     if (_chars)
500*f6dc9357SAndroid Build Coastguard Worker     {
501*f6dc9357SAndroid Build Coastguard Worker       memset(_chars, 0, (_limit + 1) * sizeof(*_chars));
502*f6dc9357SAndroid Build Coastguard Worker       _len = 0;
503*f6dc9357SAndroid Build Coastguard Worker     }
504*f6dc9357SAndroid Build Coastguard Worker   }
505*f6dc9357SAndroid Build Coastguard Worker };
506*f6dc9357SAndroid Build Coastguard Worker 
507*f6dc9357SAndroid Build Coastguard Worker 
508*f6dc9357SAndroid Build Coastguard Worker class AString_Wipe: public AString
509*f6dc9357SAndroid Build Coastguard Worker {
Z7_CLASS_NO_COPY(AString_Wipe)510*f6dc9357SAndroid Build Coastguard Worker   Z7_CLASS_NO_COPY(AString_Wipe)
511*f6dc9357SAndroid Build Coastguard Worker public:
512*f6dc9357SAndroid Build Coastguard Worker   AString_Wipe(): AString() {}
513*f6dc9357SAndroid Build Coastguard Worker   // AString_Wipe(const AString &s): AString(s) {}
514*f6dc9357SAndroid Build Coastguard Worker   // AString_Wipe &operator=(const AString &s) { AString::operator=(s); return *this; }
515*f6dc9357SAndroid Build Coastguard Worker   // AString_Wipe &operator=(const char *s) { AString::operator=(s); return *this; }
~AString_Wipe()516*f6dc9357SAndroid Build Coastguard Worker   ~AString_Wipe() { Wipe_and_Empty(); }
517*f6dc9357SAndroid Build Coastguard Worker };
518*f6dc9357SAndroid Build Coastguard Worker 
519*f6dc9357SAndroid Build Coastguard Worker 
520*f6dc9357SAndroid Build Coastguard Worker bool operator<(const AString &s1, const AString &s2);
521*f6dc9357SAndroid Build Coastguard Worker bool operator>(const AString &s1, const AString &s2);
522*f6dc9357SAndroid Build Coastguard Worker 
523*f6dc9357SAndroid Build Coastguard Worker /*
524*f6dc9357SAndroid Build Coastguard Worker bool operator==(const AString &s1, const AString &s2);
525*f6dc9357SAndroid Build Coastguard Worker bool operator==(const AString &s1, const char    *s2);
526*f6dc9357SAndroid Build Coastguard Worker bool operator==(const char    *s1, const AString &s2);
527*f6dc9357SAndroid Build Coastguard Worker 
528*f6dc9357SAndroid Build Coastguard Worker bool operator!=(const AString &s1, const AString &s2);
529*f6dc9357SAndroid Build Coastguard Worker bool operator!=(const AString &s1, const char    *s2);
530*f6dc9357SAndroid Build Coastguard Worker bool operator!=(const char    *s1, const AString &s2);
531*f6dc9357SAndroid Build Coastguard Worker */
532*f6dc9357SAndroid Build Coastguard Worker 
533*f6dc9357SAndroid Build Coastguard Worker inline bool operator==(const AString &s1, const AString &s2) { return s1.Len() == s2.Len() && strcmp(s1, s2) == 0; }
534*f6dc9357SAndroid Build Coastguard Worker inline bool operator==(const AString &s1, const char    *s2) { return strcmp(s1, s2) == 0; }
535*f6dc9357SAndroid Build Coastguard Worker inline bool operator==(const char    *s1, const AString &s2) { return strcmp(s1, s2) == 0; }
536*f6dc9357SAndroid Build Coastguard Worker 
537*f6dc9357SAndroid Build Coastguard Worker inline bool operator!=(const AString &s1, const AString &s2) { return s1.Len() != s2.Len() || strcmp(s1, s2) != 0; }
538*f6dc9357SAndroid Build Coastguard Worker inline bool operator!=(const AString &s1, const char    *s2) { return strcmp(s1, s2) != 0; }
539*f6dc9357SAndroid Build Coastguard Worker inline bool operator!=(const char    *s1, const AString &s2) { return strcmp(s1, s2) != 0; }
540*f6dc9357SAndroid Build Coastguard Worker 
541*f6dc9357SAndroid Build Coastguard Worker // ---------- forbidden functions ----------
542*f6dc9357SAndroid Build Coastguard Worker 
543*f6dc9357SAndroid Build Coastguard Worker void operator==(char c1, const AString &s2);
544*f6dc9357SAndroid Build Coastguard Worker void operator==(const AString &s1, char c2);
545*f6dc9357SAndroid Build Coastguard Worker 
546*f6dc9357SAndroid Build Coastguard Worker void operator+(char c, const AString &s); // this function can be OK, but we don't use it
547*f6dc9357SAndroid Build Coastguard Worker 
548*f6dc9357SAndroid Build Coastguard Worker void operator+(const AString &s, int c);
549*f6dc9357SAndroid Build Coastguard Worker void operator+(const AString &s, unsigned c);
550*f6dc9357SAndroid Build Coastguard Worker void operator+(int c, const AString &s);
551*f6dc9357SAndroid Build Coastguard Worker void operator+(unsigned c, const AString &s);
552*f6dc9357SAndroid Build Coastguard Worker void operator-(const AString &s, int c);
553*f6dc9357SAndroid Build Coastguard Worker void operator-(const AString &s, unsigned c);
554*f6dc9357SAndroid Build Coastguard Worker 
555*f6dc9357SAndroid Build Coastguard Worker 
556*f6dc9357SAndroid Build Coastguard Worker class UString
557*f6dc9357SAndroid Build Coastguard Worker {
558*f6dc9357SAndroid Build Coastguard Worker   wchar_t *_chars;
559*f6dc9357SAndroid Build Coastguard Worker   unsigned _len;
560*f6dc9357SAndroid Build Coastguard Worker   unsigned _limit;
561*f6dc9357SAndroid Build Coastguard Worker 
MoveItems(unsigned dest,unsigned src)562*f6dc9357SAndroid Build Coastguard Worker   void MoveItems(unsigned dest, unsigned src)
563*f6dc9357SAndroid Build Coastguard Worker   {
564*f6dc9357SAndroid Build Coastguard Worker     memmove(_chars + dest, _chars + src, (size_t)(_len - src + 1) * sizeof(wchar_t));
565*f6dc9357SAndroid Build Coastguard Worker   }
566*f6dc9357SAndroid Build Coastguard Worker 
567*f6dc9357SAndroid Build Coastguard Worker   void InsertSpace(unsigned index, unsigned size);
568*f6dc9357SAndroid Build Coastguard Worker 
569*f6dc9357SAndroid Build Coastguard Worker   void ReAlloc(unsigned newLimit);
570*f6dc9357SAndroid Build Coastguard Worker   void ReAlloc2(unsigned newLimit);
571*f6dc9357SAndroid Build Coastguard Worker   void SetStartLen(unsigned len);
572*f6dc9357SAndroid Build Coastguard Worker   void Grow_1();
573*f6dc9357SAndroid Build Coastguard Worker   void Grow(unsigned n);
574*f6dc9357SAndroid Build Coastguard Worker 
575*f6dc9357SAndroid Build Coastguard Worker   UString(unsigned num, const wchar_t *s); // for Mid
576*f6dc9357SAndroid Build Coastguard Worker   UString(unsigned num, const UString &s); // for Left
577*f6dc9357SAndroid Build Coastguard Worker   UString(const UString &s, wchar_t c); // it's for String + char
578*f6dc9357SAndroid Build Coastguard Worker   UString(const wchar_t *s1, unsigned num1, const wchar_t *s2, unsigned num2);
579*f6dc9357SAndroid Build Coastguard Worker 
580*f6dc9357SAndroid Build Coastguard Worker   friend UString operator+(const UString &s, wchar_t c) { return UString(s, c); }
581*f6dc9357SAndroid Build Coastguard Worker   // friend UString operator+(wchar_t c, const UString &s); // is not supported
582*f6dc9357SAndroid Build Coastguard Worker 
583*f6dc9357SAndroid Build Coastguard Worker   friend UString operator+(const UString &s1, const UString &s2);
584*f6dc9357SAndroid Build Coastguard Worker   friend UString operator+(const UString &s1, const wchar_t *s2);
585*f6dc9357SAndroid Build Coastguard Worker   friend UString operator+(const wchar_t *s1, const UString &s2);
586*f6dc9357SAndroid Build Coastguard Worker 
587*f6dc9357SAndroid Build Coastguard Worker   // ---------- forbidden functions ----------
588*f6dc9357SAndroid Build Coastguard Worker 
589*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString(signed char)
590*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString(unsigned char)
591*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString(short)
592*f6dc9357SAndroid Build Coastguard Worker 
593*f6dc9357SAndroid Build Coastguard Worker   #ifdef MY_NATIVE_WCHAR_T_DEFINED
594*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString(unsigned short)
595*f6dc9357SAndroid Build Coastguard Worker   #endif
596*f6dc9357SAndroid Build Coastguard Worker 
597*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString(int)
598*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString(unsigned)
599*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString(long)
600*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString(unsigned long)
601*f6dc9357SAndroid Build Coastguard Worker 
602*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_2(UString, char)
603*f6dc9357SAndroid Build Coastguard Worker 
604*f6dc9357SAndroid Build Coastguard Worker  #ifdef DEBUG_FSTRING_INHERITS_ASTRING
605*f6dc9357SAndroid Build Coastguard Worker   UString(const FString &s);
606*f6dc9357SAndroid Build Coastguard Worker   UString &operator=(const FString &s);
607*f6dc9357SAndroid Build Coastguard Worker   UString &operator+=(const FString &s);
608*f6dc9357SAndroid Build Coastguard Worker  #endif
609*f6dc9357SAndroid Build Coastguard Worker 
610*f6dc9357SAndroid Build Coastguard Worker public:
611*f6dc9357SAndroid Build Coastguard Worker   UString();
612*f6dc9357SAndroid Build Coastguard Worker   explicit UString(wchar_t c);
613*f6dc9357SAndroid Build Coastguard Worker   explicit UString(char c);
614*f6dc9357SAndroid Build Coastguard Worker   explicit UString(const char *s);
615*f6dc9357SAndroid Build Coastguard Worker   explicit UString(const AString &s);
616*f6dc9357SAndroid Build Coastguard Worker   UString(const wchar_t *s);
617*f6dc9357SAndroid Build Coastguard Worker   UString(const UString &s);
~UString()618*f6dc9357SAndroid Build Coastguard Worker   ~UString() { MY_STRING_DELETE(_chars) }
619*f6dc9357SAndroid Build Coastguard Worker 
Len()620*f6dc9357SAndroid Build Coastguard Worker   unsigned Len() const { return _len; }
IsEmpty()621*f6dc9357SAndroid Build Coastguard Worker   bool IsEmpty() const { return _len == 0; }
Empty()622*f6dc9357SAndroid Build Coastguard Worker   void Empty() { _len = 0; _chars[0] = 0; }
623*f6dc9357SAndroid Build Coastguard Worker 
624*f6dc9357SAndroid Build Coastguard Worker   operator const wchar_t *() const { return _chars; }
Ptr_non_const()625*f6dc9357SAndroid Build Coastguard Worker   wchar_t *Ptr_non_const() const { return _chars; }
Ptr()626*f6dc9357SAndroid Build Coastguard Worker   const wchar_t *Ptr() const { return _chars; }
Ptr(int pos)627*f6dc9357SAndroid Build Coastguard Worker   const wchar_t *Ptr(int pos) const { return _chars + (unsigned)pos; }
Ptr(unsigned pos)628*f6dc9357SAndroid Build Coastguard Worker   const wchar_t *Ptr(unsigned pos) const { return _chars + pos; }
RightPtr(unsigned num)629*f6dc9357SAndroid Build Coastguard Worker   const wchar_t *RightPtr(unsigned num) const { return _chars + _len - num; }
Back()630*f6dc9357SAndroid Build Coastguard Worker   wchar_t Back() const { return _chars[(size_t)_len - 1]; }
631*f6dc9357SAndroid Build Coastguard Worker 
ReplaceOneCharAtPos(unsigned pos,wchar_t c)632*f6dc9357SAndroid Build Coastguard Worker   void ReplaceOneCharAtPos(unsigned pos, wchar_t c) { _chars[pos] = c; }
633*f6dc9357SAndroid Build Coastguard Worker 
GetBuf()634*f6dc9357SAndroid Build Coastguard Worker   wchar_t *GetBuf() { return _chars; }
635*f6dc9357SAndroid Build Coastguard Worker 
636*f6dc9357SAndroid Build Coastguard Worker   /*
637*f6dc9357SAndroid Build Coastguard Worker   wchar_t *GetBuf_GetMaxAvail(unsigned &availBufLen)
638*f6dc9357SAndroid Build Coastguard Worker   {
639*f6dc9357SAndroid Build Coastguard Worker     availBufLen = _limit;
640*f6dc9357SAndroid Build Coastguard Worker     return _chars;
641*f6dc9357SAndroid Build Coastguard Worker   }
642*f6dc9357SAndroid Build Coastguard Worker   */
643*f6dc9357SAndroid Build Coastguard Worker 
GetBuf(unsigned minLen)644*f6dc9357SAndroid Build Coastguard Worker   wchar_t *GetBuf(unsigned minLen)
645*f6dc9357SAndroid Build Coastguard Worker   {
646*f6dc9357SAndroid Build Coastguard Worker     if (minLen > _limit)
647*f6dc9357SAndroid Build Coastguard Worker       ReAlloc2(minLen);
648*f6dc9357SAndroid Build Coastguard Worker     return _chars;
649*f6dc9357SAndroid Build Coastguard Worker   }
GetBuf_SetEnd(unsigned minLen)650*f6dc9357SAndroid Build Coastguard Worker   wchar_t *GetBuf_SetEnd(unsigned minLen)
651*f6dc9357SAndroid Build Coastguard Worker   {
652*f6dc9357SAndroid Build Coastguard Worker     if (minLen > _limit)
653*f6dc9357SAndroid Build Coastguard Worker       ReAlloc2(minLen);
654*f6dc9357SAndroid Build Coastguard Worker     wchar_t *chars = _chars;
655*f6dc9357SAndroid Build Coastguard Worker     chars[minLen] = 0;
656*f6dc9357SAndroid Build Coastguard Worker     _len = minLen;
657*f6dc9357SAndroid Build Coastguard Worker     return chars;
658*f6dc9357SAndroid Build Coastguard Worker   }
659*f6dc9357SAndroid Build Coastguard Worker 
ReleaseBuf_SetLen(unsigned newLen)660*f6dc9357SAndroid Build Coastguard Worker   void ReleaseBuf_SetLen(unsigned newLen) { _len = newLen; }
ReleaseBuf_SetEnd(unsigned newLen)661*f6dc9357SAndroid Build Coastguard Worker   void ReleaseBuf_SetEnd(unsigned newLen) { _len = newLen; _chars[newLen] = 0; }
ReleaseBuf_CalcLen(unsigned maxLen)662*f6dc9357SAndroid Build Coastguard Worker   void ReleaseBuf_CalcLen(unsigned maxLen)
663*f6dc9357SAndroid Build Coastguard Worker   {
664*f6dc9357SAndroid Build Coastguard Worker     wchar_t *chars = _chars;
665*f6dc9357SAndroid Build Coastguard Worker     chars[maxLen] = 0;
666*f6dc9357SAndroid Build Coastguard Worker     _len = MyStringLen(chars);
667*f6dc9357SAndroid Build Coastguard Worker   }
668*f6dc9357SAndroid Build Coastguard Worker 
669*f6dc9357SAndroid Build Coastguard Worker   UString &operator=(wchar_t c);
670*f6dc9357SAndroid Build Coastguard Worker   UString &operator=(char c) { return (*this)=((wchar_t)(unsigned char)c); }
671*f6dc9357SAndroid Build Coastguard Worker   UString &operator=(const wchar_t *s);
672*f6dc9357SAndroid Build Coastguard Worker   UString &operator=(const UString &s);
673*f6dc9357SAndroid Build Coastguard Worker   void SetFrom(const wchar_t *s, unsigned len); // no check
674*f6dc9357SAndroid Build Coastguard Worker   void SetFromBstr(LPCOLESTR s);
675*f6dc9357SAndroid Build Coastguard Worker   UString &operator=(const char *s);
676*f6dc9357SAndroid Build Coastguard Worker   UString &operator=(const AString &s) { return operator=(s.Ptr()); }
677*f6dc9357SAndroid Build Coastguard Worker 
678*f6dc9357SAndroid Build Coastguard Worker // private:
679*f6dc9357SAndroid Build Coastguard Worker   Z7_FORCE_INLINE
680*f6dc9357SAndroid Build Coastguard Worker   UString &operator+=(wchar_t c)
681*f6dc9357SAndroid Build Coastguard Worker   {
682*f6dc9357SAndroid Build Coastguard Worker     if (_limit == _len)
683*f6dc9357SAndroid Build Coastguard Worker       Grow_1();
684*f6dc9357SAndroid Build Coastguard Worker     unsigned len = _len;
685*f6dc9357SAndroid Build Coastguard Worker     wchar_t *chars = _chars;
686*f6dc9357SAndroid Build Coastguard Worker     chars[len++] = c;
687*f6dc9357SAndroid Build Coastguard Worker     chars[len] = 0;
688*f6dc9357SAndroid Build Coastguard Worker     _len = len;
689*f6dc9357SAndroid Build Coastguard Worker     return *this;
690*f6dc9357SAndroid Build Coastguard Worker   }
691*f6dc9357SAndroid Build Coastguard Worker 
692*f6dc9357SAndroid Build Coastguard Worker private:
693*f6dc9357SAndroid Build Coastguard Worker   UString &operator+=(char c); //  { return (*this)+=((wchar_t)(unsigned char)c); }
694*f6dc9357SAndroid Build Coastguard Worker public:
695*f6dc9357SAndroid Build Coastguard Worker   void Add_Char(char c);
696*f6dc9357SAndroid Build Coastguard Worker   // void Add_WChar(wchar_t c);
697*f6dc9357SAndroid Build Coastguard Worker   void Add_Space();
698*f6dc9357SAndroid Build Coastguard Worker   void Add_Space_if_NotEmpty();
699*f6dc9357SAndroid Build Coastguard Worker   void Add_LF();
700*f6dc9357SAndroid Build Coastguard Worker   void Add_Dot();
701*f6dc9357SAndroid Build Coastguard Worker   void Add_Minus();
702*f6dc9357SAndroid Build Coastguard Worker   void Add_Colon();
Add_PathSepar()703*f6dc9357SAndroid Build Coastguard Worker   void Add_PathSepar() { operator+=(WCHAR_PATH_SEPARATOR); }
704*f6dc9357SAndroid Build Coastguard Worker 
705*f6dc9357SAndroid Build Coastguard Worker   UString &operator+=(const wchar_t *s);
706*f6dc9357SAndroid Build Coastguard Worker   UString &operator+=(const UString &s);
707*f6dc9357SAndroid Build Coastguard Worker   UString &operator+=(const char *s);
708*f6dc9357SAndroid Build Coastguard Worker   UString &operator+=(const AString &s) { return operator+=(s.Ptr()); }
709*f6dc9357SAndroid Build Coastguard Worker 
710*f6dc9357SAndroid Build Coastguard Worker   void Add_UInt32(UInt32 v);
711*f6dc9357SAndroid Build Coastguard Worker   void Add_UInt64(UInt64 v);
712*f6dc9357SAndroid Build Coastguard Worker 
Mid(unsigned startIndex,unsigned count)713*f6dc9357SAndroid Build Coastguard Worker   UString Mid(unsigned startIndex, unsigned count) const { return UString(count, _chars + startIndex); }
Left(unsigned count)714*f6dc9357SAndroid Build Coastguard Worker   UString Left(unsigned count) const { return UString(count, *this); }
Left(int count)715*f6dc9357SAndroid Build Coastguard Worker   UString Left(int count) const { return Left((unsigned)count); }
716*f6dc9357SAndroid Build Coastguard Worker 
717*f6dc9357SAndroid Build Coastguard Worker   // void MakeUpper() { MyStringUpper(_chars); }
718*f6dc9357SAndroid Build Coastguard Worker   // void MakeUpper() { MyStringUpper_Ascii(_chars); }
719*f6dc9357SAndroid Build Coastguard Worker   // void MakeUpper_Ascii() { MyStringUpper_Ascii(_chars); }
MakeLower_Ascii()720*f6dc9357SAndroid Build Coastguard Worker   void MakeLower_Ascii() { MyStringLower_Ascii(_chars); }
721*f6dc9357SAndroid Build Coastguard Worker 
IsEqualTo(const char * s)722*f6dc9357SAndroid Build Coastguard Worker   bool IsEqualTo(const char *s) const { return StringsAreEqual_Ascii(_chars, s); }
IsEqualTo_NoCase(const wchar_t * s)723*f6dc9357SAndroid Build Coastguard Worker   bool IsEqualTo_NoCase(const wchar_t *s) const { return StringsAreEqualNoCase(_chars, s); }
IsEqualTo_Ascii_NoCase(const char * s)724*f6dc9357SAndroid Build Coastguard Worker   bool IsEqualTo_Ascii_NoCase(const char *s) const { return StringsAreEqualNoCase_Ascii(_chars, s); }
Compare(const wchar_t * s)725*f6dc9357SAndroid Build Coastguard Worker   int Compare(const wchar_t *s) const { return wcscmp(_chars, s); }
726*f6dc9357SAndroid Build Coastguard Worker   // int Compare(const UString &s) const { return MyStringCompare(_chars, s._chars); }
727*f6dc9357SAndroid Build Coastguard Worker   // int CompareNoCase(const wchar_t *s) const { return MyStringCompareNoCase(_chars, s); }
728*f6dc9357SAndroid Build Coastguard Worker   // int CompareNoCase(const UString &s) const { return MyStringCompareNoCase(_chars, s._chars); }
IsPrefixedBy(const wchar_t * s)729*f6dc9357SAndroid Build Coastguard Worker   bool IsPrefixedBy(const wchar_t *s) const { return IsString1PrefixedByString2(_chars, s); }
IsPrefixedBy_NoCase(const wchar_t * s)730*f6dc9357SAndroid Build Coastguard Worker   bool IsPrefixedBy_NoCase(const wchar_t *s) const { return IsString1PrefixedByString2_NoCase(_chars, s); }
731*f6dc9357SAndroid Build Coastguard Worker   bool IsPrefixedBy_Ascii_NoCase(const char *s) const throw();
732*f6dc9357SAndroid Build Coastguard Worker 
IsAscii()733*f6dc9357SAndroid Build Coastguard Worker   bool IsAscii() const
734*f6dc9357SAndroid Build Coastguard Worker   {
735*f6dc9357SAndroid Build Coastguard Worker     unsigned len = Len();
736*f6dc9357SAndroid Build Coastguard Worker     const wchar_t *s = _chars;
737*f6dc9357SAndroid Build Coastguard Worker     for (unsigned i = 0; i < len; i++)
738*f6dc9357SAndroid Build Coastguard Worker       if (s[i] >= 0x80)
739*f6dc9357SAndroid Build Coastguard Worker         return false;
740*f6dc9357SAndroid Build Coastguard Worker     return true;
741*f6dc9357SAndroid Build Coastguard Worker   }
Find(wchar_t c)742*f6dc9357SAndroid Build Coastguard Worker   int Find(wchar_t c) const { return FindCharPosInString(_chars, c); }
Find(wchar_t c,unsigned startIndex)743*f6dc9357SAndroid Build Coastguard Worker   int Find(wchar_t c, unsigned startIndex) const
744*f6dc9357SAndroid Build Coastguard Worker   {
745*f6dc9357SAndroid Build Coastguard Worker     int pos = FindCharPosInString(_chars + startIndex, c);
746*f6dc9357SAndroid Build Coastguard Worker     return pos < 0 ? -1 : (int)startIndex + pos;
747*f6dc9357SAndroid Build Coastguard Worker   }
748*f6dc9357SAndroid Build Coastguard Worker 
749*f6dc9357SAndroid Build Coastguard Worker   int ReverseFind(wchar_t c) const throw();
ReverseFind_Dot()750*f6dc9357SAndroid Build Coastguard Worker   int ReverseFind_Dot() const throw() { return ReverseFind(L'.'); }
751*f6dc9357SAndroid Build Coastguard Worker   int ReverseFind_PathSepar() const throw();
752*f6dc9357SAndroid Build Coastguard Worker 
Find(const wchar_t * s)753*f6dc9357SAndroid Build Coastguard Worker   int Find(const wchar_t *s) const { return Find(s, 0); }
754*f6dc9357SAndroid Build Coastguard Worker   int Find(const wchar_t *s, unsigned startIndex) const throw();
755*f6dc9357SAndroid Build Coastguard Worker 
756*f6dc9357SAndroid Build Coastguard Worker   void TrimLeft() throw();
757*f6dc9357SAndroid Build Coastguard Worker   void TrimRight() throw();
Trim()758*f6dc9357SAndroid Build Coastguard Worker   void Trim()
759*f6dc9357SAndroid Build Coastguard Worker   {
760*f6dc9357SAndroid Build Coastguard Worker     TrimRight();
761*f6dc9357SAndroid Build Coastguard Worker     TrimLeft();
762*f6dc9357SAndroid Build Coastguard Worker   }
763*f6dc9357SAndroid Build Coastguard Worker 
764*f6dc9357SAndroid Build Coastguard Worker   void InsertAtFront(wchar_t c);
765*f6dc9357SAndroid Build Coastguard Worker   // void Insert_wchar_t(unsigned index, wchar_t c);
766*f6dc9357SAndroid Build Coastguard Worker   void Insert(unsigned index, const wchar_t *s);
767*f6dc9357SAndroid Build Coastguard Worker   void Insert(unsigned index, const UString &s);
768*f6dc9357SAndroid Build Coastguard Worker 
769*f6dc9357SAndroid Build Coastguard Worker   void RemoveChar(wchar_t ch) throw();
770*f6dc9357SAndroid Build Coastguard Worker 
771*f6dc9357SAndroid Build Coastguard Worker   void Replace(wchar_t oldChar, wchar_t newChar) throw();
772*f6dc9357SAndroid Build Coastguard Worker   void Replace(const UString &oldString, const UString &newString);
773*f6dc9357SAndroid Build Coastguard Worker 
Delete(int index)774*f6dc9357SAndroid Build Coastguard Worker   void Delete(int index) throw() { Delete((unsigned)index); }
775*f6dc9357SAndroid Build Coastguard Worker   void Delete(unsigned index) throw();
776*f6dc9357SAndroid Build Coastguard Worker   void Delete(unsigned index, unsigned count) throw();
777*f6dc9357SAndroid Build Coastguard Worker   void DeleteFrontal(unsigned num) throw();
DeleteBack()778*f6dc9357SAndroid Build Coastguard Worker   void DeleteBack() { _chars[--_len] = 0; }
DeleteFrom(int index)779*f6dc9357SAndroid Build Coastguard Worker   void DeleteFrom(int index) { DeleteFrom((unsigned)index); }
DeleteFrom(unsigned index)780*f6dc9357SAndroid Build Coastguard Worker   void DeleteFrom(unsigned index)
781*f6dc9357SAndroid Build Coastguard Worker   {
782*f6dc9357SAndroid Build Coastguard Worker     if (index < _len)
783*f6dc9357SAndroid Build Coastguard Worker     {
784*f6dc9357SAndroid Build Coastguard Worker       _len = index;
785*f6dc9357SAndroid Build Coastguard Worker       _chars[index] = 0;
786*f6dc9357SAndroid Build Coastguard Worker     }
787*f6dc9357SAndroid Build Coastguard Worker   }
788*f6dc9357SAndroid Build Coastguard Worker 
Wipe_and_Empty()789*f6dc9357SAndroid Build Coastguard Worker   void Wipe_and_Empty()
790*f6dc9357SAndroid Build Coastguard Worker   {
791*f6dc9357SAndroid Build Coastguard Worker     if (_chars)
792*f6dc9357SAndroid Build Coastguard Worker     {
793*f6dc9357SAndroid Build Coastguard Worker       memset(_chars, 0, (_limit + 1) * sizeof(*_chars));
794*f6dc9357SAndroid Build Coastguard Worker       _len = 0;
795*f6dc9357SAndroid Build Coastguard Worker     }
796*f6dc9357SAndroid Build Coastguard Worker   }
797*f6dc9357SAndroid Build Coastguard Worker };
798*f6dc9357SAndroid Build Coastguard Worker 
799*f6dc9357SAndroid Build Coastguard Worker 
800*f6dc9357SAndroid Build Coastguard Worker class UString_Wipe: public UString
801*f6dc9357SAndroid Build Coastguard Worker {
Z7_CLASS_NO_COPY(UString_Wipe)802*f6dc9357SAndroid Build Coastguard Worker   Z7_CLASS_NO_COPY(UString_Wipe)
803*f6dc9357SAndroid Build Coastguard Worker public:
804*f6dc9357SAndroid Build Coastguard Worker   UString_Wipe(): UString() {}
805*f6dc9357SAndroid Build Coastguard Worker   // UString_Wipe(const UString &s): UString(s) {}
806*f6dc9357SAndroid Build Coastguard Worker   // UString_Wipe &operator=(const UString &s) { UString::operator=(s); return *this; }
807*f6dc9357SAndroid Build Coastguard Worker   // UString_Wipe &operator=(const wchar_t *s) { UString::operator=(s); return *this; }
~UString_Wipe()808*f6dc9357SAndroid Build Coastguard Worker   ~UString_Wipe() { Wipe_and_Empty(); }
809*f6dc9357SAndroid Build Coastguard Worker };
810*f6dc9357SAndroid Build Coastguard Worker 
811*f6dc9357SAndroid Build Coastguard Worker 
812*f6dc9357SAndroid Build Coastguard Worker bool operator<(const UString &s1, const UString &s2);
813*f6dc9357SAndroid Build Coastguard Worker bool operator>(const UString &s1, const UString &s2);
814*f6dc9357SAndroid Build Coastguard Worker 
815*f6dc9357SAndroid Build Coastguard Worker inline bool operator==(const UString &s1, const UString &s2) { return s1.Len() == s2.Len() && wcscmp(s1, s2) == 0; }
816*f6dc9357SAndroid Build Coastguard Worker inline bool operator==(const UString &s1, const wchar_t *s2) { return wcscmp(s1, s2) == 0; }
817*f6dc9357SAndroid Build Coastguard Worker inline bool operator==(const wchar_t *s1, const UString &s2) { return wcscmp(s1, s2) == 0; }
818*f6dc9357SAndroid Build Coastguard Worker 
819*f6dc9357SAndroid Build Coastguard Worker inline bool operator!=(const UString &s1, const UString &s2) { return s1.Len() != s2.Len() || wcscmp(s1, s2) != 0; }
820*f6dc9357SAndroid Build Coastguard Worker inline bool operator!=(const UString &s1, const wchar_t *s2) { return wcscmp(s1, s2) != 0; }
821*f6dc9357SAndroid Build Coastguard Worker inline bool operator!=(const wchar_t *s1, const UString &s2) { return wcscmp(s1, s2) != 0; }
822*f6dc9357SAndroid Build Coastguard Worker 
823*f6dc9357SAndroid Build Coastguard Worker 
824*f6dc9357SAndroid Build Coastguard Worker // ---------- forbidden functions ----------
825*f6dc9357SAndroid Build Coastguard Worker 
826*f6dc9357SAndroid Build Coastguard Worker void operator==(wchar_t c1, const UString &s2);
827*f6dc9357SAndroid Build Coastguard Worker void operator==(const UString &s1, wchar_t c2);
828*f6dc9357SAndroid Build Coastguard Worker 
829*f6dc9357SAndroid Build Coastguard Worker void operator+(wchar_t c, const UString &s); // this function can be OK, but we don't use it
830*f6dc9357SAndroid Build Coastguard Worker 
831*f6dc9357SAndroid Build Coastguard Worker void operator+(const AString &s1, const UString &s2);
832*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString &s1, const AString &s2);
833*f6dc9357SAndroid Build Coastguard Worker 
834*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString &s1, const char *s2);
835*f6dc9357SAndroid Build Coastguard Worker void operator+(const char *s1, const UString &s2);
836*f6dc9357SAndroid Build Coastguard Worker 
837*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString &s, char c);
838*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString &s, unsigned char c);
839*f6dc9357SAndroid Build Coastguard Worker void operator+(char c, const UString &s);
840*f6dc9357SAndroid Build Coastguard Worker void operator+(unsigned char c, const UString &s);
841*f6dc9357SAndroid Build Coastguard Worker void operator-(const UString &s1, wchar_t c);
842*f6dc9357SAndroid Build Coastguard Worker 
843*f6dc9357SAndroid Build Coastguard Worker #ifdef _WIN32
844*f6dc9357SAndroid Build Coastguard Worker // can we forbid these functions, if wchar_t is 32-bit ?
845*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString &s, int c);
846*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString &s, unsigned c);
847*f6dc9357SAndroid Build Coastguard Worker void operator+(int c, const UString &s);
848*f6dc9357SAndroid Build Coastguard Worker void operator+(unsigned c, const UString &s);
849*f6dc9357SAndroid Build Coastguard Worker void operator-(const UString &s1, int c);
850*f6dc9357SAndroid Build Coastguard Worker void operator-(const UString &s1, unsigned c);
851*f6dc9357SAndroid Build Coastguard Worker #endif
852*f6dc9357SAndroid Build Coastguard Worker 
853*f6dc9357SAndroid Build Coastguard Worker 
854*f6dc9357SAndroid Build Coastguard Worker 
855*f6dc9357SAndroid Build Coastguard Worker 
856*f6dc9357SAndroid Build Coastguard Worker 
857*f6dc9357SAndroid Build Coastguard Worker 
858*f6dc9357SAndroid Build Coastguard Worker 
859*f6dc9357SAndroid Build Coastguard Worker class UString2
860*f6dc9357SAndroid Build Coastguard Worker {
861*f6dc9357SAndroid Build Coastguard Worker   wchar_t *_chars;
862*f6dc9357SAndroid Build Coastguard Worker   unsigned _len;
863*f6dc9357SAndroid Build Coastguard Worker 
864*f6dc9357SAndroid Build Coastguard Worker   void ReAlloc2(unsigned newLimit);
865*f6dc9357SAndroid Build Coastguard Worker   void SetStartLen(unsigned len);
866*f6dc9357SAndroid Build Coastguard Worker 
867*f6dc9357SAndroid Build Coastguard Worker   // ---------- forbidden functions ----------
868*f6dc9357SAndroid Build Coastguard Worker 
869*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString2(char)
870*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString2(signed char)
871*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString2(unsigned char)
872*f6dc9357SAndroid Build Coastguard Worker   FORBID_STRING_OPS_UString2(short)
873*f6dc9357SAndroid Build Coastguard Worker 
874*f6dc9357SAndroid Build Coastguard Worker   UString2 &operator=(wchar_t c);
875*f6dc9357SAndroid Build Coastguard Worker 
876*f6dc9357SAndroid Build Coastguard Worker   UString2(const AString &s);
877*f6dc9357SAndroid Build Coastguard Worker   UString2 &operator=(const AString &s);
878*f6dc9357SAndroid Build Coastguard Worker   UString2 &operator+=(const AString &s);
879*f6dc9357SAndroid Build Coastguard Worker 
880*f6dc9357SAndroid Build Coastguard Worker  #ifdef DEBUG_FSTRING_INHERITS_ASTRING
881*f6dc9357SAndroid Build Coastguard Worker   UString2(const FString &s);
882*f6dc9357SAndroid Build Coastguard Worker   UString2 &operator=(const FString &s);
883*f6dc9357SAndroid Build Coastguard Worker   UString2 &operator+=(const FString &s);
884*f6dc9357SAndroid Build Coastguard Worker  #endif
885*f6dc9357SAndroid Build Coastguard Worker 
886*f6dc9357SAndroid Build Coastguard Worker public:
UString2()887*f6dc9357SAndroid Build Coastguard Worker   UString2(): _chars(NULL), _len(0) {}
888*f6dc9357SAndroid Build Coastguard Worker   UString2(const wchar_t *s);
889*f6dc9357SAndroid Build Coastguard Worker   UString2(const UString2 &s);
~UString2()890*f6dc9357SAndroid Build Coastguard Worker   ~UString2() { if (_chars) { MY_STRING_DELETE(_chars) } }
891*f6dc9357SAndroid Build Coastguard Worker 
Len()892*f6dc9357SAndroid Build Coastguard Worker   unsigned Len() const { return _len; }
IsEmpty()893*f6dc9357SAndroid Build Coastguard Worker   bool IsEmpty() const { return _len == 0; }
894*f6dc9357SAndroid Build Coastguard Worker   // void Empty() { _len = 0; _chars[0] = 0; }
895*f6dc9357SAndroid Build Coastguard Worker 
896*f6dc9357SAndroid Build Coastguard Worker   // operator const wchar_t *() const { return _chars; }
GetRawPtr()897*f6dc9357SAndroid Build Coastguard Worker   const wchar_t *GetRawPtr() const { return _chars; }
898*f6dc9357SAndroid Build Coastguard Worker 
Compare(const wchar_t * s)899*f6dc9357SAndroid Build Coastguard Worker   int Compare(const wchar_t *s) const { return wcscmp(_chars, s); }
900*f6dc9357SAndroid Build Coastguard Worker 
GetBuf(unsigned minLen)901*f6dc9357SAndroid Build Coastguard Worker   wchar_t *GetBuf(unsigned minLen)
902*f6dc9357SAndroid Build Coastguard Worker   {
903*f6dc9357SAndroid Build Coastguard Worker     if (!_chars || minLen > _len)
904*f6dc9357SAndroid Build Coastguard Worker       ReAlloc2(minLen);
905*f6dc9357SAndroid Build Coastguard Worker     return _chars;
906*f6dc9357SAndroid Build Coastguard Worker   }
ReleaseBuf_SetLen(unsigned newLen)907*f6dc9357SAndroid Build Coastguard Worker   void ReleaseBuf_SetLen(unsigned newLen) { _len = newLen; }
908*f6dc9357SAndroid Build Coastguard Worker 
909*f6dc9357SAndroid Build Coastguard Worker   UString2 &operator=(const wchar_t *s);
910*f6dc9357SAndroid Build Coastguard Worker   UString2 &operator=(const UString2 &s);
911*f6dc9357SAndroid Build Coastguard Worker   void SetFromAscii(const char *s);
912*f6dc9357SAndroid Build Coastguard Worker };
913*f6dc9357SAndroid Build Coastguard Worker 
914*f6dc9357SAndroid Build Coastguard Worker bool operator==(const UString2 &s1, const UString2 &s2);
915*f6dc9357SAndroid Build Coastguard Worker bool operator==(const UString2 &s1, const wchar_t *s2);
916*f6dc9357SAndroid Build Coastguard Worker bool operator==(const wchar_t *s1, const UString2 &s2);
917*f6dc9357SAndroid Build Coastguard Worker 
918*f6dc9357SAndroid Build Coastguard Worker inline bool operator!=(const UString2 &s1, const UString2 &s2) { return !(s1 == s2); }
919*f6dc9357SAndroid Build Coastguard Worker inline bool operator!=(const UString2 &s1, const wchar_t *s2) { return !(s1 == s2); }
920*f6dc9357SAndroid Build Coastguard Worker inline bool operator!=(const wchar_t *s1, const UString2 &s2) { return !(s1 == s2); }
921*f6dc9357SAndroid Build Coastguard Worker 
922*f6dc9357SAndroid Build Coastguard Worker 
923*f6dc9357SAndroid Build Coastguard Worker // ---------- forbidden functions ----------
924*f6dc9357SAndroid Build Coastguard Worker 
925*f6dc9357SAndroid Build Coastguard Worker void operator==(wchar_t c1, const UString2 &s2);
926*f6dc9357SAndroid Build Coastguard Worker void operator==(const UString2 &s1, wchar_t c2);
927*f6dc9357SAndroid Build Coastguard Worker bool operator<(const UString2 &s1, const UString2 &s2);
928*f6dc9357SAndroid Build Coastguard Worker bool operator>(const UString2 &s1, const UString2 &s2);
929*f6dc9357SAndroid Build Coastguard Worker 
930*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString2 &s1, const UString2 &s2);
931*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString2 &s1, const wchar_t *s2);
932*f6dc9357SAndroid Build Coastguard Worker void operator+(const wchar_t *s1, const UString2 &s2);
933*f6dc9357SAndroid Build Coastguard Worker void operator+(wchar_t c, const UString2 &s);
934*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString2 &s, wchar_t c);
935*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString2 &s, char c);
936*f6dc9357SAndroid Build Coastguard Worker void operator+(const UString2 &s, unsigned char c);
937*f6dc9357SAndroid Build Coastguard Worker void operator+(char c, const UString2 &s);
938*f6dc9357SAndroid Build Coastguard Worker void operator+(unsigned char c, const UString2 &s);
939*f6dc9357SAndroid Build Coastguard Worker void operator-(const UString2 &s1, wchar_t c);
940*f6dc9357SAndroid Build Coastguard Worker 
941*f6dc9357SAndroid Build Coastguard Worker 
942*f6dc9357SAndroid Build Coastguard Worker 
943*f6dc9357SAndroid Build Coastguard Worker 
944*f6dc9357SAndroid Build Coastguard Worker 
945*f6dc9357SAndroid Build Coastguard Worker 
946*f6dc9357SAndroid Build Coastguard Worker typedef CObjectVector<AString> AStringVector;
947*f6dc9357SAndroid Build Coastguard Worker typedef CObjectVector<UString> UStringVector;
948*f6dc9357SAndroid Build Coastguard Worker 
949*f6dc9357SAndroid Build Coastguard Worker #ifdef _UNICODE
950*f6dc9357SAndroid Build Coastguard Worker   typedef UString CSysString;
951*f6dc9357SAndroid Build Coastguard Worker #else
952*f6dc9357SAndroid Build Coastguard Worker   typedef AString CSysString;
953*f6dc9357SAndroid Build Coastguard Worker #endif
954*f6dc9357SAndroid Build Coastguard Worker 
955*f6dc9357SAndroid Build Coastguard Worker typedef CObjectVector<CSysString> CSysStringVector;
956*f6dc9357SAndroid Build Coastguard Worker 
957*f6dc9357SAndroid Build Coastguard Worker 
958*f6dc9357SAndroid Build Coastguard Worker // ---------- FString ----------
959*f6dc9357SAndroid Build Coastguard Worker 
960*f6dc9357SAndroid Build Coastguard Worker #ifndef DEBUG_FSTRING_INHERITS_ASTRING
961*f6dc9357SAndroid Build Coastguard Worker #ifdef _WIN32
962*f6dc9357SAndroid Build Coastguard Worker   #define USE_UNICODE_FSTRING
963*f6dc9357SAndroid Build Coastguard Worker #endif
964*f6dc9357SAndroid Build Coastguard Worker #endif
965*f6dc9357SAndroid Build Coastguard Worker 
966*f6dc9357SAndroid Build Coastguard Worker #ifdef USE_UNICODE_FSTRING
967*f6dc9357SAndroid Build Coastguard Worker 
968*f6dc9357SAndroid Build Coastguard Worker   #define MY_FTEXT(quote) L##quote
969*f6dc9357SAndroid Build Coastguard Worker 
970*f6dc9357SAndroid Build Coastguard Worker   typedef wchar_t FChar;
971*f6dc9357SAndroid Build Coastguard Worker   typedef UString FString;
972*f6dc9357SAndroid Build Coastguard Worker 
973*f6dc9357SAndroid Build Coastguard Worker   #define fs2us(_x_) (_x_)
974*f6dc9357SAndroid Build Coastguard Worker   #define us2fs(_x_) (_x_)
975*f6dc9357SAndroid Build Coastguard Worker   FString fas2fs(const char *s);
976*f6dc9357SAndroid Build Coastguard Worker   FString fas2fs(const AString &s);
977*f6dc9357SAndroid Build Coastguard Worker   AString fs2fas(const FChar *s);
978*f6dc9357SAndroid Build Coastguard Worker 
979*f6dc9357SAndroid Build Coastguard Worker #else // USE_UNICODE_FSTRING
980*f6dc9357SAndroid Build Coastguard Worker 
981*f6dc9357SAndroid Build Coastguard Worker   #define MY_FTEXT(quote) quote
982*f6dc9357SAndroid Build Coastguard Worker 
983*f6dc9357SAndroid Build Coastguard Worker   typedef char FChar;
984*f6dc9357SAndroid Build Coastguard Worker 
985*f6dc9357SAndroid Build Coastguard Worker  #ifdef DEBUG_FSTRING_INHERITS_ASTRING
986*f6dc9357SAndroid Build Coastguard Worker 
987*f6dc9357SAndroid Build Coastguard Worker   class FString: public AString
988*f6dc9357SAndroid Build Coastguard Worker   {
989*f6dc9357SAndroid Build Coastguard Worker     // FString &operator=(const char *s);
990*f6dc9357SAndroid Build Coastguard Worker     FString &operator=(const AString &s);
991*f6dc9357SAndroid Build Coastguard Worker     // FString &operator+=(const AString &s);
992*f6dc9357SAndroid Build Coastguard Worker   public:
FString(const AString & s)993*f6dc9357SAndroid Build Coastguard Worker     FString(const AString &s): AString(s.Ptr()) {}
FString(const FString & s)994*f6dc9357SAndroid Build Coastguard Worker     FString(const FString &s): AString(s.Ptr()) {}
FString(const char * s)995*f6dc9357SAndroid Build Coastguard Worker     FString(const char *s): AString(s) {}
FString()996*f6dc9357SAndroid Build Coastguard Worker     FString() {}
997*f6dc9357SAndroid Build Coastguard Worker     FString &operator=(const FString &s)  { AString::operator=((const AString &)s); return *this; }
998*f6dc9357SAndroid Build Coastguard Worker     FString &operator=(char c) { AString::operator=(c); return *this; }
999*f6dc9357SAndroid Build Coastguard Worker     FString &operator+=(char c) { AString::operator+=(c); return *this; }
1000*f6dc9357SAndroid Build Coastguard Worker     FString &operator+=(const FString &s) { AString::operator+=((const AString &)s); return *this; }
Left(unsigned count)1001*f6dc9357SAndroid Build Coastguard Worker     FString Left(unsigned count) const  { return FString(AString::Left(count)); }
1002*f6dc9357SAndroid Build Coastguard Worker   };
1003*f6dc9357SAndroid Build Coastguard Worker   void operator+(const AString &s1, const FString &s2);
1004*f6dc9357SAndroid Build Coastguard Worker   void operator+(const FString &s1, const AString &s2);
1005*f6dc9357SAndroid Build Coastguard Worker 
1006*f6dc9357SAndroid Build Coastguard Worker   inline FString operator+(const FString &s1, const FString &s2)
1007*f6dc9357SAndroid Build Coastguard Worker   {
1008*f6dc9357SAndroid Build Coastguard Worker     AString s =(const AString &)s1 + (const AString &)s2;
1009*f6dc9357SAndroid Build Coastguard Worker     return FString(s.Ptr());
1010*f6dc9357SAndroid Build Coastguard Worker     // return FString((const AString &)s1 + (const AString &)s2);
1011*f6dc9357SAndroid Build Coastguard Worker   }
1012*f6dc9357SAndroid Build Coastguard Worker   inline FString operator+(const FString &s1, const FChar *s2)
1013*f6dc9357SAndroid Build Coastguard Worker   {
1014*f6dc9357SAndroid Build Coastguard Worker     return s1 + (FString)s2;
1015*f6dc9357SAndroid Build Coastguard Worker   }
1016*f6dc9357SAndroid Build Coastguard Worker   /*
1017*f6dc9357SAndroid Build Coastguard Worker   inline FString operator+(const FChar *s1, const FString &s2)
1018*f6dc9357SAndroid Build Coastguard Worker   {
1019*f6dc9357SAndroid Build Coastguard Worker     return (FString)s1 + s2;
1020*f6dc9357SAndroid Build Coastguard Worker   }
1021*f6dc9357SAndroid Build Coastguard Worker   */
1022*f6dc9357SAndroid Build Coastguard Worker 
fas2fs(const char * s)1023*f6dc9357SAndroid Build Coastguard Worker   inline FString fas2fs(const char *s)  { return FString(s); }
1024*f6dc9357SAndroid Build Coastguard Worker 
1025*f6dc9357SAndroid Build Coastguard Worker  #else // DEBUG_FSTRING_INHERITS_ASTRING
1026*f6dc9357SAndroid Build Coastguard Worker   typedef AString FString;
1027*f6dc9357SAndroid Build Coastguard Worker   #define fas2fs(_x_) (_x_)
1028*f6dc9357SAndroid Build Coastguard Worker  #endif // DEBUG_FSTRING_INHERITS_ASTRING
1029*f6dc9357SAndroid Build Coastguard Worker 
1030*f6dc9357SAndroid Build Coastguard Worker   UString fs2us(const FChar *s);
1031*f6dc9357SAndroid Build Coastguard Worker   UString fs2us(const FString &s);
1032*f6dc9357SAndroid Build Coastguard Worker   FString us2fs(const wchar_t *s);
1033*f6dc9357SAndroid Build Coastguard Worker   #define fs2fas(_x_) (_x_)
1034*f6dc9357SAndroid Build Coastguard Worker 
1035*f6dc9357SAndroid Build Coastguard Worker #endif // USE_UNICODE_FSTRING
1036*f6dc9357SAndroid Build Coastguard Worker 
1037*f6dc9357SAndroid Build Coastguard Worker #define FTEXT(quote) MY_FTEXT(quote)
1038*f6dc9357SAndroid Build Coastguard Worker 
1039*f6dc9357SAndroid Build Coastguard Worker #define FCHAR_PATH_SEPARATOR FTEXT(CHAR_PATH_SEPARATOR)
1040*f6dc9357SAndroid Build Coastguard Worker #define FSTRING_PATH_SEPARATOR FTEXT(STRING_PATH_SEPARATOR)
1041*f6dc9357SAndroid Build Coastguard Worker 
1042*f6dc9357SAndroid Build Coastguard Worker // #define FCHAR_ANY_MASK FTEXT('*')
1043*f6dc9357SAndroid Build Coastguard Worker // #define FSTRING_ANY_MASK FTEXT("*")
1044*f6dc9357SAndroid Build Coastguard Worker 
1045*f6dc9357SAndroid Build Coastguard Worker typedef const FChar *CFSTR;
1046*f6dc9357SAndroid Build Coastguard Worker 
1047*f6dc9357SAndroid Build Coastguard Worker typedef CObjectVector<FString> FStringVector;
1048*f6dc9357SAndroid Build Coastguard Worker 
1049*f6dc9357SAndroid Build Coastguard Worker 
1050*f6dc9357SAndroid Build Coastguard Worker class CStringFinder
1051*f6dc9357SAndroid Build Coastguard Worker {
1052*f6dc9357SAndroid Build Coastguard Worker   AString _temp;
1053*f6dc9357SAndroid Build Coastguard Worker public:
1054*f6dc9357SAndroid Build Coastguard Worker   // list - is list of low case Ascii strings separated by space " ".
1055*f6dc9357SAndroid Build Coastguard Worker   // the function returns true, if it can find exact word (str) in (list).
1056*f6dc9357SAndroid Build Coastguard Worker   bool FindWord_In_LowCaseAsciiList_NoCase(const char *list, const wchar_t *str);
1057*f6dc9357SAndroid Build Coastguard Worker };
1058*f6dc9357SAndroid Build Coastguard Worker 
1059*f6dc9357SAndroid Build Coastguard Worker void SplitString(const UString &srcString, UStringVector &destStrings);
1060*f6dc9357SAndroid Build Coastguard Worker 
1061*f6dc9357SAndroid Build Coastguard Worker #endif
1062*f6dc9357SAndroid Build Coastguard Worker 
1063*f6dc9357SAndroid Build Coastguard Worker 
1064*f6dc9357SAndroid Build Coastguard Worker 
1065*f6dc9357SAndroid Build Coastguard Worker #if defined(_WIN32)
1066*f6dc9357SAndroid Build Coastguard Worker   // #include <wchar.h>
1067*f6dc9357SAndroid Build Coastguard Worker   // WCHAR_MAX is defined as ((wchar_t)-1)
1068*f6dc9357SAndroid Build Coastguard Worker   #define Z7_WCHART_IS_16BIT 1
1069*f6dc9357SAndroid Build Coastguard Worker #elif (defined(WCHAR_MAX) && (WCHAR_MAX <= 0xffff)) \
1070*f6dc9357SAndroid Build Coastguard Worker    || (defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ == 2))
1071*f6dc9357SAndroid Build Coastguard Worker   #define Z7_WCHART_IS_16BIT 1
1072*f6dc9357SAndroid Build Coastguard Worker #endif
1073*f6dc9357SAndroid Build Coastguard Worker 
1074*f6dc9357SAndroid Build Coastguard Worker #if WCHAR_PATH_SEPARATOR == L'\\'
1075*f6dc9357SAndroid Build Coastguard Worker // WSL scheme
1076*f6dc9357SAndroid Build Coastguard Worker #define WCHAR_IN_FILE_NAME_BACKSLASH_REPLACEMENT  ((wchar_t)((unsigned)(0xF000) + (unsigned)'\\'))
1077*f6dc9357SAndroid Build Coastguard Worker // #define WCHAR_IN_FILE_NAME_BACKSLASH_REPLACEMENT  '_'
1078*f6dc9357SAndroid Build Coastguard Worker #endif
1079