Go to the documentation of this file.
40 class CFX_ByteStringL;
41 class CFX_WideStringL;
74 #ifndef _NO_LPCSTR_SUPPORT_
121 m_Length = src.m_Length;
153 m_Length = src.m_Length;
174 return str.m_Length == m_Length &&
FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) == 0;
185 return str.m_Length != m_Length ||
FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) != 0;
189 #define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4))
233 bool IsEmpty()
const {
return m_Length == 0; }
265 if (index < 0) index = 0;
267 if (count < 0 || count > m_Length - index) count = m_Length - index;
281 void*
operator new (size_t)
throw() {
return NULL; }
296 #define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str-1)
447 #ifndef _NO_LPCSTR_SUPPORT_
477 #ifndef _NO_LPCSTR_SUPPORT_
891 #define FXFORMAT_SIGNED 1
893 #define FXFORMAT_HEX 2
895 #define FXFORMAT_CAPITAL 4
942 void CopyBeforeWrite();
982 #ifndef _NO_LPCSTR_SUPPORT_
1052 #ifndef _NO_LPCSTR_SUPPORT_
1186 template<FX_STRSIZE limit>
1226 #ifndef _NO_LPCSTR_SUPPORT_
1273 m_Length = src.m_Length;
1305 m_Length = src.m_Length;
1378 if (count > m_Length) count = m_Length;
1392 if (index < 0) index = 0;
1394 if (count < 0 || count > m_Length - index) count = m_Length - index;
1408 if (count > m_Length) count = m_Length;
1422 void*
operator new (size_t)
throw() {
return NULL; }
1437 #define FX_WSTRC(wstr) CFX_WideStringC((FX_LPCWSTR)wstr, sizeof(wstr) / sizeof(FX_WCHAR) - 1)
1965 void CopyBeforeWrite();
2010 #ifndef _NO_LPCSTR_SUPPORT_
2076 #ifndef _NO_LPCSTR_SUPPORT_
2301 #define FXWCHAR_LTR 0
2303 #define FXWCHAR_RTL 1
2305 #define FXWCHAR_UNKNOWN 2
2370 return ((first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00);
2387 const FX_DWORD mask = (1 << 10) - 1;
2388 return (((first & mask) << 10) | (second & mask)) + 0x10000;
2411 if (unicode < 0x10000 || unicode > 0x10FFFF)
2415 first = (
FX_WCHAR)(0xD800 - (0x10000 >> 10) + ((unicode) >> 10));
2417 second = (
FX_WCHAR)(0xDC00 + ((unicode)&0x3FF));
2430 ~CFX_ByteStringL() {}
2446 ~CFX_WideStringL() {}
2452 int GetInteger()
const;
2462 #endif // _FX_STRING_H_
bool Equal(const CFX_WideStringC &str) const
Check if current string is equal to another.
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:665
FX_BYTE GetAt(FX_STRSIZE nIndex) const
Get a single byte specified by an index number.
Definition: fx_string.h:606
FX_LPSTR GetBuffer(FX_STRSIZE len)
Get a buffer with specific number of bytes allocated.
FX_LPWSTR GetBuffer(FX_STRSIZE len)
Get a buffer with specific number of characters allocated.
FX_STRSIZE GetLength() const
Get number of bytes in the byte string (not counting any possible terminator).
Definition: fx_string.h:402
FX_LPCSTR GetCStr() const
Get a constant character string pointer to the byte string.
Definition: fx_string.h:221
void MakeUpper()
Change case of English letters to upper.
void ConvertFrom(const CFX_ByteString &str, CFX_CharMap *pCharMap=NULL)
Load MBCS data into this wide string, using specified character mapper.
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:726
FX_STRSIZE m_nAllocLength
Length of allocation.
Definition: fx_string.h:1450
CFX_ByteStringC(FX_LPCBYTE ptr, FX_STRSIZE size)
Constructs from a byte string.
Definition: fx_string.h:68
bool operator<(const CFX_ByteString &rhs) const
Comparison(<) operator overload. case-sensitive.
CFX_WideStringC Right(FX_STRSIZE count) const
Extracts the last (rightmost) count wide characters from this CFX_WideStringC object as a sub-string.
Definition: fx_string.h:1405
FX_INT32 FXSYS_memcmp32(const void *buf1, const void *buf2, size_t size)
Compare data in two buffers.
FX_STRSIZE Find(FX_BSTR lpszSub, FX_STRSIZE start=0) const
Find a sub-string, from specific position. Only first occurrence is found.
FX_STRSIZE m_nAllocLength
Length of allocation.
Definition: fx_string.h:309
bool IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:233
void MakeUpper()
Change case of English letters to upper.
CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count=-1) const
This method extracts a substring of length count bytes from this CFX_ByteStringC object,...
Definition: fx_string.h:263
bool operator!=(const CFX_WideStringC &str) const
Comparison(!=) operator overload. Case-sensitive.
Definition: fx_string.h:1335
void FormatV(FX_LPCWSTR lpszFormat, va_list argList)
Format a number of parameters into this wide string. using va_list.
FX_STRSIZE m_nDataLength
Length of data (excluding terminator).
Definition: fx_string.h:1448
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:732
bool operator!=(const CFX_ByteStringC &str) const
Comparison(!=) operator overload. case-sensitive.
Definition: fx_string.h:183
bool operator==(FX_LPCSTR str) const
Comparison(==) operator overload. case-sensitive.
Definition: fx_string.h:456
FX_STRSIZE Remove(FX_WCHAR ch)
Remove all occurrence of a particular character.
CFX_ByteStringC GetStringC() const
Get a non-buffered byte string.
Definition: fx_string.h:1167
void Copy(FX_BSTR str)
Copy from a non-buffered byte string.
const CFX_ByteString & operator=(FX_LPCSTR str)
Assignment(=) operator overload. From a character string.
CFX_WideStringC(FX_WCHAR &ch)
Construct from a single character.
Definition: fx_string.h:1246
FX_STRSIZE GetSize() const
Gets the length of the string.
Definition: fx_string.h:1123
bool operator==(const CFX_ByteStringC &str) const
Comparison(==) operator overload. case-sensitive.
Definition: fx_string.h:172
FX_WCHAR FXWCHAR_GetUpper(FX_WCHAR wchar)
Convert to upper-case letter.
CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count=-1) const
Extracts a substring of length count bytes from this CFX_WideStringC object, starting at position ind...
Definition: fx_string.h:1390
int Compare(FX_LPCWSTR str) const
Compare current string with a wide character string. Case-sensitive.
CFX_StringBufTemplate()
A constructor.
Definition: fx_string.h:1193
void Empty()
Set this string to be empty.
Definition: fx_string.h:1130
CFX_ByteString Left(FX_STRSIZE count) const
Extracts the first (leftmost) count bytes from this CFX_ByteString object as a sub-string.
int Compare(FX_BSTR str) const
Compare the the string with another. Case-sensitive.
static CFX_ByteString FormatFloat(FX_FLOAT f, int precision=0)
Convert from floating-point number.
#define FXSYS_strlen
Get the length of a ANSIC string.
Definition: fx_system.h:879
void Reserve(FX_STRSIZE len)
Reserve a buffer that can hold specific number of bytes.
FX_LPWSTR LockBuffer()
Lock and get the current string buffer, so the caller can modify the returned buffer....
void Format(FX_LPCSTR lpszFormat,...)
Format a number of parameters into this byte string.
void * FXSYS_memset32(void *dst, FX_INT32 v, size_t size)
Set buffer data to specified value.
int FX_STRSIZE
String size is limited to 2^31-1.
Definition: fx_string.h:35
FX_BOOL IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:1570
CFX_ByteStringC(const FX_CHAR &ch)
Construct from a single character.
Definition: fx_string.h:94
FX_BOOL FXWCHAR_IsWordBreak(FX_WCHAR wchar)
Check if the unicode can break a word.
~CFX_WideString()
The Destructor.
static CFX_WideString FromLocal(const char *str, FX_STRSIZE len=-1)
Create a wide string from system multi-byte charset.
void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch)
Overwrites a single wide character specified by an index number.
CONSTANT WIDE STRING CLASS.
Definition: fx_string.h:1214
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf, int precision=0)
Convert float to byte string.
FX_STRSIZE Remove(FX_CHAR ch)
Remove all occurrence of a particular character.
char FX_CHAR
8-bit Windows (ANSI) character.
Definition: fx_system.h:701
void FX_atonum(FX_BSTR str, FX_BOOL &bInteger, void *pData, int sizeOfData=4)
Convert a non-buffered byte string to a number.
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count=1)
Delete one or more wide characters starting from specific position.
FX_BOOL FX_IsUtf16SurrogatePair(FX_WCHAR first, FX_WCHAR second)
Determines if the arguments constitute UTF-16 surrogate pair.
Definition: fx_string.h:2368
CFX_ByteString()
Construct a null byte string.
Definition: fx_string.h:323
CFX_ByteStringC()
Constructs a null constant string.
Definition: fx_string.h:57
void ConvertFrom(const CFX_WideString &str, CFX_CharMap *pCharMap=NULL)
Load unicode data into this byte string, using specified character mapper. If no character mapper spe...
void TrimRight()
Trim white spaces from the right side of the byte string.
bool Equal(FX_BSTR str) const
Check if current string is equal to another one. Case-sensitive.
int GetInteger() const
Convert to other data type.
long m_nRefs
Reference count.
Definition: fx_string.h:1446
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:734
const CFX_WideString & operator=(FX_LPCWSTR str)
Assignment(=) operator overload. From a wide character string.
FX_WCHAR GetAt(FX_STRSIZE nIndex) const
Retrieves a single wide character specified by an index number.
Definition: fx_string.h:1646
CFX_WideStringC(const CFX_WideStringC &src)
Copy constructor.
Definition: fx_string.h:1270
This class represents the data of a byte string object.
Definition: fx_string.h:302
char * FX_LPSTR
Pointer to 8-bit Windows (ANSI) characters.
Definition: fx_system.h:703
void TrimRight()
Trim white spaces from the right side of the wide string.
const CFX_ByteString & operator+=(FX_CHAR ch)
Concatenation(+=) operator overload. Concatenate a single character.
void Empty()
Set this string to be empty.
void Empty()
Set this string to be empty.
FX_STRSIZE ReverseFind(FX_CHAR ch) const
Find a character from end of the string.
#define FXSYS_wcslen
Get the length of a wide-character string.
Definition: fx_system.h:1028
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:683
This class represents the data of a wide string object.
Definition: fx_string.h:1443
bool operator==(const CFX_WideString &s1, const CFX_WideString &s2)
Comparison(==) operator overload. Case-sensitive.
int CompareNoCase(FX_LPCWSTR str) const
Compare the the string with a wide character string. No case-insensitive.
bool EqualNoCase(FX_BSTR str) const
Check if current string is equal to another one, not considering case.
BYTE STRING CLASS.
Definition: fx_string.h:317
FX_DWORD FX_CreateCodePointFromUtf16SurrogatePair(FX_WCHAR first, FX_WCHAR second)
Creates a Unicode code point from UTF16 surrogate pair.
Definition: fx_string.h:2384
FX_BYTE GetAt(FX_STRSIZE index) const
This method retrieves a single byte specified by an index number.
Definition: fx_string.h:252
FX_WCHAR operator[](FX_STRSIZE nIndex) const
Subscript([]) operator overload. It retrieves a wide character specified by the zero-based index in n...
Definition: fx_string.h:1654
Foxit allocator interface.
Definition: fx_memory.h:997
CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len)
Encode a wide string into a UTF-8 string.
CFX_StringBufBase(FX_STRSIZE limit)
A Constructor.
Definition: fx_string.h:1110
FX_DWORD GetID(FX_STRSIZE start_pos=0) const
Get a DWORD identifier of the string. See function CFX_ByteStringC::GetID for details.
FX_BOOL FX_CreateUtf16SurrogatePairFromCodePoint(FX_DWORD unicode, FX_WCHAR &first, FX_WCHAR &second)
Creates UTF16 surrogate pair from a Unicode code point.
Definition: fx_string.h:2406
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:736
bool IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:409
CFX_ByteString UTF8Encode() const
Do UTF8 encoding.
FX_BOOL FXWCHAR_IsSpace(FX_WCHAR wchar)
Check if the unicode is space.
CFX_WideString()
Construct a null wide string.
Definition: fx_string.h:1467
bool operator<(const CFX_WideString &lhs, const CFX_WideString &rhs)
Comparison(<) operator overload. Case-sensitive.
CFX_WideStringC & operator=(FX_LPCWSTR src)
Assignment(=) operator overload. From a character string.
Definition: fx_string.h:1289
FX_FLOAT GetFloat() const
Convert to other data type.
FX_DWORD GetID(FX_STRSIZE start_pos=0) const
Get a DWORD identifier of the string, from a particular position.
A fixed string buffer holding up to certain number of characters.
Definition: fx_string.h:1102
FX_LPCBYTE GetPtr() const
Get a constant byte string pointer to the byte string.
Definition: fx_string.h:215
CFX_WideStringC Left(FX_STRSIZE count) const
Extracts the first (leftmost) count wide characters from this CFX_WideStringC object as a sub-string.
Definition: fx_string.h:1375
CFX_ByteString operator+(FX_BSTR str1, FX_BSTR str2)
Concatenate a non-buffered byte string and a non-buffered byte string.
Definition: fx_string.h:980
CFX_ByteStringC(FX_LPCSTR ptr)
Construct from a character string.
Definition: fx_string.h:81
CFX_ByteString UTF16LE_Encode(FX_BOOL bTerminate=true) const
Do UTF16LE encoding.
Definition: fx_basic.h:956
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:705
FX_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:1351
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:669
FX_WCHAR FXWCHAR_GetLower(FX_WCHAR wchar)
Convert to lower-case letter.
void Reserve(FX_STRSIZE len)
Reserve a buffer that can hold specific number of characters.
static CFX_ByteString FormatInteger(FX_INT32 i, FX_DWORD flags=0)
Convert from Integer.
Dynamic binary buffers designed for more efficient appending.
Definition: fx_basic.h:52
long m_nRefs
Reference count.
Definition: fx_string.h:305
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:685
void MakeLower()
Change case of English letters to lower.
FX_CHAR m_Buffer[limit]
The fixed string buffer.
Definition: fx_string.h:1200
CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len=-1)
Construct from a wide character string.
Definition: fx_string.h:1480
const typedef CFX_ByteStringC & FX_BSTR
A reference to a constant CFX_ByteStringC object.
Definition: fx_string.h:285
FX_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:227
int FXWCHAR_GetDirection(FX_WCHAR wchar)
Get text direction.
void MakeLower()
Change case of English letters to lower.
CFX_WideStringC()
Constructs a null constant string.
Definition: fx_string.h:1220
FX_CHAR m_String[1]
Real data (actually a variable-sized array).
Definition: fx_string.h:311
#define NULL
The null-pointer value.
Definition: fx_system.h:792
static CFX_ByteString FormatInteger64(FX_INT64 i)
Convert from Integer64.
CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
Construct from a character string.
Definition: fx_string.h:1257
CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len)
Construct from a character string.
Definition: fx_string.h:105
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:691
CFX_ByteStringC(const CFX_ByteStringC &src)
Copy constructor.
Definition: fx_string.h:118
const CFX_WideString & operator+=(FX_LPCWSTR str)
Concatenation(+=) operator overload. Concatenate a wide character string.
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count=1)
Delete one or more characters starting from specific position.
const typedef CFX_WideStringC & FX_WSTR
Type definition for a reference to a constant CFX_WideStringC object.
Definition: fx_string.h:1426
bool operator!=(FX_LPCSTR str) const
Comparison(!=) operator overload. case-sensitive.
Definition: fx_string.h:486
FX_BYTE operator[](FX_STRSIZE nIndex) const
Subscript([]) operator overload. It retrieves a single byte specified by the zero-based index in nInd...
Definition: fx_string.h:614
FX_STRSIZE Find(FX_LPCWSTR lpszSub, FX_STRSIZE start=0) const
Find a sub-string, from specific position. Only first occurrence is found.
bool IsEmpty() const
Determines whether current string object is empty.
Definition: fx_string.h:1357
FX_WCHAR GetAt(FX_STRSIZE index) const
Retrieves a single byte specified by an index number.
Definition: fx_string.h:1366
CFX_WideStringC(FX_LPCWSTR ptr)
Construct from a character string.
Definition: fx_string.h:1233
void ReleaseBuffer(FX_STRSIZE len=-1)
Release the buffer fetched by function CFX_WideString::GetBuffer or CFX_WideString::LockBuffer,...
FX_LPCWSTR GetPtr() const
Get a constant wide string pointer to the wide string.
Definition: fx_string.h:1345
void SetAt(FX_STRSIZE nIndex, FX_CHAR ch)
Overwrites a single byte specified by an index number.
bool operator!=(const CFX_WideString &s1, const CFX_WideString &s2)
Comparison(!=) operator overload. Case-sensitive.
void TrimLeft()
Trim white spaces from the left side of the byte string.
void FormatV(FX_LPCSTR lpszFormat, va_list argList)
Format a number of parameters into this byte string, using va_list.
FX_STRSIZE GetLength() const
Get number of characters, not bytes. Trailing zero not counted.
Definition: fx_string.h:1577
bool operator==(const CFX_WideStringC &str) const
Comparison(==) operator overload. Case-sensitive.
Definition: fx_string.h:1324
FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch)
Insert a wide character before specific position.
FX_CHAR * GetPtr() const
Get a C-style string pointer to the string buffer.
Definition: fx_string.h:1117
static CFX_WideString FromUTF16LE(const unsigned short *str, FX_STRSIZE len=-1)
Create a wide string from UTF16LE encoded string.
void ReleaseBuffer(FX_STRSIZE len=-1)
Release the buffer fetched by function CFX_ByteString::GetBuffer or CFX_ByteString::LockBuffer,...
FX_FLOAT FX_atof(FX_BSTR str)
Convert a non-buffered byte string to a floating-point number.
FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch)
Insert a character before specific position.
CFX_ByteString GetString() const
Get a buffered byte string.
Definition: fx_string.h:1173
CFX_WideString Left(FX_STRSIZE count) const
Extracts the first (leftmost) count wide characters from this CFX_WideString object as a sub-string.
static CFX_ByteString FromUnicode(FX_LPCWSTR ptr, FX_STRSIZE len=-1)
Create a CFX_ByteString object from a Unicode string. Convert from Unicode to system multi-byte chars...
CFX_WideString Mid(FX_STRSIZE first) const
Extracts a substring from this CFX_WideString object, starting at position nFirst (zero-based) to las...
FX_WCHAR m_String[1]
Real data (actually a variable-sized array).
Definition: fx_string.h:1452
static CFX_WideString FromUTF8(const char *str, FX_STRSIZE len=-1)
Create a wide string from UTF-8 string (ASCII string compatible).
void Format(FX_LPCWSTR lpszFormat,...)
Format a number of parameters into this wide string.
CFX_ByteStringC & operator=(FX_LPCSTR src)
Assignment(=) operator overload. From a character string.
Definition: fx_string.h:137
WIDE STRING CLASS.
Definition: fx_string.h:1461
void TrimLeft()
Trim white spaces from the left side of the wide string.
A fixed string buffer template.
Definition: fx_string.h:1187
CFX_ByteString Right(FX_STRSIZE count) const
Extracts the last (rightmost) count bytes from this CFX_ByteString object as a sub-string.
CFX_WideString Right(FX_STRSIZE count) const
Extracts the last (rightmost) count wide characters from this CFX_WideString object as a sub-string.
CFX_WideString UTF8Decode() const
Decode a UTF-8 unicode string (assume this byte string is UTF-8 encoded).
static CFX_ByteString LoadFromFile(FX_BSTR file_path)
Load the whole content of a file.
FX_LPSTR LockBuffer()
Lock and get the current string buffer, so the caller can modify the returned buffer.
void Load(FX_LPCBYTE str, FX_STRSIZE len)
Load from a byte string.
CONSTANT BYTE STRING CLASS.
Definition: fx_string.h:51
static CFX_WideString FromUTF16BE(const unsigned short *str, FX_STRSIZE len=-1)
Create a wide string from UTF16BE encoded string.
static FX_STRSIZE WStringLength(const unsigned short *str)
Length of string.
CFX_ByteString Mid(FX_STRSIZE first) const
Extracts a substring from this CFX_ByteString object, starting at position nFirst (zero-based) to las...
CFX_StringBufTemplate< 256 > CFX_StringBuf256
A fixed 256-byte string buffer.
Definition: fx_string.h:1204
FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew)
Replace all patterns in the string with a new sub-string.
FX_STRSIZE m_nDataLength
Length of data (excluding terminator).
Definition: fx_string.h:307
FX_STRSIZE Replace(FX_BSTR lpszOld, FX_BSTR lpszNew)
Replace all patterns in the string with a new sub-string.
void Append(FX_BSTR str)
Append a non-buffered byte string.
@2024 Foxit Software Incorporated. All rights reserved.