7#ifndef CORE_FPDFAPI_PARSER_CPDF_SECURITY_HANDLER_H_
8#define CORE_FPDFAPI_PARSER_CPDF_SECURITY_HANDLER_H_
15#include "core/fpdfapi/parser/cpdf_crypto_handler.h"
16#include "core/fxcrt/bytestring.h"
17#include "core/fxcrt/retain_ptr.h"
26 bool OnInit(
const CPDF_Dictionary* pEncryptDict,
28 const ByteString& password);
29 void OnCreate(CPDF_Dictionary* pEncryptDict,
30 const CPDF_Array* pIdArray,
31 const ByteString& password);
39 return m_pCryptoHandler.get();
47 enum PasswordEncodingConversion {
54 CPDF_SecurityHandler();
57 bool LoadDict(
const CPDF_Dictionary* pEncryptDict);
58 bool LoadDict(
const CPDF_Dictionary* pEncryptDict,
62 ByteString GetUserPassword(
const ByteString& owner_password)
const;
63 bool CheckPassword(
const ByteString& user_password,
bool bOwner);
64 bool CheckPasswordImpl(
const ByteString& password,
bool bOwner);
65 bool CheckUserPassword(
const ByteString& password,
bool bIgnoreEncryptMeta);
66 bool CheckOwnerPassword(
const ByteString& password);
67 bool AES256_CheckPassword(
const ByteString& password,
bool bOwner);
68 void AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
69 const ByteString& password);
70 void AES256_SetPerms(CPDF_Dictionary* pEncryptDict);
71 bool CheckSecurity(
const ByteString& password);
73 void InitCryptoHandler();
75 bool m_bOwnerUnlocked =
false;
78 uint32_t m_Permissions = 0;
81 PasswordEncodingConversion m_PasswordEncodingConversion = kUnknown;
83 RetainPtr<
const CPDF_Dictionary> m_pEncryptDict;
84 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler;
85 uint8_t m_EncryptKey[32] = {};
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
const_iterator end() const
CPDF_ArrayLocker(const CPDF_Array *pArray)
CPDF_ArrayLocker(RetainPtr< const CPDF_Array > pArray)
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
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)
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)
RetainPtr< const CPDF_Dictionary > GetDictAt(size_t index) const
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type InsertNewAt(size_t index, Args &&... args)
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)
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type SetNewAt(size_t index, Args &&... args)
bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const override
RetainPtr< CPDF_Object > GetMutableDirectObjectAt(size_t index)
CFX_Matrix GetMatrix() const
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)
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)
bool Create(uint32_t flags)
CPDF_Dictionary * GetMutableTrailerForTesting()
void SetFree(uint32_t obj_num)
const CPDF_Dictionary * trailer() const
const ObjectInfo * GetObjectInfo(uint32_t obj_num) const
CPDF_CrossRefTable(RetainPtr< CPDF_Dictionary > trailer, uint32_t trailer_object_number)
void Update(std::unique_ptr< CPDF_CrossRefTable > new_cross_ref)
const std::map< uint32_t, ObjectInfo > & objects_info() const
static std::unique_ptr< CPDF_CrossRefTable > MergeUp(std::unique_ptr< CPDF_CrossRefTable > current, std::unique_ptr< CPDF_CrossRefTable > top)
void AddCompressed(uint32_t obj_num, uint32_t archive_obj_num, uint32_t archive_obj_index)
uint32_t trailer_object_number() const
void AddNormal(uint32_t obj_num, uint16_t gen_num, bool is_object_stream, FX_FILESIZE pos)
void SetTrailer(RetainPtr< CPDF_Dictionary > trailer, uint32_t trailer_object_number)
void SetObjectMapSize(uint32_t size)
bool DecryptObjectTree(RetainPtr< CPDF_Object > object)
static bool IsSignatureDictionary(const CPDF_Dictionary *dictionary)
CPDF_CryptoHandler(Cipher cipher, const uint8_t *key, size_t keylen)
size_t EncryptGetSize(pdfium::span< const uint8_t > source) const
void EncryptContent(uint32_t objnum, uint32_t gennum, pdfium::span< const uint8_t > source, uint8_t *dest_buf, size_t &dest_size) const
const_iterator end() const
CPDF_DictionaryLocker(const CPDF_Dictionary *pDictionary)
const_iterator begin() const
CPDF_DictionaryLocker(RetainPtr< const CPDF_Dictionary > pDictionary)
CPDF_DictionaryLocker(RetainPtr< CPDF_Dictionary > pDictionary)
Type GetType() const override
bool KeyExist(const ByteString &key) const
int GetIntegerFor(const ByteString &key) const
RetainPtr< const CPDF_Stream > GetStreamFor(const ByteString &key) const
RetainPtr< const CPDF_Number > GetNumberFor(const ByteString &key) const
void SetFor(const ByteString &key, RetainPtr< CPDF_Object > object)
ByteString GetByteStringFor(const ByteString &key, const ByteString &default_str) const
std::enable_if< CanInternStrings< T >::value, RetainPtr< T > >::type SetNewFor(const ByteString &key, Args &&... args)
RetainPtr< CPDF_Object > RemoveFor(ByteStringView key)
RetainPtr< CPDF_Array > GetOrCreateArrayFor(const ByteString &key)
void SetMatrixFor(const ByteString &key, const CFX_Matrix &matrix)
RetainPtr< CPDF_Stream > GetMutableStreamFor(const ByteString &key)
RetainPtr< CPDF_Object > GetMutableDirectObjectFor(const ByteString &key)
RetainPtr< const CPDF_Dictionary > GetDictFor(const ByteString &key) const
RetainPtr< CPDF_Array > GetMutableArrayFor(const ByteString &key)
float GetFloatFor(const ByteString &key) const
RetainPtr< CPDF_Dictionary > GetOrCreateDictFor(const ByteString &key)
void ConvertToIndirectObjectFor(const ByteString &key, CPDF_IndirectObjectHolder *pHolder)
WideString GetUnicodeTextFor(const ByteString &key) const
RetainPtr< CPDF_Object > Clone() const override
const CPDF_Dictionary * GetDictInternal() const override
RetainPtr< CPDF_Object > CloneNonCyclic(bool bDirect, std::set< const CPDF_Object * > *visited) const override
CPDF_Dictionary * AsMutableDictionary() override
std::vector< ByteString > GetKeys() const
bool GetBooleanFor(const ByteString &key, bool bDefault) const
ByteString GetByteStringFor(const ByteString &key) const
int GetDirectIntegerFor(const ByteString &key) const
RetainPtr< const CPDF_String > GetStringFor(const ByteString &key) const
WeakPtr< ByteStringPool > GetByteStringPool() const
void SetRectFor(const ByteString &key, const CFX_FloatRect &rect)
RetainPtr< CPDF_Dictionary > GetMutableDictFor(const ByteString &key)
RetainPtr< const CPDF_Object > GetDirectObjectFor(const ByteString &key) const
bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const override
RetainPtr< const CPDF_Array > GetArrayFor(const ByteString &key) const
RetainPtr< const CPDF_Object > GetObjectFor(const ByteString &key) const
int GetIntegerFor(const ByteString &key, int default_int) const
~CPDF_Dictionary() override
void SetFor(const ByteString &key, RetainPtr< CPDF_Stream > stream)=delete
CFX_FloatRect GetRectFor(const ByteString &key) const
std::enable_if<!CanInternStrings< T >::value &&!std::is_same< T, CPDF_Stream >::value, RetainPtr< T > >::type SetNewFor(const ByteString &key, Args &&... args)
ByteString GetNameFor(const ByteString &key) const
CFX_Matrix GetMatrixFor(const ByteString &key) const
RetainPtr< CPDF_Object > GetMutableObjectFor(const ByteString &key)
void ReplaceKey(const ByteString &oldkey, const ByteString &newkey)
virtual void DeletePage(int page_index)=0
virtual ~Extension()=default
virtual bool ContainsExtensionForm() const =0
virtual bool ContainsExtensionFullForm() const =0
virtual int GetPageCount() const =0
virtual bool ContainsExtensionForegroundForm() const =0
virtual ~LinkListIface()=default
void SetDocument(CPDF_Document *pDoc)
CPDF_Document * GetDocument() const
virtual void MaybePurgeImage(uint32_t objnum)=0
virtual void ClearStockFont()=0
virtual RetainPtr< CPDF_StreamAcc > GetFontFileStreamAcc(RetainPtr< const CPDF_Stream > pFontStream)=0
virtual void MaybePurgeFontFileStreamAcc(RetainPtr< CPDF_StreamAcc > &&pStreamAcc)=0
void SetDocument(CPDF_Document *pDoc)
virtual ~RenderDataIface()
CPDF_Document * GetDocument() const
~CPDF_Document() override
bool has_valid_cross_reference_table() const
JBig2_DocumentContext * GetOrCreateCodecContext()
CPDF_Parser::Error LoadLinearizedDoc(RetainPtr< CPDF_ReadValidator > validator, const ByteString &password)
RetainPtr< CPDF_Object > ParseIndirectObject(uint32_t objnum) override
uint32_t GetParsedPageCountForTesting()
bool IsPageLoaded(int iPage) const
RetainPtr< const CPDF_Dictionary > GetPageDictionary(int iPage)
RetainPtr< CPDF_Dictionary > CreateNewPage(int iPage)
void DeletePage(int iPage)
void SetExtension(std::unique_ptr< Extension > pExt)
void SetLinksContext(std::unique_ptr< LinkListIface > pContext)
PageDataIface * GetPageData() const
bool IsModifiedAPStream(const CPDF_Stream *stream) const
RetainPtr< const CPDF_Array > GetFileIdentifier() const
void MaybePurgeImage(uint32_t objnum)
void MaybePurgeFontFileStreamAcc(RetainPtr< CPDF_StreamAcc > &&pStreamAcc)
RetainPtr< CPDF_Dictionary > GetMutableRoot()
RetainPtr< CPDF_Dictionary > GetInfo()
RenderDataIface * GetRenderData() const
LinkListIface * GetLinksContext() const
CPDF_Document(std::unique_ptr< RenderDataIface > pRenderData, std::unique_ptr< PageDataIface > pPageData)
CPDF_Parser::Error LoadDoc(RetainPtr< IFX_SeekableReadStream > pFileAccess, const ByteString &password)
void ResizePageListForTesting(size_t size)
CPDF_Parser * GetParser() const
RetainPtr< CPDF_Dictionary > GetMutablePageDictionary(int iPage)
bool MovePages(pdfium::span< const int > page_indices, int dest_page_index)
int GetPageIndex(uint32_t objnum)
Extension * GetExtension() const
uint32_t GetUserPermissions(bool get_owner_perms) const
RetainPtr< CPDF_StreamAcc > GetFontFileStreamAcc(RetainPtr< const CPDF_Stream > pFontStream)
void SetRootForTesting(RetainPtr< CPDF_Dictionary > root)
static bool IsValidPageObject(const CPDF_Object *obj)
const CPDF_Dictionary * GetRoot() const
void SetParser(std::unique_ptr< CPDF_Parser > pParser)
static constexpr int kPageMaxNum
void SetPageObjNum(int iPage, uint32_t objNum)
void IncrementParsedPageCount()
RetainPtr< CPDF_Stream > CreateModifiedAPStream()
CPDF_Encryptor(const CPDF_CryptoHandler *pHandler, int objnum)
DataVector< uint8_t > Encrypt(pdfium::span< const uint8_t > src_data) const
bool WriteDictTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const
pdfium::span< const uint8_t > GetSpan() const
CPDF_FlateEncoder(RetainPtr< const CPDF_Stream > pStream, bool bFlateEncode)
void UpdateLength(size_t size)
void DeleteIndirectObject(uint32_t objnum)
RetainPtr< const CPDF_Object > GetIndirectObject(uint32_t objnum) const
std::enable_if<!CanInternStrings< T >::value, RetainPtr< T > >::type New(Args &&... args)
void SetLastObjNum(uint32_t objnum)
const_iterator begin() const
RetainPtr< T > NewIndirect(Args &&... args)
RetainPtr< CPDF_Object > GetOrParseIndirectObject(uint32_t objnum)
uint32_t GetLastObjNum() const
CPDF_IndirectObjectHolder()
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)
virtual ~CPDF_IndirectObjectHolder()
uint32_t AddIndirectObject(RetainPtr< CPDF_Object > pObj)
bool ReplaceIndirectObjectIfHigherGeneration(uint32_t objnum, RetainPtr< CPDF_Object > pObj)
const_iterator end() const
bool WriteTo(IFX_ArchiveStream *archive, const CPDF_Encryptor *encryptor) const override
float GetNumber() const override
int GetInteger() const override
RetainPtr< CPDF_Object > Clone() const override
void SetString(const ByteString &str) override
ByteString GetString() const override
CPDF_Number * AsMutableNumber() override
Type GetType() const override
void SetGenNum(uint32_t gennum)
RetainPtr< const CPDF_Dictionary > GetDict() const
uint32_t GetGenNum() const
virtual Type GetType() const =0
virtual WideString GetUnicodeText() const
virtual ByteString GetString() const
RetainPtr< const CPDF_Object > GetDirect() const
virtual CPDF_Null * AsMutableNull()
const CPDF_Name * AsName() const
const CPDF_Boolean * AsBoolean() const
virtual void SetString(const ByteString &str)
const CPDF_Null * AsNull() const
bool IsDictionary() const
virtual RetainPtr< CPDF_Reference > MakeReference(CPDF_IndirectObjectHolder *holder) const
RetainPtr< CPDF_Object > GetMutableDirect()
const CPDF_Array * AsArray() const
virtual int GetInteger() const
virtual float GetNumber() const
uint32_t GetObjNum() const
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()
virtual CPDF_Number * AsMutableNumber()
virtual CPDF_Dictionary * AsMutableDictionary()
virtual RetainPtr< CPDF_Object > Clone() const =0
virtual CPDF_Reference * AsMutableReference()
CPDF_Object(const CPDF_Object &src)=delete
const CPDF_Stream * AsStream() const
static constexpr uint32_t kInvalidObjNum
virtual const CPDF_Object * GetDirectInternal() const
virtual CPDF_Name * AsMutableName()
void SetObjNum(uint32_t objnum)
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
virtual CPDF_Boolean * AsMutableBoolean()
bool IsObjectFreeOrNull(uint32_t objnum) const
void SetSyntaxParserForTesting(std::unique_ptr< CPDF_SyntaxParser > parser)
uint32_t GetPermissions(bool get_owner_perms) const
const CPDF_Dictionary * GetTrailer() const
FX_FILESIZE GetObjectPositionOrZero(uint32_t objnum) const
void SetLinearizedHeaderForTesting(std::unique_ptr< CPDF_LinearizedHeader > pLinearized)
int GetFileVersion() const
Error StartLinearizedParse(RetainPtr< CPDF_ReadValidator > validator, const ByteString &password)
uint32_t GetRootObjNum() const
RetainPtr< const CPDF_Array > GetIDArray() const
RetainPtr< const CPDF_Dictionary > GetEncryptDict() const
std::vector< unsigned int > GetTrailerEnds()
CPDF_Parser(ParsedObjectsHolder *holder)
FX_FILESIZE GetLastXRefOffset() const
RetainPtr< const CPDF_Dictionary > GetRoot() const
bool WriteToArchive(IFX_ArchiveStream *archive, FX_FILESIZE src_size)
void SetPassword(const ByteString &password)
const CPDF_LinearizedHeader * GetLinearizedHeader() const
ByteString GetPassword() const
static constexpr size_t kInvalidPos
CPDF_Dictionary * GetMutableTrailerForTesting()
uint32_t GetTrailerObjectNumber() const
RetainPtr< CPDF_Object > ParseIndirectObjectAt(FX_FILESIZE pos, uint32_t objnum)
static constexpr uint32_t kMaxObjectNumber
bool IsXRefStream() const
uint32_t GetFirstPageNo() const
Error StartParseInternal()
ByteString GetEncodedPassword() const
FX_FILESIZE GetDocumentSize() const
bool IsValidObjectNumber(uint32_t objnum) const
Error StartParse(RetainPtr< IFX_SeekableReadStream > pFile, const ByteString &password)
const CPDF_CrossRefTable * GetCrossRefTable() const
std::unique_ptr< CPDF_LinearizedHeader > ParseLinearizedHeader()
FX_FILESIZE ParseStartXRef()
bool IsObjectFree(uint32_t objnum) const
RetainPtr< CPDF_Dictionary > GetCombinedTrailer() const
uint32_t GetLastObjNum() const
const RetainPtr< CPDF_SecurityHandler > & GetSecurityHandler() const
RetainPtr< CPDF_Object > ParseIndirectObject(uint32_t objnum)
bool LoadCrossRefV4(FX_FILESIZE pos, bool bSkip)
uint32_t GetInfoObjNum() const
bool xref_table_rebuilt() const
CPDF_CryptoHandler * GetCryptoHandler() const
bool IsMetadataEncrypted() const
bool OnInit(const CPDF_Dictionary *pEncryptDict, RetainPtr< const CPDF_Array > pIdArray, const ByteString &password)
~CPDF_SecurityHandler() override
uint32_t GetPermissions(bool get_owner_perms) const
void OnCreate(CPDF_Dictionary *pEncryptDict, const CPDF_Array *pIdArray, const ByteString &password)
ByteString GetEncodedPassword(ByteStringView password) const
FX_Number(uint32_t value)=delete
int32_t GetSigned() const
FX_Number(ByteStringView str)
virtual FX_FILESIZE CurrentOffset() const =0
static RetainPtr< IFX_SeekableReadStream > CreateFromFilename(const char *filename)
virtual size_t ReadBlock(pdfium::span< uint8_t > buffer)
virtual FX_FILESIZE GetPosition()
virtual bool ReadBlockAtOffset(pdfium::span< uint8_t > buffer, FX_FILESIZE offset)=0
bool WriteBlock(pdfium::span< const uint8_t > buffer) override
virtual bool WriteBlockAtOffset(pdfium::span< const uint8_t > data, FX_FILESIZE offset)=0
bool WriteBlock(pdfium::span< const uint8_t > buffer) override
virtual FX_FILESIZE GetSize()=0
bool WriteFilesize(FX_FILESIZE size)
bool WriteByte(uint8_t byte)
bool WriteString(ByteStringView str)
virtual ~IFX_WriteStream()=default
bool WriteDWord(uint32_t i)
virtual bool WriteBlock(pdfium::span< const uint8_t > data)=0
virtual size_t GetLength() const
void AppendUint8(uint8_t value)
BinaryBuffer & operator=(const BinaryBuffer &that)=delete
void AppendUint16(uint16_t value)
DataVector< uint8_t > m_buffer
void AppendSpan(pdfium::span< const uint8_t > span)
pdfium::span< const uint8_t > GetSpan() const
void DeleteBuf(size_t start_index, size_t count)
void AppendDouble(double value)
void ExpandBuf(size_t size)
void AppendString(const ByteString &str)
void EstimateSize(size_t size)
BinaryBuffer & operator=(BinaryBuffer &&that) noexcept
BinaryBuffer(BinaryBuffer &&that) noexcept
void AppendUint32(uint32_t value)
BinaryBuffer(const BinaryBuffer &that)=delete
pdfium::span< uint8_t > GetMutableSpan()
DataVector< uint8_t > DetachBuffer()
void SetAllocStep(size_t step)
void TrimLeft(ByteStringView targets)
bool IsValidLength(size_t length) const
bool Contains(ByteStringView lpszSub, size_t start=0) const
const_iterator begin() const
bool IsValidIndex(size_t index) const
static ByteString FormatFloat(float f)
ByteStringView AsStringView() const
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
ByteString Substr(size_t first, size_t count) const
size_t GetStringLength() const
size_t InsertAtBack(char ch)
bool operator==(ByteStringView str) const
pdfium::span< const uint8_t > raw_span() const
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
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
ByteString & operator+=(char ch)
const uint8_t * raw_str() const
void ReallocBeforeWrite(size_t nNewLen)
ByteString(ByteStringView bstrc)
RetainPtr< StringData > m_pData
static ByteString FormatInteger(int i)
pdfium::span< char > GetBuffer(size_t nMinBufLength)
bool operator==(const ByteString &other) const
bool operator==(const char *ptr) const
const_iterator end() const
ByteString(const ByteString &other)
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
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
ByteString Substr(size_t offset) const
ByteString & operator=(const ByteString &that)
ByteString & operator=(ByteString &&that) noexcept
void TrimRight(ByteStringView targets)
bool operator<(const ByteString &other) const
ByteString(const std::initializer_list< ByteStringView > &list)
CharType operator[](const size_t index) const
const_reverse_iterator rbegin() const
bool operator!=(const char *ptr) const
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)
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
virtual void OnObservableDestroyed()=0
virtual ~ObserverIface()=default
Observable(const Observable &that)=delete
void AddObserver(ObserverIface *pObserver)
size_t ActiveObserversForTesting() const
void RemoveObserver(ObserverIface *pObserver)
Observable & operator=(const Observable &that)=delete
ObservedPtr(T *pObservable)
ObservedPtr & operator=(const ObservedPtr &that)
bool operator==(const ObservedPtr &that) const
void OnObservableDestroyed() override
bool HasObservable() const
void Reset(T *pObservable=nullptr)
ObservedPtr(const ObservedPtr &that)
bool operator!=(const ObservedPtr &that) const
bool operator!=(const U *that) const
bool operator==(const U *that) const
RetainPtr & operator=(const RetainPtr< U > &that)
RetainPtr(std::nullptr_t ptr)
void Reset(T *obj=nullptr)
bool operator!=(const RetainPtr &that) const
void Swap(RetainPtr &that)
RetainPtr() noexcept=default
RetainPtr(RetainPtr &&that) noexcept
bool operator!=(const U &that) const
RetainPtr & operator=(const RetainPtr &that)
bool operator==(const RetainPtr &that) const
bool operator==(const U &that) const
RetainPtr & operator=(RetainPtr &&that) noexcept
RetainPtr & operator=(RetainPtr< U > &&that) noexcept
RetainPtr(const RetainPtr< U > &that)
bool operator<(const RetainPtr &that) const
RetainPtr(const RetainPtr &that) noexcept
operator T*() const noexcept
RetainPtr & operator=(std::nullptr_t) noexcept
UnownedPtr< T > BackPointer() const
RetainPtr(RetainPtr< U > &&that) noexcept
RetainPtr< U > As() const
RetainPtr(T *pObj) noexcept
virtual ~Retainable()=default
void CopyContents(const CharType *pStr, size_t nLen)
static StringDataTemplate * Create(size_t nLen)
const size_t m_nAllocLength
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)
StringType Intern(const StringType &str)
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
UnsignedType Back() 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
UnsignedType Front() 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
UnownedPtr(const UnownedPtr< U > &that)
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
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
constexpr UnownedPtr() noexcept=default
bool operator<(const UnownedPtr &that) const
UnownedPtr & operator=(const UnownedPtr &that) noexcept=default
constexpr UnownedPtr(UnownedPtr &&that) noexcept
constexpr UnownedPtr(std::nullptr_t ptr)
bool operator==(const WeakPtr &that) const
void Reset(std::unique_ptr< T, D > pObj)
WeakPtr(std::unique_ptr< T, D > pObj)
WeakPtr(const WeakPtr &that)
WeakPtr & operator=(const WeakPtr &that)
WeakPtr(std::nullptr_t arg)
const T * operator->() const
WeakPtr(WeakPtr &&that) noexcept
bool operator!=(const WeakPtr &that) const
WideString(const std::initializer_list< WideStringView > &list)
WideString & operator+=(const WideString &str)
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
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
void TrimLeft(WideStringView targets)
void SetAt(size_t index, wchar_t c)
bool operator<(WideStringView str) const
bool EqualsASCIINoCase(ByteStringView that) const
CharType operator[](const size_t index) const
const wchar_t * c_str() const
void TrimRight(WideStringView targets)
static WideString FromDefANSI(ByteStringView str)
void AssignCopy(const wchar_t *pSrcData, size_t nSrcLen)
WideString(const WideString &other)
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
absl::optional< size_t > Find(wchar_t ch, size_t start=0) const
bool Contains(char ch, size_t start=0) const
static size_t WStringLength(const unsigned short *str)
static WideString FromLatin1(ByteStringView str)
size_t InsertAtBack(wchar_t ch)
size_t InsertAtFront(wchar_t ch)
bool operator==(WideStringView str) const
bool operator!=(const WideString &other) const
ByteString ToLatin1() const
intptr_t ReferenceCountForTesting() const
bool Contains(WideStringView lpszSub, size_t start=0) const
static WideString FromUTF16BE(pdfium::span< const uint8_t > data)
bool operator<(const WideString &other) const
int Compare(const wchar_t *str) const
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
static WideString FromUTF16LE(pdfium::span< const uint8_t > data)
void ReleaseBuffer(size_t nNewLength)
size_t GetStringLength() const
WideString Last(size_t count) const
int Compare(const WideString &str) const
const_reverse_iterator rend() const
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
WideString(WideStringView str)
void Trim(wchar_t target)
size_t Remove(wchar_t ch)
absl::optional< size_t > ReverseFind(wchar_t ch) const
bool operator!=(const wchar_t *ptr) const
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
ByteString ToDefANSI() const
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
absl::optional< size_t > Find(WideStringView subStr, size_t start=0) const
bool operator!=(WideStringView str) const
WideString & operator=(WideStringView str)
RetainPtr< StringData > m_pData
CPDF_Array * ToArray(CPDF_Object *obj)
const CPDF_Array * ToArray(const CPDF_Object *obj)
RetainPtr< CPDF_Array > ToArray(RetainPtr< CPDF_Object > obj)
#define FPDFCREATE_INCREMENTAL
#define FPDFCREATE_NO_ORIGINAL
const CPDF_Dictionary * ToDictionary(const CPDF_Object *obj)
RetainPtr< CPDF_Dictionary > ToDictionary(RetainPtr< CPDF_Object > obj)
CPDF_Dictionary * ToDictionary(CPDF_Object *obj)
const CPDF_Number * ToNumber(const CPDF_Object *obj)
RetainPtr< CPDF_Number > ToNumber(RetainPtr< CPDF_Object > obj)
CPDF_Number * ToNumber(CPDF_Object *obj)
NOINLINE void FX_OutOfMemoryTerminate(size_t size)
void FXMEM_DefaultFree(void *pointer)
void * FXMEM_DefaultAlloc(size_t byte_size)
void * FXMEM_DefaultCalloc(size_t num_elems, size_t byte_size)
void * FXMEM_DefaultRealloc(void *pointer, size_t new_size)
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)
uint32_t FX_Random_MT_Generate(void *pContext)
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)
double StringToDouble(WideStringView wsStr)
float StringToFloat(ByteStringView str)
ByteString FX_UTF8Encode(WideStringView wsStr)
std::u16string FX_UTF16Encode(WideStringView wsStr)
size_t DoubleToString(double d, pdfium::span< char > buf)
float StringToFloat(WideStringView wsStr)
double StringToDouble(ByteStringView str)
bool operator==(const char *lhs, const ByteString &rhs)
bool operator<(const ByteStringView &lhs, const char *rhs)
WideString operator+(const wchar_t *str1, WideStringView str2)
ByteString operator+(const ByteString &str1, const ByteString &str2)
ByteString operator+(ByteStringView str1, const char *str2)
bool operator<(const ByteStringView &lhs, const ByteString &rhs)
bool operator==(const wchar_t *lhs, const WideString &rhs)
WideString operator+(const WideString &str1, const WideString &str2)
WideString operator+(const WideString &str1, WideStringView str2)
WideString operator+(const WideString &str1, wchar_t ch)
bool operator==(const T *lhs, const StringViewTemplate< T > &rhs)
bool operator<(const T *lhs, const StringViewTemplate< T > &rhs)
bool operator!=(const U *lhs, const ObservedPtr< T > &rhs)
ByteString operator+(const ByteString &str1, char ch)
WideString operator+(WideStringView str1, const WideString &str2)
ByteString operator+(const ByteString &str1, const char *str2)
std::vector< StrType > Split(const StrType &that, typename StrType::CharType ch)
void PrintTo(const ByteString &str, std::ostream *os)
bool operator!=(const T *lhs, const StringViewTemplate< T > &rhs)
ByteString operator+(char ch, const ByteString &str2)
ByteString operator+(const ByteString &str1, ByteStringView str2)
ByteString operator+(const char *str1, const ByteString &str2)
bool operator!=(WideStringView lhs, const WideString &rhs)
bool operator!=(ByteStringView lhs, const ByteString &rhs)
bool operator!=(const char *lhs, const ByteString &rhs)
ByteString operator+(ByteStringView str1, ByteStringView str2)
ByteString operator+(ByteStringView str1, char ch)
bool operator<(const char *lhs, const ByteString &rhs)
bool operator==(WideStringView lhs, const WideString &rhs)
bool operator!=(const wchar_t *lhs, const WideString &rhs)
ByteString operator+(char ch, ByteStringView str2)
WideString operator+(WideStringView str1, const wchar_t *str2)
WideString operator+(WideStringView str1, wchar_t ch)
void PrintTo(const WideString &str, std::ostream *os)
ByteString operator+(ByteStringView str1, const ByteString &str2)
WideString operator+(WideStringView str1, WideStringView str2)
WideString operator+(wchar_t ch, WideStringView str2)
ByteString operator+(const char *str1, ByteStringView str2)
WideString operator+(wchar_t ch, const WideString &str2)
WideString operator+(const wchar_t *str1, const WideString &str2)
bool operator<(const wchar_t *lhs, const WideString &rhs)
bool operator==(ByteStringView lhs, const ByteString &rhs)
bool operator==(const U *lhs, const ObservedPtr< T > &rhs)
WideString operator+(const WideString &str1, const wchar_t *str2)
void * CallocOrDie2D(size_t w, size_t h, size_t member_size)
void * AllocOrDie2D(size_t w, size_t h, size_t member_size)
void * StringAllocOrDie(size_t num_members, size_t member_size)
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)
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)
void * Calloc(size_t num_members, size_t member_size)
void * CallocOrDie(size_t num_members, size_t member_size)
UnownedPtr< T > WrapUnowned(T *that)
RetainPtr< T > MakeRetain(Args &&... args)
RetainPtr< T > WrapRetain(T *that)
#define CONSTRUCT_VIA_MAKE_RETAIN
bool is_object_stream_flag
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
size_t operator()(const ByteString &str) const
size_t operator()(const WideString &str) const
#define UNOWNED_PTR_EXCLUSION
uint32_t FX_HashCode_GetLoweredW(WideStringView str)
uint32_t FX_HashCode_GetW(WideStringView str)