Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
widestring.h
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef CORE_FXCRT_WIDESTRING_H_
8#define CORE_FXCRT_WIDESTRING_H_
9
10#include <stdarg.h>
11#include <stddef.h>
12#include <stdint.h>
13#include <wchar.h>
14
15#include <functional>
16#include <iosfwd>
17#include <iterator>
18#include <utility>
19
20#include "core/fxcrt/retain_ptr.h"
21#include "core/fxcrt/string_data_template.h"
22#include "core/fxcrt/string_view_template.h"
23#include "third_party/abseil-cpp/absl/types/optional.h"
24#include "third_party/base/check.h"
25#include "third_party/base/containers/span.h"
26
27namespace fxcrt {
28
29class ByteString;
30
31// A mutable string with shared buffers using copy-on-write semantics that
32// avoids the cost of std::string's iterator stability guarantees.
34 public:
35 // TODO(crbug.com/pdfium/2031): Consider switching to `char16_t` instead.
36 using CharType = wchar_t;
37 using const_iterator = const CharType*;
38 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
39
40 [[nodiscard]] static WideString FormatInteger(int i);
41 [[nodiscard]] static WideString Format(const wchar_t* pFormat, ...);
42 [[nodiscard]] static WideString FormatV(const wchar_t* lpszFormat,
43 va_list argList);
44
46 WideString(const WideString& other);
47
48 // Move-construct a WideString. After construction, |other| is empty.
49 WideString(WideString&& other) noexcept;
50
51 // Make a one-character string from one wide char.
52 explicit WideString(wchar_t ch);
53
54 // Deliberately implicit to avoid calling on every string literal.
55 // NOLINTNEXTLINE(runtime/explicit)
56 WideString(const wchar_t* ptr);
57
58 // No implicit conversions from byte strings.
59 // NOLINTNEXTLINE(runtime/explicit)
60 WideString(char) = delete;
61
62 WideString(const wchar_t* pStr, size_t len);
63
64 explicit WideString(WideStringView str);
65 WideString(WideStringView str1, WideStringView str2);
66 WideString(const std::initializer_list<WideStringView>& list);
67
69
70 [[nodiscard]] static WideString FromASCII(ByteStringView str);
71 [[nodiscard]] static WideString FromLatin1(ByteStringView str);
72 [[nodiscard]] static WideString FromDefANSI(ByteStringView str);
73 [[nodiscard]] static WideString FromUTF8(ByteStringView str);
74 [[nodiscard]] static WideString FromUTF16LE(pdfium::span<const uint8_t> data);
75 [[nodiscard]] static WideString FromUTF16BE(pdfium::span<const uint8_t> data);
76
77 [[nodiscard]] static size_t WStringLength(const unsigned short* str);
78
79 // Explicit conversion to C-style wide string.
80 // Note: Any subsequent modification of |this| will invalidate the result.
81 const wchar_t* c_str() const { return m_pData ? m_pData->m_String : L""; }
82
83 // Explicit conversion to WideStringView.
84 // Note: Any subsequent modification of |this| will invalidate the result.
85 WideStringView AsStringView() const {
86 return WideStringView(c_str(), GetLength());
87 }
88
89 // Explicit conversion to span.
90 // Note: Any subsequent modification of |this| will invalidate the result.
91 pdfium::span<const wchar_t> span() const {
92 return pdfium::make_span(m_pData ? m_pData->m_String : nullptr,
93 GetLength());
94 }
95
96 // Note: Any subsequent modification of |this| will invalidate iterators.
97 const_iterator begin() const { return m_pData ? m_pData->m_String : nullptr; }
98 const_iterator end() const {
99 return m_pData ? m_pData->m_String + m_pData->m_nDataLength : nullptr;
100 }
101
102 // Note: Any subsequent modification of |this| will invalidate iterators.
103 const_reverse_iterator rbegin() const {
104 return const_reverse_iterator(end());
105 }
106 const_reverse_iterator rend() const {
107 return const_reverse_iterator(begin());
108 }
109
110 // Holds on to buffer if possible for later re-use. Assign WideString()
111 // to force immediate release if desired.
112 void clear();
113
114 size_t GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
116 return m_pData ? wcslen(m_pData->m_String) : 0;
117 }
118 bool IsEmpty() const { return !GetLength(); }
119 bool IsValidIndex(size_t index) const { return index < GetLength(); }
120 bool IsValidLength(size_t length) const { return length <= GetLength(); }
121
122 WideString& operator=(const wchar_t* str);
123 WideString& operator=(WideStringView str);
124 WideString& operator=(const WideString& that);
125
126 // Move-assign a WideString. After assignment, |that| is empty.
127 WideString& operator=(WideString&& that) noexcept;
128
129 WideString& operator+=(const wchar_t* str);
130 WideString& operator+=(wchar_t ch);
131 WideString& operator+=(const WideString& str);
132 WideString& operator+=(WideStringView str);
133
134 bool operator==(const wchar_t* ptr) const;
135 bool operator==(WideStringView str) const;
136 bool operator==(const WideString& other) const;
137
138 bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
139 bool operator!=(WideStringView str) const { return !(*this == str); }
140 bool operator!=(const WideString& other) const { return !(*this == other); }
141
142 bool operator<(const wchar_t* ptr) const;
143 bool operator<(WideStringView str) const;
144 bool operator<(const WideString& other) const;
145
146 CharType operator[](const size_t index) const {
147 CHECK(IsValidIndex(index));
148 return m_pData->m_String[index];
149 }
150
151 CharType Front() const { return GetLength() ? (*this)[0] : 0; }
152 CharType Back() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
153
154 void SetAt(size_t index, wchar_t c);
155
156 int Compare(const wchar_t* str) const;
157 int Compare(const WideString& str) const;
158 int CompareNoCase(const wchar_t* str) const;
159
160 WideString Substr(size_t offset) const;
161 WideString Substr(size_t first, size_t count) const;
162 WideString First(size_t count) const;
163 WideString Last(size_t count) const;
164
165 size_t Insert(size_t index, wchar_t ch);
166 size_t InsertAtFront(wchar_t ch) { return Insert(0, ch); }
167 size_t InsertAtBack(wchar_t ch) { return Insert(GetLength(), ch); }
168 size_t Delete(size_t index, size_t count = 1);
169
170 void MakeLower();
171 void MakeUpper();
172
173 void Trim();
174 void Trim(wchar_t target);
175 void Trim(WideStringView targets);
176
177 void TrimLeft();
178 void TrimLeft(wchar_t target);
179 void TrimLeft(WideStringView targets);
180
181 void TrimRight();
182 void TrimRight(wchar_t target);
183 void TrimRight(WideStringView targets);
184
185 void Reserve(size_t len);
186
187 // Increase the backing store of the string so that it is capable of storing
188 // at least `nMinBufLength` wchars. Returns a span to the entire buffer,
189 // which may be larger than `nMinBufLength` due to rounding by allocators.
190 // Note: any modification of the string (including ReleaseBuffer()) may
191 // invalidate the span, which must not outlive its buffer.
192 pdfium::span<wchar_t> GetBuffer(size_t nMinBufLength);
193
194 // Sets the size of the string to `nNewLength` wchars. Call this after a call
195 // to GetBuffer(), to indicate how much of the buffer was actually used.
196 void ReleaseBuffer(size_t nNewLength);
197
198 int GetInteger() const;
199
200 absl::optional<size_t> Find(WideStringView subStr, size_t start = 0) const;
201 absl::optional<size_t> Find(wchar_t ch, size_t start = 0) const;
202 absl::optional<size_t> ReverseFind(wchar_t ch) const;
203
204 bool Contains(WideStringView lpszSub, size_t start = 0) const {
205 return Find(lpszSub, start).has_value();
206 }
207
208 bool Contains(char ch, size_t start = 0) const {
209 return Find(ch, start).has_value();
210 }
211
212 size_t Replace(WideStringView pOld, WideStringView pNew);
213 size_t Remove(wchar_t ch);
214
215 bool IsASCII() const { return AsStringView().IsASCII(); }
216 bool EqualsASCII(ByteStringView that) const {
217 return AsStringView().EqualsASCII(that);
218 }
219 bool EqualsASCIINoCase(ByteStringView that) const {
220 return AsStringView().EqualsASCIINoCase(that);
221 }
222
223 ByteString ToASCII() const;
224 ByteString ToLatin1() const;
225 ByteString ToDefANSI() const;
226 ByteString ToUTF8() const;
227
228 // This method will add \0\0 to the end of the string to represent the
229 // wide string terminator. These values are in the string, not just the data,
230 // so GetLength() will include them.
231 ByteString ToUTF16LE() const;
232
233 // Replace the characters &<>'" with HTML entities.
235
236 protected:
237 using StringData = StringDataTemplate<wchar_t>;
238
239 void ReallocBeforeWrite(size_t nNewLength);
240 void AllocBeforeWrite(size_t nNewLength);
241 void AllocCopy(WideString& dest, size_t nCopyLen, size_t nCopyIndex) const;
242 void AssignCopy(const wchar_t* pSrcData, size_t nSrcLen);
243 void Concat(const wchar_t* pSrcData, size_t nSrcLen);
244 intptr_t ReferenceCountForTesting() const;
245
246 RetainPtr<StringData> m_pData;
247
248 friend class WideString_Assign_Test;
249 friend class WideString_ConcatInPlace_Test;
250 friend class WideString_Construct_Test;
251 friend class StringPool_WideString_Test;
252};
253
254inline WideString operator+(WideStringView str1, WideStringView str2) {
255 return WideString(str1, str2);
256}
257inline WideString operator+(WideStringView str1, const wchar_t* str2) {
258 return WideString(str1, str2);
259}
260inline WideString operator+(const wchar_t* str1, WideStringView str2) {
261 return WideString(str1, str2);
262}
263inline WideString operator+(WideStringView str1, wchar_t ch) {
264 return WideString(str1, WideStringView(ch));
265}
266inline WideString operator+(wchar_t ch, WideStringView str2) {
267 return WideString(WideStringView(ch), str2);
268}
269inline WideString operator+(const WideString& str1, const WideString& str2) {
270 return WideString(str1.AsStringView(), str2.AsStringView());
271}
272inline WideString operator+(const WideString& str1, wchar_t ch) {
273 return WideString(str1.AsStringView(), WideStringView(ch));
274}
275inline WideString operator+(wchar_t ch, const WideString& str2) {
276 return WideString(WideStringView(ch), str2.AsStringView());
277}
278inline WideString operator+(const WideString& str1, const wchar_t* str2) {
279 return WideString(str1.AsStringView(), str2);
280}
281inline WideString operator+(const wchar_t* str1, const WideString& str2) {
282 return WideString(str1, str2.AsStringView());
283}
284inline WideString operator+(const WideString& str1, WideStringView str2) {
285 return WideString(str1.AsStringView(), str2);
286}
287inline WideString operator+(WideStringView str1, const WideString& str2) {
288 return WideString(str1, str2.AsStringView());
289}
290inline bool operator==(const wchar_t* lhs, const WideString& rhs) {
291 return rhs == lhs;
292}
293inline bool operator==(WideStringView lhs, const WideString& rhs) {
294 return rhs == lhs;
295}
296inline bool operator!=(const wchar_t* lhs, const WideString& rhs) {
297 return rhs != lhs;
298}
299inline bool operator!=(WideStringView lhs, const WideString& rhs) {
300 return rhs != lhs;
301}
302inline bool operator<(const wchar_t* lhs, const WideString& rhs) {
303 return rhs.Compare(lhs) > 0;
304}
305
306std::wostream& operator<<(std::wostream& os, const WideString& str);
307std::ostream& operator<<(std::ostream& os, const WideString& str);
308std::wostream& operator<<(std::wostream& os, WideStringView str);
309std::ostream& operator<<(std::ostream& os, WideStringView str);
310
311// This is declared here for use in gtest-based tests but is defined in a test
312// support target. This should not be used in production code. Just use
313// operator<< from above instead.
314// In some cases, gtest will automatically use operator<< as well, but in this
315// case, it needs PrintTo() because WideString looks like a container to gtest.
316void PrintTo(const WideString& str, std::ostream* os);
317
318} // namespace fxcrt
319
320using WideString = fxcrt::WideString;
321
322uint32_t FX_HashCode_GetW(WideStringView str);
323uint32_t FX_HashCode_GetLoweredW(WideStringView str);
324
325namespace std {
326
327template <>
328struct hash<WideString> {
329 size_t operator()(const WideString& str) const {
330 return FX_HashCode_GetW(str.AsStringView());
331 }
332};
333
334} // namespace std
335
336extern template struct std::hash<WideString>;
337
338#endif // CORE_FXCRT_WIDESTRING_H_
uint32_t FX_HashCode_GetLoweredAsIfW(ByteStringView str)
uint32_t FX_HashCode_GetLoweredA(ByteStringView str)
uint32_t FX_HashCode_GetAsIfW(ByteStringView str)
uint32_t FX_HashCode_GetA(ByteStringView str)
CPDF_ArrayLocker(RetainPtr< CPDF_Array > pArray)
const_iterator begin() const
Definition cpdf_array.h:176
const_iterator end() const
Definition cpdf_array.h:180
CPDF_ArrayLocker(const CPDF_Array *pArray)
CPDF_ArrayLocker(RetainPtr< const CPDF_Array > pArray)
size_t size() const
Definition cpdf_array.h:41
void Append(RetainPtr< CPDF_Stream > stream)=delete
bool GetBooleanAt(size_t index, bool bDefault) const
void SetAt(size_t index, RetainPtr< CPDF_Object > object)
RetainPtr< CPDF_Dictionary > GetMutableDictAt(size_t index)
RetainPtr< CPDF_Object > CloneNonCyclic(bool bDirect, std::set< const CPDF_Object * > *pVisited) const override
bool IsEmpty() const
Definition cpdf_array.h:40
RetainPtr< const CPDF_Object > GetDirectObjectAt(size_t index) const
RetainPtr< const CPDF_Stream > GetStreamAt(size_t index) const
Type GetType() const override
absl::optional< size_t > Find(const CPDF_Object *pThat) const
CPDF_Array * AsMutableArray() override
RetainPtr< const CPDF_Object > GetObjectAt(size_t index) const
RetainPtr< CPDF_Object > GetMutableObjectAt(size_t index)
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type AppendNew(Args &&... args)
Definition cpdf_array.h:85
WideString GetUnicodeTextAt(size_t index) const
RetainPtr< CPDF_Array > GetMutableArrayAt(size_t index)
RetainPtr< CPDF_Object > Clone() const override
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type AppendNew(Args &&... args)
Definition cpdf_array.h:91
RetainPtr< const CPDF_Dictionary > GetDictAt(size_t index) const
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type InsertNewAt(size_t index, Args &&... args)
Definition cpdf_array.h:109
bool IsLocked() const
Definition cpdf_array.h:141
RetainPtr< CPDF_Stream > GetMutableStreamAt(size_t index)
bool Contains(const CPDF_Object *pThat) const
void ConvertToIndirectObjectAt(size_t index, CPDF_IndirectObjectHolder *pHolder)
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type InsertNewAt(size_t index, Args &&... args)
Definition cpdf_array.h:115
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type SetNewAt(size_t index, Args &&... args)
Definition cpdf_array.h:97
bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const override
RetainPtr< CPDF_Object > GetMutableDirectObjectAt(size_t index)
CFX_Matrix GetMatrix() const
~CPDF_Array() override
int GetIntegerAt(size_t index) const
void SetAt(size_t index, RetainPtr< CPDF_Stream > stream)=delete
void InsertAt(size_t index, RetainPtr< CPDF_Object > object)
ByteString GetByteStringAt(size_t index) const
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type SetNewAt(size_t index, Args &&... args)
Definition cpdf_array.h:103
void Append(RetainPtr< CPDF_Object > object)
RetainPtr< const CPDF_String > GetStringAt(size_t index) const
RetainPtr< const CPDF_Array > GetArrayAt(size_t index) const
RetainPtr< const CPDF_Number > GetNumberAt(size_t index) const
CFX_FloatRect GetRect() const
void InsertAt(size_t index, RetainPtr< CPDF_Stream > stream)=delete
void RemoveAt(size_t index)
float GetFloatAt(size_t index) const
CPDF_Creator(CPDF_Document *pDoc, RetainPtr< IFX_RetainableWriteStream > archive)
bool SetFileVersion(int32_t fileVersion)
void RemoveSecurity()
bool Create(uint32_t flags)
RetainPtr< const CPDF_Object > GetIndirectObject(uint32_t objnum) const
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type New(Args &&... args)
RetainPtr< T > NewIndirect(Args &&... args)
RetainPtr< CPDF_Object > GetOrParseIndirectObject(uint32_t objnum)
WeakPtr< ByteStringPool > GetByteStringPool() const
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type New(Args &&... args)
virtual RetainPtr< CPDF_Object > ParseIndirectObject(uint32_t objnum)
RetainPtr< CPDF_Object > GetMutableIndirectObject(uint32_t objnum)
uint32_t AddIndirectObject(RetainPtr< CPDF_Object > pObj)
bool ReplaceIndirectObjectIfHigherGeneration(uint32_t objnum, RetainPtr< CPDF_Object > pObj)
void SetGenNum(uint32_t gennum)
Definition cpdf_object.h:68
RetainPtr< const CPDF_Dictionary > GetDict() const
bool IsInline() const
Definition cpdf_object.h:69
uint32_t GetGenNum() const
Definition cpdf_object.h:67
virtual Type GetType() const =0
virtual WideString GetUnicodeText() const
virtual ByteString GetString() const
RetainPtr< const CPDF_Object > GetDirect() const
uint32_t m_GenNum
bool IsName() const
virtual CPDF_Null * AsMutableNull()
const CPDF_Name * AsName() const
bool IsArray() const
const CPDF_Boolean * AsBoolean() const
virtual void SetString(const ByteString &str)
const CPDF_Null * AsNull() const
bool IsDictionary() const
bool IsStream() const
virtual RetainPtr< CPDF_Reference > MakeReference(CPDF_IndirectObjectHolder *holder) const
RetainPtr< CPDF_Object > GetMutableDirect()
const CPDF_Array * AsArray() const
virtual int GetInteger() const
CPDF_Object()=default
virtual float GetNumber() const
bool IsNull() const
bool IsBoolean() const
uint32_t GetObjNum() const
Definition cpdf_object.h:65
const CPDF_Dictionary * AsDictionary() const
virtual bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const =0
RetainPtr< CPDF_Object > CloneDirectObject() const
virtual CPDF_Stream * AsMutableStream()
bool IsString() const
virtual CPDF_Number * AsMutableNumber()
virtual CPDF_Dictionary * AsMutableDictionary()
virtual RetainPtr< CPDF_Object > Clone() const =0
bool IsNumber() const
virtual CPDF_Reference * AsMutableReference()
uint32_t m_ObjNum
CPDF_Object(const CPDF_Object &src)=delete
const CPDF_Stream * AsStream() const
static constexpr uint32_t kInvalidObjNum
Definition cpdf_object.h:52
virtual const CPDF_Object * GetDirectInternal() const
virtual CPDF_Name * AsMutableName()
bool IsReference() const
void SetObjNum(uint32_t objnum)
Definition cpdf_object.h:66
const CPDF_String * AsString() const
uint64_t KeyForCache() const
virtual CPDF_Array * AsMutableArray()
const CPDF_Reference * AsReference() const
virtual RetainPtr< CPDF_Object > CloneNonCyclic(bool bDirect, std::set< const CPDF_Object * > *pVisited) const
virtual CPDF_String * AsMutableString()
const CPDF_Number * AsNumber() const
RetainPtr< CPDF_Dictionary > GetMutableDict()
RetainPtr< CPDF_Object > CloneObjectNonCyclic(bool bDirect) const
virtual const CPDF_Dictionary * GetDictInternal() const
~CPDF_Object() override
virtual CPDF_Boolean * AsMutableBoolean()
virtual FX_FILESIZE CurrentOffset() const =0
static RetainPtr< IFX_SeekableReadStream > CreateFromFilename(const char *filename)
Definition fx_stream.cpp:68
virtual size_t ReadBlock(pdfium::span< uint8_t > buffer)
Definition fx_stream.cpp:88
virtual FX_FILESIZE GetPosition()
Definition fx_stream.cpp:84
virtual bool ReadBlockAtOffset(pdfium::span< uint8_t > buffer, FX_FILESIZE offset)=0
virtual bool IsEOF()
Definition fx_stream.cpp:80
bool WriteBlock(pdfium::span< const uint8_t > buffer) override
Definition fx_stream.cpp:92
virtual bool WriteBlockAtOffset(pdfium::span< const uint8_t > data, FX_FILESIZE offset)=0
bool WriteBlock(pdfium::span< const uint8_t > buffer) override
Definition fx_stream.cpp:76
virtual bool Flush()=0
virtual FX_FILESIZE GetSize()=0
bool WriteFilesize(FX_FILESIZE size)
Definition fx_stream.cpp:61
bool WriteByte(uint8_t byte)
Definition fx_stream.cpp:51
bool WriteString(ByteStringView str)
Definition fx_stream.cpp:47
virtual ~IFX_WriteStream()=default
bool WriteDWord(uint32_t i)
Definition fx_stream.cpp:55
virtual bool WriteBlock(pdfium::span< const uint8_t > data)=0
void TrimLeft(ByteStringView targets)
bool IsValidLength(size_t length) const
Definition bytestring.h:121
bool Contains(ByteStringView lpszSub, size_t start=0) const
Definition bytestring.h:187
const_iterator begin() const
Definition bytestring.h:102
bool IsValidIndex(size_t index) const
Definition bytestring.h:120
static ByteString FormatFloat(float f)
ByteStringView AsStringView() const
Definition bytestring.h:87
uint32_t GetID() const
Definition bytestring.h:213
void Reserve(size_t len)
ByteString(const char *ptr)
bool EqualNoCase(ByteStringView str) const
static ByteString Format(const char *pFormat,...)
ByteString & operator+=(const ByteString &str)
bool operator!=(ByteStringView str) const
Definition bytestring.h:131
size_t GetLength() const
Definition bytestring.h:115
ByteString Substr(size_t first, size_t count) const
size_t GetStringLength() const
Definition bytestring.h:116
size_t InsertAtBack(char ch)
Definition bytestring.h:162
bool operator==(ByteStringView str) const
pdfium::span< const uint8_t > raw_span() const
Definition bytestring.h:97
void AllocCopy(ByteString &dest, size_t nCopyLen, size_t nCopyIndex) const
void AssignCopy(const char *pSrcData, size_t nSrcLen)
bool Contains(char ch, size_t start=0) const
Definition bytestring.h:191
absl::optional< size_t > ReverseFind(char ch) const
intptr_t ReferenceCountForTesting() const
size_t Delete(size_t index, size_t count=1)
const_reverse_iterator rend() const
Definition bytestring.h:111
ByteString & operator+=(char ch)
const uint8_t * raw_str() const
Definition bytestring.h:80
void ReallocBeforeWrite(size_t nNewLen)
ByteString(ByteStringView bstrc)
RetainPtr< StringData > m_pData
Definition bytestring.h:225
static ByteString FormatInteger(int i)
pdfium::span< char > GetBuffer(size_t nMinBufLength)
void Trim(char target)
bool operator==(const ByteString &other) const
bool operator==(const char *ptr) const
const_iterator end() const
Definition bytestring.h:103
ByteString(const ByteString &other)
size_t Remove(char ch)
ByteString(const char *pStr, size_t len)
bool operator<(ByteStringView str) const
ByteString(wchar_t)=delete
ByteString & operator+=(const char *str)
ByteString & operator+=(ByteStringView str)
ByteString(const uint8_t *pStr, size_t len)
size_t Replace(ByteStringView pOld, ByteStringView pNew)
absl::optional< size_t > Find(ByteStringView subStr, size_t start=0) const
bool operator!=(const ByteString &other) const
Definition bytestring.h:132
void SetAt(size_t index, char c)
ByteString & operator=(ByteStringView str)
ByteString(ByteStringView str1, ByteStringView str2)
void Trim(ByteStringView targets)
ByteString & operator=(const char *str)
static ByteString FormatV(const char *pFormat, va_list argList)
void TrimRight(char target)
const char * c_str() const
Definition bytestring.h:76
ByteString Substr(size_t offset) const
ByteString & operator=(const ByteString &that)
ByteString & operator=(ByteString &&that) noexcept
bool IsEmpty() const
Definition bytestring.h:119
void TrimRight(ByteStringView targets)
bool operator<(const ByteString &other) const
ByteString(const std::initializer_list< ByteStringView > &list)
CharType operator[](const size_t index) const
Definition bytestring.h:150
const_reverse_iterator rbegin() const
Definition bytestring.h:108
CharType Back() const
Definition bytestring.h:156
CharType Front() const
Definition bytestring.h:155
bool operator!=(const char *ptr) const
Definition bytestring.h:130
int Compare(ByteStringView str) const
size_t Insert(size_t index, char ch)
void ReleaseBuffer(size_t nNewLength)
ByteString(const fxcrt::ostringstream &outStream)
void TrimLeft(char target)
size_t InsertAtFront(char ch)
Definition bytestring.h:161
ByteString First(size_t count) const
void AllocBeforeWrite(size_t nNewLen)
bool operator<(const char *ptr) const
void Concat(const char *pSrcData, size_t nSrcLen)
absl::optional< size_t > Find(char ch, size_t start=0) const
ByteString(ByteString &&other) noexcept
ByteString Last(size_t count) const
U * AsRaw() const
Definition retain_ptr.h:107
RetainPtr & operator=(const RetainPtr< U > &that)
Definition retain_ptr.h:89
operator bool() const
Definition retain_ptr.h:149
void Unleak(T *ptr)
Definition retain_ptr.h:130
RetainPtr(std::nullptr_t ptr)
Definition retain_ptr.h:35
void Reset(T *obj=nullptr)
Definition retain_ptr.h:116
bool operator!=(const RetainPtr &that) const
Definition retain_ptr.h:133
void Swap(RetainPtr &that)
Definition retain_ptr.h:126
RetainPtr() noexcept=default
RetainPtr(RetainPtr &&that) noexcept
Definition retain_ptr.h:48
bool operator!=(const U &that) const
Definition retain_ptr.h:141
RetainPtr & operator=(const RetainPtr &that)
Definition retain_ptr.h:72
bool operator==(const RetainPtr &that) const
Definition retain_ptr.h:132
T & operator*() const
Definition retain_ptr.h:150
bool operator==(const U &that) const
Definition retain_ptr.h:136
RetainPtr & operator=(RetainPtr &&that) noexcept
Definition retain_ptr.h:80
T * operator->() const
Definition retain_ptr.h:151
RetainPtr & operator=(RetainPtr< U > &&that) noexcept
Definition retain_ptr.h:99
RetainPtr(const RetainPtr< U > &that)
Definition retain_ptr.h:54
T * Get() const noexcept
Definition retain_ptr.h:123
~RetainPtr()=default
bool operator<(const RetainPtr &that) const
Definition retain_ptr.h:145
RetainPtr(const RetainPtr &that) noexcept
Definition retain_ptr.h:44
operator T*() const noexcept
Definition retain_ptr.h:122
RetainPtr & operator=(std::nullptr_t) noexcept
Definition retain_ptr.h:65
UnownedPtr< T > BackPointer() const
Definition retain_ptr.h:125
RetainPtr(RetainPtr< U > &&that) noexcept
Definition retain_ptr.h:60
RetainPtr< U > As() const
Definition retain_ptr.h:112
RetainPtr(T *pObj) noexcept
Definition retain_ptr.h:37
bool HasOneRef() const
Definition retain_ptr.h:162
Retainable()=default
virtual ~Retainable()=default
void CopyContents(const CharType *pStr, size_t nLen)
static StringDataTemplate * Create(size_t nLen)
void CopyContents(const StringDataTemplate &other)
bool CanOperateInPlace(size_t nTotalLen) const
static StringDataTemplate * Create(const CharType *pStr, size_t nLen)
void CopyContentsAt(size_t offset, const CharType *pStr, size_t nLen)
absl::optional< size_t > Find(CharType ch) const
bool operator>(const StringViewTemplate &that) const
StringViewTemplate(const CharType *ptr) noexcept
bool operator<(const StringViewTemplate &that) const
constexpr StringViewTemplate(const UnsignedType *ptr, size_t size) noexcept
bool IsValidLength(size_t length) const
constexpr StringViewTemplate(const CharType *ptr, size_t size) noexcept
bool operator!=(const CharType *ptr) const
StringViewTemplate TrimmedRight(CharType ch) const
pdfium::span< const UnsignedType > m_Span
bool EqualsASCII(const StringViewTemplate< char > &that) const
const CharType * unterminated_c_str() const
bool operator==(const CharType *ptr) const
bool Contains(CharType ch) const
bool EqualsASCIINoCase(const StringViewTemplate< char > &that) const
pdfium::span< const UnsignedType > raw_span() const
StringViewTemplate Substr(size_t first, size_t count) const
bool operator==(const StringViewTemplate &other) const
const_iterator end() const
const UnsignedType & operator[](const size_t index) const
StringViewTemplate Last(size_t count) const
CharType CharAt(const size_t index) const
bool operator!=(const StringViewTemplate &other) const
StringViewTemplate First(size_t count) const
constexpr StringViewTemplate(const pdfium::span< const CharType > &other) noexcept
constexpr StringViewTemplate(const StringViewTemplate &src) noexcept=default
const_iterator begin() const
StringViewTemplate & operator=(const StringViewTemplate &src)
const_reverse_iterator rend() const
StringViewTemplate & operator=(const CharType *src)
StringViewTemplate Substr(size_t offset) const
constexpr StringViewTemplate() noexcept=default
constexpr StringViewTemplate(const CharType &ch) noexcept
const_reverse_iterator rbegin() const
const UnsignedType * raw_str() const
bool IsValidIndex(size_t index) const
constexpr StringViewTemplate(const pdfium::span< const UnsignedType > &other) noexcept
T * get() const noexcept
UnownedPtr(const UnownedPtr< U > &that)
Definition unowned_ptr.h:98
bool operator==(const UnownedPtr &that) const
operator T*() const noexcept
UnownedPtr(UnownedPtr< U > &&that) noexcept
UnownedPtr & operator=(UnownedPtr< U > &&that) noexcept
constexpr UnownedPtr(const UnownedPtr &that) noexcept=default
constexpr UnownedPtr(T *pObj) noexcept
Definition unowned_ptr.h:83
UnownedPtr & operator=(T *that) noexcept
bool operator==(std::nullptr_t ptr) const
UnownedPtr & operator=(UnownedPtr &&that) noexcept
UnownedPtr & operator=(std::nullptr_t) noexcept
UnownedPtr & operator=(const UnownedPtr< U > &that) noexcept
T * operator->() const
constexpr UnownedPtr() noexcept=default
bool operator<(const UnownedPtr &that) const
UnownedPtr & operator=(const UnownedPtr &that) noexcept=default
T & operator*() const
constexpr UnownedPtr(UnownedPtr &&that) noexcept
Definition unowned_ptr.h:91
constexpr UnownedPtr(std::nullptr_t ptr)
Definition unowned_ptr.h:81
WideString(char)=delete
WideString(const std::initializer_list< WideStringView > &list)
WideString & operator+=(const WideString &str)
WideString(wchar_t ch)
bool operator==(const WideString &other) const
size_t Insert(size_t index, wchar_t ch)
ByteString ToUTF8() const
static WideString Format(const wchar_t *pFormat,...)
WideString(WideString &&other) noexcept
WideString(const wchar_t *pStr, size_t len)
WideString & operator=(WideString &&that) noexcept
WideString(WideStringView str1, WideStringView str2)
WideString First(size_t count) const
static WideString FromUTF8(ByteStringView str)
WideString & operator+=(const wchar_t *str)
const_reverse_iterator rbegin() const
Definition widestring.h:103
void Trim(WideStringView targets)
pdfium::span< wchar_t > GetBuffer(size_t nMinBufLength)
bool operator==(const wchar_t *ptr) const
WideString & operator+=(wchar_t ch)
size_t Replace(WideStringView pOld, WideStringView pNew)
void TrimLeft(wchar_t target)
WideStringView AsStringView() const
Definition widestring.h:85
void TrimLeft(WideStringView targets)
void SetAt(size_t index, wchar_t c)
bool operator<(WideStringView str) const
bool EqualsASCIINoCase(ByteStringView that) const
Definition widestring.h:219
CharType operator[](const size_t index) const
Definition widestring.h:146
bool IsEmpty() const
Definition widestring.h:118
CharType Front() const
Definition widestring.h:151
const wchar_t * c_str() const
Definition widestring.h:81
void TrimRight(WideStringView targets)
static WideString FromDefANSI(ByteStringView str)
void AssignCopy(const wchar_t *pSrcData, size_t nSrcLen)
WideString(const WideString &other)
int GetInteger() const
int CompareNoCase(const wchar_t *str) const
void AllocCopy(WideString &dest, size_t nCopyLen, size_t nCopyIndex) const
WideString(const wchar_t *ptr)
bool IsValidIndex(size_t index) const
Definition widestring.h:119
absl::optional< size_t > Find(wchar_t ch, size_t start=0) const
bool Contains(char ch, size_t start=0) const
Definition widestring.h:208
static size_t WStringLength(const unsigned short *str)
static WideString FromLatin1(ByteStringView str)
size_t InsertAtBack(wchar_t ch)
Definition widestring.h:167
bool IsASCII() const
Definition widestring.h:215
size_t InsertAtFront(wchar_t ch)
Definition widestring.h:166
bool operator==(WideStringView str) const
bool operator!=(const WideString &other) const
Definition widestring.h:140
ByteString ToLatin1() const
intptr_t ReferenceCountForTesting() const
bool Contains(WideStringView lpszSub, size_t start=0) const
Definition widestring.h:204
static WideString FromUTF16BE(pdfium::span< const uint8_t > data)
bool operator<(const WideString &other) const
int Compare(const wchar_t *str) const
size_t GetLength() const
Definition widestring.h:114
WideString & operator=(const WideString &that)
void TrimRight(wchar_t target)
WideString EncodeEntities() const
void ReallocBeforeWrite(size_t nNewLength)
ByteString ToASCII() const
static WideString FromASCII(ByteStringView str)
WideString & operator+=(WideStringView str)
const_iterator end() const
Definition widestring.h:98
static WideString FromUTF16LE(pdfium::span< const uint8_t > data)
void ReleaseBuffer(size_t nNewLength)
size_t GetStringLength() const
Definition widestring.h:115
WideString Last(size_t count) const
int Compare(const WideString &str) const
const_reverse_iterator rend() const
Definition widestring.h:106
WideString & operator=(const wchar_t *str)
void Concat(const wchar_t *pSrcData, size_t nSrcLen)
WideString Substr(size_t offset) const
const_iterator begin() const
Definition widestring.h:97
WideString(WideStringView str)
void Trim(wchar_t target)
size_t Remove(wchar_t ch)
CharType Back() const
Definition widestring.h:152
absl::optional< size_t > ReverseFind(wchar_t ch) const
bool operator!=(const wchar_t *ptr) const
Definition widestring.h:138
static WideString FormatV(const wchar_t *lpszFormat, va_list argList)
ByteString ToUTF16LE() const
static WideString FormatInteger(int i)
size_t Delete(size_t index, size_t count=1)
bool EqualsASCII(ByteStringView that) const
Definition widestring.h:216
ByteString ToDefANSI() const
void Reserve(size_t len)
bool operator<(const wchar_t *ptr) const
void AllocBeforeWrite(size_t nNewLength)
WideString Substr(size_t first, size_t count) const
bool IsValidLength(size_t length) const
Definition widestring.h:120
absl::optional< size_t > Find(WideStringView subStr, size_t start=0) const
bool operator!=(WideStringView str) const
Definition widestring.h:139
WideString & operator=(WideStringView str)
RetainPtr< StringData > m_pData
Definition widestring.h:246
CPDF_Array * ToArray(CPDF_Object *obj)
Definition cpdf_array.h:189
const CPDF_Array * ToArray(const CPDF_Object *obj)
Definition cpdf_array.h:193
RetainPtr< CPDF_Array > ToArray(RetainPtr< CPDF_Object > obj)
Definition cpdf_array.h:197
#define FPDFCREATE_INCREMENTAL
#define FPDFCREATE_NO_ORIGINAL
NOINLINE void FX_OutOfMemoryTerminate(size_t size)
Definition fx_memory.cpp:37
void FXMEM_DefaultFree(void *pointer)
Definition fx_memory.cpp:33
void * FXMEM_DefaultAlloc(size_t byte_size)
Definition fx_memory.cpp:21
void * FXMEM_DefaultCalloc(size_t num_elems, size_t byte_size)
Definition fx_memory.cpp:25
void * FXMEM_DefaultRealloc(void *pointer, size_t new_size)
Definition fx_memory.cpp:29
void * FX_ArrayBufferAllocate(size_t length)
void FX_InitializeMemoryAllocators()
void FX_ArrayBufferFree(void *data)
void * FX_ArrayBufferAllocateUninitialized(size_t length)
void * FX_Random_MT_Start(uint32_t dwSeed)
Definition fx_random.cpp:85
uint32_t FX_Random_MT_Generate(void *pContext)
Definition fx_random.cpp:96
void FX_Random_MT_Close(void *pContext)
size_t FloatToString(float f, pdfium::span< char > buf)
constexpr uint32_t FXBSTR_ID(uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4)
Definition fx_string.h:19
double StringToDouble(WideStringView wsStr)
float StringToFloat(ByteStringView str)
ByteString FX_UTF8Encode(WideStringView wsStr)
Definition fx_string.cpp:69
std::u16string FX_UTF16Encode(WideStringView wsStr)
Definition fx_string.cpp:77
size_t DoubleToString(double d, pdfium::span< char > buf)
float StringToFloat(WideStringView wsStr)
double StringToDouble(ByteStringView str)
#define FX_FILESIZE
Definition fx_types.h:19
bool operator==(const char *lhs, const ByteString &rhs)
Definition bytestring.h:233
bool operator<(const ByteStringView &lhs, const char *rhs)
Definition bytestring.h:251
WideString operator+(const wchar_t *str1, WideStringView str2)
Definition widestring.h:260
ByteString operator+(const ByteString &str1, const ByteString &str2)
Definition bytestring.h:270
ByteString operator+(ByteStringView str1, const char *str2)
Definition bytestring.h:258
bool operator<(const ByteStringView &lhs, const ByteString &rhs)
Definition bytestring.h:248
bool operator==(const wchar_t *lhs, const WideString &rhs)
Definition widestring.h:290
WideString operator+(const WideString &str1, const WideString &str2)
Definition widestring.h:269
WideString operator+(const WideString &str1, WideStringView str2)
Definition widestring.h:284
WideString operator+(const WideString &str1, wchar_t ch)
Definition widestring.h:272
bool operator==(const T *lhs, const StringViewTemplate< T > &rhs)
bool operator<(const T *lhs, const StringViewTemplate< T > &rhs)
ByteString operator+(const ByteString &str1, char ch)
Definition bytestring.h:273
WideString operator+(WideStringView str1, const WideString &str2)
Definition widestring.h:287
ByteString operator+(const ByteString &str1, const char *str2)
Definition bytestring.h:279
std::vector< StrType > Split(const StrType &that, typename StrType::CharType ch)
Definition fx_string.h:38
void PrintTo(const ByteString &str, std::ostream *os)
bool operator!=(const T *lhs, const StringViewTemplate< T > &rhs)
ByteString operator+(char ch, const ByteString &str2)
Definition bytestring.h:276
ByteString operator+(const ByteString &str1, ByteStringView str2)
Definition bytestring.h:285
ByteString operator+(const char *str1, const ByteString &str2)
Definition bytestring.h:282
bool operator!=(WideStringView lhs, const WideString &rhs)
Definition widestring.h:299
bool operator!=(ByteStringView lhs, const ByteString &rhs)
Definition bytestring.h:242
bool operator!=(const char *lhs, const ByteString &rhs)
Definition bytestring.h:239
ByteString operator+(ByteStringView str1, ByteStringView str2)
Definition bytestring.h:255
ByteString operator+(ByteStringView str1, char ch)
Definition bytestring.h:264
bool operator<(const char *lhs, const ByteString &rhs)
Definition bytestring.h:245
bool operator==(WideStringView lhs, const WideString &rhs)
Definition widestring.h:293
bool operator!=(const wchar_t *lhs, const WideString &rhs)
Definition widestring.h:296
ByteString operator+(char ch, ByteStringView str2)
Definition bytestring.h:267
WideString operator+(WideStringView str1, const wchar_t *str2)
Definition widestring.h:257
WideString operator+(WideStringView str1, wchar_t ch)
Definition widestring.h:263
void PrintTo(const WideString &str, std::ostream *os)
ByteString operator+(ByteStringView str1, const ByteString &str2)
Definition bytestring.h:288
WideString operator+(WideStringView str1, WideStringView str2)
Definition widestring.h:254
WideString operator+(wchar_t ch, WideStringView str2)
Definition widestring.h:266
ByteString operator+(const char *str1, ByteStringView str2)
Definition bytestring.h:261
WideString operator+(wchar_t ch, const WideString &str2)
Definition widestring.h:275
WideString operator+(const wchar_t *str1, const WideString &str2)
Definition widestring.h:281
bool operator<(const wchar_t *lhs, const WideString &rhs)
Definition widestring.h:302
bool operator==(ByteStringView lhs, const ByteString &rhs)
Definition bytestring.h:236
WideString operator+(const WideString &str1, const wchar_t *str2)
Definition widestring.h:278
void * CallocOrDie2D(size_t w, size_t h, size_t member_size)
Definition fx_memory.cpp:79
void * AllocOrDie2D(size_t w, size_t h, size_t member_size)
Definition fx_memory.cpp:65
void * StringAllocOrDie(size_t num_members, size_t member_size)
Definition fx_memory.cpp:94
void * Alloc(size_t num_members, size_t member_size)
void * StringAlloc(size_t num_members, size_t member_size)
void * ReallocOrDie(void *ptr, size_t num_members, size_t member_size)
Definition fx_memory.cpp:86
void * Realloc(void *ptr, size_t num_members, size_t member_size)
void StringDealloc(void *ptr)
void * AllocOrDie(size_t num_members, size_t member_size)
Definition fx_memory.cpp:57
void * Calloc(size_t num_members, size_t member_size)
void * CallocOrDie(size_t num_members, size_t member_size)
Definition fx_memory.cpp:71
void Dealloc(void *ptr)
UnownedPtr< T > WrapUnowned(T *that)
RetainPtr< T > MakeRetain(Args &&... args)
Definition retain_ptr.h:209
RetainPtr< T > WrapRetain(T *that)
Definition retain_ptr.h:216
#define CHECK(cvref)
#define CONSTRUCT_VIA_MAKE_RETAIN
Definition retain_ptr.h:224
static constexpr bool value
void operator()(void *ptr) const
pointer allocate(size_type n, const void *hint=0)
void deallocate(pointer p, size_type n)
const_pointer address(const_reference x) const noexcept
FxPartitionAllocAllocator() noexcept=default
size_type max_size() const noexcept
~FxPartitionAllocAllocator()=default
pointer address(reference x) const noexcept
FxPartitionAllocAllocator(const FxPartitionAllocAllocator< U, Alloc, Free > &other) noexcept
bool operator!=(const FxPartitionAllocAllocator &that)
void construct(U *p, Args &&... args)
bool operator==(const FxPartitionAllocAllocator &that)
FxPartitionAllocAllocator(const FxPartitionAllocAllocator &other) noexcept=default
void operator()(T *ptr) const
Definition retain_ptr.h:24
size_t operator()(const ByteString &str) const
Definition bytestring.h:315
size_t operator()(const WideString &str) const
Definition widestring.h:329
#define UNOWNED_PTR_EXCLUSION
uint32_t FX_HashCode_GetLoweredW(WideStringView str)
uint32_t FX_HashCode_GetW(WideStringView str)