summaryrefslogtreecommitdiff
path: root/core/include/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/include/fxcrt')
-rw-r--r--core/include/fxcrt/fx_arb.h91
-rw-r--r--core/include/fxcrt/fx_basic.h2190
-rw-r--r--core/include/fxcrt/fx_coordinates.h1491
-rw-r--r--core/include/fxcrt/fx_ext.h122
-rw-r--r--core/include/fxcrt/fx_memory.h114
-rw-r--r--core/include/fxcrt/fx_stream.h240
-rw-r--r--core/include/fxcrt/fx_string.h1203
-rw-r--r--core/include/fxcrt/fx_system.h240
-rw-r--r--core/include/fxcrt/fx_ucd.h348
-rw-r--r--core/include/fxcrt/fx_xml.h306
10 files changed, 2926 insertions, 3419 deletions
diff --git a/core/include/fxcrt/fx_arb.h b/core/include/fxcrt/fx_arb.h
index 3886ac3aae..d3612db4e7 100644
--- a/core/include/fxcrt/fx_arb.h
+++ b/core/include/fxcrt/fx_arb.h
@@ -13,26 +13,25 @@
class IFX_ArabicChar;
class IFX_BidiChar;
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
typedef struct _FX_ARBFORMTABLE {
- FX_WCHAR wIsolated;
- FX_WCHAR wFinal;
- FX_WCHAR wInitial;
- FX_WCHAR wMedial;
-} FX_ARBFORMTABLE, * FX_LPARBFORMTABLE;
-typedef FX_ARBFORMTABLE const * FX_LPCARBFORMTABLE;
+ FX_WCHAR wIsolated;
+ FX_WCHAR wFinal;
+ FX_WCHAR wInitial;
+ FX_WCHAR wMedial;
+} FX_ARBFORMTABLE, *FX_LPARBFORMTABLE;
+typedef FX_ARBFORMTABLE const* FX_LPCARBFORMTABLE;
typedef struct _FX_ARAALEF {
- FX_WCHAR wAlef;
- FX_WCHAR wIsolated;
-} FX_ARAALEF, * FX_LPARAALEF;
-typedef FX_ARAALEF const * FX_LPCARAALEF;
+ FX_WCHAR wAlef;
+ FX_WCHAR wIsolated;
+} FX_ARAALEF, *FX_LPARAALEF;
+typedef FX_ARAALEF const* FX_LPCARAALEF;
typedef struct _FX_ARASHADDA {
- FX_WCHAR wShadda;
- FX_WCHAR wIsolated;
-} FX_ARASHADDA, * FX_LPARASHADDA;
-typedef FX_ARASHADDA const * FX_LPCARASHADDA;
+ FX_WCHAR wShadda;
+ FX_WCHAR wIsolated;
+} FX_ARASHADDA, *FX_LPARASHADDA;
+typedef FX_ARASHADDA const* FX_LPCARASHADDA;
FX_LPCARBFORMTABLE FX_GetArabicFormTable(FX_WCHAR unicode);
FX_WCHAR FX_GetArabicFromAlefTable(FX_WCHAR alef);
FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda);
@@ -40,36 +39,42 @@ FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda);
};
#endif
enum FX_ARBPOSITION {
- FX_ARBPOSITION_Isolated = 0,
- FX_ARBPOSITION_Final,
- FX_ARBPOSITION_Initial,
- FX_ARBPOSITION_Medial,
+ FX_ARBPOSITION_Isolated = 0,
+ FX_ARBPOSITION_Final,
+ FX_ARBPOSITION_Initial,
+ FX_ARBPOSITION_Medial,
};
-class IFX_ArabicChar
-{
-public:
- static IFX_ArabicChar* Create();
- virtual ~IFX_ArabicChar() {}
- virtual void Release() = 0;
- virtual FX_BOOL IsArabicChar(FX_WCHAR wch) const = 0;
- virtual FX_BOOL IsArabicFormChar(FX_WCHAR wch) const = 0;
- virtual FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev = 0, FX_WCHAR next = 0) const = 0;
- virtual FX_WCHAR GetFormChar(const CFX_Char *cur, const CFX_Char *prev, const CFX_Char *next) const = 0;
+class IFX_ArabicChar {
+ public:
+ static IFX_ArabicChar* Create();
+ virtual ~IFX_ArabicChar() {}
+ virtual void Release() = 0;
+ virtual FX_BOOL IsArabicChar(FX_WCHAR wch) const = 0;
+ virtual FX_BOOL IsArabicFormChar(FX_WCHAR wch) const = 0;
+ virtual FX_WCHAR GetFormChar(FX_WCHAR wch,
+ FX_WCHAR prev = 0,
+ FX_WCHAR next = 0) const = 0;
+ virtual FX_WCHAR GetFormChar(const CFX_Char* cur,
+ const CFX_Char* prev,
+ const CFX_Char* next) const = 0;
};
-void FX_BidiLine(CFX_WideString &wsText, int32_t iBaseLevel = 0);
-void FX_BidiLine(CFX_TxtCharArray &chars, int32_t iCount, int32_t iBaseLevel = 0);
-void FX_BidiLine(CFX_RTFCharArray &chars, int32_t iCount, int32_t iBaseLevel = 0);
-class IFX_BidiChar
-{
-public:
- static IFX_BidiChar* Create();
- virtual ~IFX_BidiChar() {}
+void FX_BidiLine(CFX_WideString& wsText, int32_t iBaseLevel = 0);
+void FX_BidiLine(CFX_TxtCharArray& chars,
+ int32_t iCount,
+ int32_t iBaseLevel = 0);
+void FX_BidiLine(CFX_RTFCharArray& chars,
+ int32_t iCount,
+ int32_t iBaseLevel = 0);
+class IFX_BidiChar {
+ public:
+ static IFX_BidiChar* Create();
+ virtual ~IFX_BidiChar() {}
- virtual void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) = 0;
- virtual FX_BOOL AppendChar(FX_WCHAR wch) = 0;
- virtual FX_BOOL EndChar() = 0;
- virtual int32_t GetBidiInfo(int32_t &iStart, int32_t &iCount) = 0;
- virtual void Reset() = 0;
+ virtual void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) = 0;
+ virtual FX_BOOL AppendChar(FX_WCHAR wch) = 0;
+ virtual FX_BOOL EndChar() = 0;
+ virtual int32_t GetBidiInfo(int32_t& iStart, int32_t& iCount) = 0;
+ virtual void Reset() = 0;
};
#endif // CORE_INCLUDE_FXCRT_FX_ARB_H_
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index dcc1081f44..0079acdd5e 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -25,1609 +25,1375 @@
// Note that the function doesn't need an implementation, as we only
// use its type.
template <typename T, size_t N>
-char (&ArraySizeHelper(T (&array)[N]))[N];
+char(&ArraySizeHelper(T(&array)[N]))[N];
-class CFX_BinaryBuf
-{
-public:
- CFX_BinaryBuf();
- CFX_BinaryBuf(FX_STRSIZE size);
+class CFX_BinaryBuf {
+ public:
+ CFX_BinaryBuf();
+ CFX_BinaryBuf(FX_STRSIZE size);
- ~CFX_BinaryBuf();
+ ~CFX_BinaryBuf();
- void Clear();
+ void Clear();
- void EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step = 0);
+ void EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step = 0);
- void AppendBlock(const void* pBuf, FX_STRSIZE size);
+ void AppendBlock(const void* pBuf, FX_STRSIZE size);
- void AppendFill(uint8_t byte, FX_STRSIZE count);
+ void AppendFill(uint8_t byte, FX_STRSIZE count);
- void AppendString(const CFX_ByteStringC& str)
- {
- AppendBlock(str.GetPtr(), str.GetLength());
- }
+ void AppendString(const CFX_ByteStringC& str) {
+ AppendBlock(str.GetPtr(), str.GetLength());
+ }
- inline void AppendByte(uint8_t byte)
- {
- if (m_AllocSize <= m_DataSize) {
- ExpandBuf(1);
- }
- m_pBuffer[m_DataSize++] = byte;
+ inline void AppendByte(uint8_t byte) {
+ if (m_AllocSize <= m_DataSize) {
+ ExpandBuf(1);
}
+ m_pBuffer[m_DataSize++] = byte;
+ }
- void InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size);
+ void InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size);
- void AttachData(void* pBuf, FX_STRSIZE size);
+ void AttachData(void* pBuf, FX_STRSIZE size);
- void CopyData(const void* pBuf, FX_STRSIZE size);
+ void CopyData(const void* pBuf, FX_STRSIZE size);
- void TakeOver(CFX_BinaryBuf& other);
+ void TakeOver(CFX_BinaryBuf& other);
- void Delete(int start_index, int count);
+ void Delete(int start_index, int count);
- uint8_t* GetBuffer() const
- {
- return m_pBuffer;
- }
+ uint8_t* GetBuffer() const { return m_pBuffer; }
- FX_STRSIZE GetSize() const
- {
- return m_DataSize;
- }
+ FX_STRSIZE GetSize() const { return m_DataSize; }
- CFX_ByteStringC GetByteString() const;
+ CFX_ByteStringC GetByteString() const;
- void DetachBuffer();
-protected:
+ void DetachBuffer();
- FX_STRSIZE m_AllocStep;
+ protected:
+ FX_STRSIZE m_AllocStep;
- uint8_t* m_pBuffer;
+ uint8_t* m_pBuffer;
- FX_STRSIZE m_DataSize;
+ FX_STRSIZE m_DataSize;
- FX_STRSIZE m_AllocSize;
+ FX_STRSIZE m_AllocSize;
- void ExpandBuf(FX_STRSIZE size);
+ void ExpandBuf(FX_STRSIZE size);
};
-class CFX_ByteTextBuf : public CFX_BinaryBuf
-{
-public:
+class CFX_ByteTextBuf : public CFX_BinaryBuf {
+ public:
+ void operator=(const CFX_ByteStringC& str);
- void operator = (const CFX_ByteStringC& str);
+ void AppendChar(int ch) { AppendByte((uint8_t)ch); }
- void AppendChar(int ch)
- {
- AppendByte((uint8_t)ch);
- }
-
- CFX_ByteTextBuf& operator << (int i);
+ CFX_ByteTextBuf& operator<<(int i);
- CFX_ByteTextBuf& operator << (FX_DWORD i);
+ CFX_ByteTextBuf& operator<<(FX_DWORD i);
- CFX_ByteTextBuf& operator << (double f);
+ CFX_ByteTextBuf& operator<<(double f);
- CFX_ByteTextBuf& operator << (const CFX_ByteStringC& lpsz);
+ CFX_ByteTextBuf& operator<<(const CFX_ByteStringC& lpsz);
- CFX_ByteTextBuf& operator << (const CFX_ByteTextBuf& buf);
+ CFX_ByteTextBuf& operator<<(const CFX_ByteTextBuf& buf);
- FX_STRSIZE GetLength() const
- {
- return m_DataSize;
- }
+ FX_STRSIZE GetLength() const { return m_DataSize; }
};
-class CFX_WideTextBuf : public CFX_BinaryBuf
-{
-public:
+class CFX_WideTextBuf : public CFX_BinaryBuf {
+ public:
+ void operator=(const FX_WCHAR* lpsz);
- void operator = (const FX_WCHAR* lpsz);
+ void operator=(const CFX_WideStringC& str);
- void operator = (const CFX_WideStringC& str);
+ void AppendChar(FX_WCHAR wch);
- void AppendChar(FX_WCHAR wch);
+ CFX_WideTextBuf& operator<<(int i);
- CFX_WideTextBuf& operator << (int i);
+ CFX_WideTextBuf& operator<<(double f);
- CFX_WideTextBuf& operator << (double f);
+ CFX_WideTextBuf& operator<<(const FX_WCHAR* lpsz);
- CFX_WideTextBuf& operator << (const FX_WCHAR* lpsz);
+ CFX_WideTextBuf& operator<<(const CFX_WideStringC& str);
+ CFX_WideTextBuf& operator<<(const CFX_WideString& str);
- CFX_WideTextBuf& operator << (const CFX_WideStringC& str);
- CFX_WideTextBuf& operator << (const CFX_WideString &str);
+ CFX_WideTextBuf& operator<<(const CFX_WideTextBuf& buf);
- CFX_WideTextBuf& operator << (const CFX_WideTextBuf& buf);
+ FX_STRSIZE GetLength() const { return m_DataSize / sizeof(FX_WCHAR); }
- FX_STRSIZE GetLength() const
- {
- return m_DataSize / sizeof(FX_WCHAR);
- }
-
- FX_WCHAR* GetBuffer() const
- {
- return (FX_WCHAR*)m_pBuffer;
- }
+ FX_WCHAR* GetBuffer() const { return (FX_WCHAR*)m_pBuffer; }
- void Delete(int start_index, int count)
- {
- CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), count * sizeof(FX_WCHAR));
- }
+ void Delete(int start_index, int count) {
+ CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR),
+ count * sizeof(FX_WCHAR));
+ }
- CFX_WideStringC GetWideString() const;
+ CFX_WideStringC GetWideString() const;
};
-class CFX_ArchiveSaver
-{
-public:
- CFX_ArchiveSaver() : m_pStream(NULL) {}
+class CFX_ArchiveSaver {
+ public:
+ CFX_ArchiveSaver() : m_pStream(NULL) {}
- CFX_ArchiveSaver& operator << (uint8_t i);
+ CFX_ArchiveSaver& operator<<(uint8_t i);
- CFX_ArchiveSaver& operator << (int i);
+ CFX_ArchiveSaver& operator<<(int i);
- CFX_ArchiveSaver& operator << (FX_DWORD i);
+ CFX_ArchiveSaver& operator<<(FX_DWORD i);
- CFX_ArchiveSaver& operator << (FX_FLOAT i);
+ CFX_ArchiveSaver& operator<<(FX_FLOAT i);
- CFX_ArchiveSaver& operator << (double i);
+ CFX_ArchiveSaver& operator<<(double i);
- CFX_ArchiveSaver& operator << (const CFX_ByteStringC& bstr);
+ CFX_ArchiveSaver& operator<<(const CFX_ByteStringC& bstr);
- CFX_ArchiveSaver& operator << (const FX_WCHAR* bstr);
+ CFX_ArchiveSaver& operator<<(const FX_WCHAR* bstr);
- CFX_ArchiveSaver& operator << (const CFX_WideString& wstr);
+ CFX_ArchiveSaver& operator<<(const CFX_WideString& wstr);
- void Write(const void* pData, FX_STRSIZE dwSize);
+ void Write(const void* pData, FX_STRSIZE dwSize);
- intptr_t GetLength()
- {
- return m_SavingBuf.GetSize();
- }
+ intptr_t GetLength() { return m_SavingBuf.GetSize(); }
- const uint8_t* GetBuffer()
- {
- return m_SavingBuf.GetBuffer();
- }
+ const uint8_t* GetBuffer() { return m_SavingBuf.GetBuffer(); }
- void SetStream(IFX_FileStream* pStream)
- {
- m_pStream = pStream;
- }
-protected:
+ void SetStream(IFX_FileStream* pStream) { m_pStream = pStream; }
- CFX_BinaryBuf m_SavingBuf;
+ protected:
+ CFX_BinaryBuf m_SavingBuf;
- IFX_FileStream* m_pStream;
+ IFX_FileStream* m_pStream;
};
-class CFX_ArchiveLoader
-{
-public:
+class CFX_ArchiveLoader {
+ public:
+ CFX_ArchiveLoader(const uint8_t* pData, FX_DWORD dwSize);
- CFX_ArchiveLoader(const uint8_t* pData, FX_DWORD dwSize);
+ CFX_ArchiveLoader& operator>>(uint8_t& i);
- CFX_ArchiveLoader& operator >> (uint8_t& i);
+ CFX_ArchiveLoader& operator>>(int& i);
- CFX_ArchiveLoader& operator >> (int& i);
+ CFX_ArchiveLoader& operator>>(FX_DWORD& i);
- CFX_ArchiveLoader& operator >> (FX_DWORD& i);
+ CFX_ArchiveLoader& operator>>(FX_FLOAT& i);
- CFX_ArchiveLoader& operator >> (FX_FLOAT& i);
+ CFX_ArchiveLoader& operator>>(double& i);
- CFX_ArchiveLoader& operator >> (double& i);
+ CFX_ArchiveLoader& operator>>(CFX_ByteString& bstr);
- CFX_ArchiveLoader& operator >> (CFX_ByteString& bstr);
+ CFX_ArchiveLoader& operator>>(CFX_WideString& wstr);
- CFX_ArchiveLoader& operator >> (CFX_WideString& wstr);
+ FX_BOOL IsEOF();
- FX_BOOL IsEOF();
+ FX_BOOL Read(void* pBuf, FX_DWORD dwSize);
- FX_BOOL Read(void* pBuf, FX_DWORD dwSize);
-protected:
+ protected:
+ FX_DWORD m_LoadingPos;
- FX_DWORD m_LoadingPos;
-
- const uint8_t* m_pLoadingBuf;
-
- FX_DWORD m_LoadingSize;
+ const uint8_t* m_pLoadingBuf;
+ FX_DWORD m_LoadingSize;
};
-class IFX_BufferArchive
-{
-public:
- IFX_BufferArchive(FX_STRSIZE size);
- virtual ~IFX_BufferArchive() {}
-
- virtual void Clear();
-
- FX_BOOL Flush();
+class IFX_BufferArchive {
+ public:
+ IFX_BufferArchive(FX_STRSIZE size);
+ virtual ~IFX_BufferArchive() {}
- int32_t AppendBlock(const void* pBuf, size_t size);
+ virtual void Clear();
- int32_t AppendByte(uint8_t byte);
+ FX_BOOL Flush();
- int32_t AppendDWord(FX_DWORD i);
+ int32_t AppendBlock(const void* pBuf, size_t size);
+ int32_t AppendByte(uint8_t byte);
- int32_t AppendString(const CFX_ByteStringC& lpsz);
+ int32_t AppendDWord(FX_DWORD i);
-protected:
+ int32_t AppendString(const CFX_ByteStringC& lpsz);
- virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
+ protected:
+ virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
- FX_STRSIZE m_BufSize;
+ FX_STRSIZE m_BufSize;
- uint8_t* m_pBuffer;
+ uint8_t* m_pBuffer;
- FX_STRSIZE m_Length;
+ FX_STRSIZE m_Length;
};
-class CFX_FileBufferArchive : public IFX_BufferArchive
-{
-public:
- CFX_FileBufferArchive(FX_STRSIZE size = 32768);
- ~CFX_FileBufferArchive() override;
+class CFX_FileBufferArchive : public IFX_BufferArchive {
+ public:
+ CFX_FileBufferArchive(FX_STRSIZE size = 32768);
+ ~CFX_FileBufferArchive() override;
- void Clear() override;
+ void Clear() override;
- FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover = FALSE);
+ FX_BOOL AttachFile(IFX_StreamWrite* pFile, FX_BOOL bTakeover = FALSE);
- FX_BOOL AttachFile(const FX_WCHAR* filename);
+ FX_BOOL AttachFile(const FX_WCHAR* filename);
- FX_BOOL AttachFile(const FX_CHAR* filename);
+ FX_BOOL AttachFile(const FX_CHAR* filename);
-private:
- FX_BOOL DoWork(const void* pBuf, size_t size) override;
+ private:
+ FX_BOOL DoWork(const void* pBuf, size_t size) override;
- IFX_StreamWrite* m_pFile;
+ IFX_StreamWrite* m_pFile;
- FX_BOOL m_bTakeover;
+ FX_BOOL m_bTakeover;
};
struct CFX_CharMap {
+ static CFX_CharMap* GetDefaultMapper(int32_t codepage = 0);
- static CFX_CharMap* GetDefaultMapper(int32_t codepage = 0);
+ CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap,
+ const CFX_ByteString& bstr);
+ CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap,
+ const CFX_WideString& wstr);
- CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap, const CFX_ByteString& bstr);
-
- CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap, const CFX_WideString& wstr);
-
- int32_t (*m_GetCodePage)();
+ int32_t (*m_GetCodePage)();
};
-class CFX_UTF8Decoder
-{
-public:
- CFX_UTF8Decoder()
- {
- m_PendingBytes = 0;
- }
+class CFX_UTF8Decoder {
+ public:
+ CFX_UTF8Decoder() { m_PendingBytes = 0; }
- void Clear();
+ void Clear();
- void Input(uint8_t byte);
+ void Input(uint8_t byte);
- void AppendChar(FX_DWORD ch);
+ void AppendChar(FX_DWORD ch);
- void ClearStatus()
- {
- m_PendingBytes = 0;
- }
+ void ClearStatus() { m_PendingBytes = 0; }
- CFX_WideStringC GetResult() const
- {
- return m_Buffer.GetWideString();
- }
-protected:
+ CFX_WideStringC GetResult() const { return m_Buffer.GetWideString(); }
- int m_PendingBytes;
+ protected:
+ int m_PendingBytes;
- FX_DWORD m_PendingChar;
+ FX_DWORD m_PendingChar;
- CFX_WideTextBuf m_Buffer;
+ CFX_WideTextBuf m_Buffer;
};
-class CFX_UTF8Encoder
-{
-public:
- CFX_UTF8Encoder()
- {
- m_UTF16First = 0;
- }
+class CFX_UTF8Encoder {
+ public:
+ CFX_UTF8Encoder() { m_UTF16First = 0; }
- void Input(FX_WCHAR unicode);
+ void Input(FX_WCHAR unicode);
- void AppendStr(const CFX_ByteStringC& str)
- {
- m_UTF16First = 0;
- m_Buffer << str;
- }
+ void AppendStr(const CFX_ByteStringC& str) {
+ m_UTF16First = 0;
+ m_Buffer << str;
+ }
- CFX_ByteStringC GetResult() const
- {
- return m_Buffer.GetByteString();
- }
-protected:
+ CFX_ByteStringC GetResult() const { return m_Buffer.GetByteString(); }
- CFX_ByteTextBuf m_Buffer;
+ protected:
+ CFX_ByteTextBuf m_Buffer;
- FX_DWORD m_UTF16First;
+ FX_DWORD m_UTF16First;
};
CFX_ByteString FX_UrlEncode(const CFX_WideString& wsUrl);
CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl);
CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI);
CFX_WideString FX_DecodeURI(const CFX_ByteString& bsURI);
-class CFX_BasicArray
-{
-protected:
- CFX_BasicArray(int unit_size);
+class CFX_BasicArray {
+ protected:
+ CFX_BasicArray(int unit_size);
- ~CFX_BasicArray();
+ ~CFX_BasicArray();
- FX_BOOL SetSize(int nNewSize);
+ FX_BOOL SetSize(int nNewSize);
- FX_BOOL Append(const CFX_BasicArray& src);
+ FX_BOOL Append(const CFX_BasicArray& src);
- FX_BOOL Copy(const CFX_BasicArray& src);
+ FX_BOOL Copy(const CFX_BasicArray& src);
- uint8_t* InsertSpaceAt(int nIndex, int nCount);
+ uint8_t* InsertSpaceAt(int nIndex, int nCount);
- FX_BOOL RemoveAt(int nIndex, int nCount);
+ FX_BOOL RemoveAt(int nIndex, int nCount);
- FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray);
+ FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray);
- const void* GetDataPtr(int index) const;
-protected:
+ const void* GetDataPtr(int index) const;
- uint8_t* m_pData;
+ protected:
+ uint8_t* m_pData;
- int m_nSize;
+ int m_nSize;
- int m_nMaxSize;
+ int m_nMaxSize;
- int m_nUnitSize;
+ int m_nUnitSize;
};
-template<class TYPE>
-class CFX_ArrayTemplate : public CFX_BasicArray
-{
-public:
- CFX_ArrayTemplate() : CFX_BasicArray(sizeof(TYPE)) {}
-
- int GetSize() const
- {
- return m_nSize;
- }
+template <class TYPE>
+class CFX_ArrayTemplate : public CFX_BasicArray {
+ public:
+ CFX_ArrayTemplate() : CFX_BasicArray(sizeof(TYPE)) {}
- int GetUpperBound() const
- {
- return m_nSize - 1;
- }
+ int GetSize() const { return m_nSize; }
- FX_BOOL SetSize(int nNewSize)
- {
- return CFX_BasicArray::SetSize(nNewSize);
- }
+ int GetUpperBound() const { return m_nSize - 1; }
- void RemoveAll()
- {
- SetSize(0);
- }
+ FX_BOOL SetSize(int nNewSize) { return CFX_BasicArray::SetSize(nNewSize); }
- const TYPE GetAt(int nIndex) const
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- return (const TYPE&)(*(volatile const TYPE*)NULL);
- }
- return ((const TYPE*)m_pData)[nIndex];
- }
+ void RemoveAll() { SetSize(0); }
- FX_BOOL SetAt(int nIndex, TYPE newElement)
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- return FALSE;
- }
- ((TYPE*)m_pData)[nIndex] = newElement;
- return TRUE;
+ const TYPE GetAt(int nIndex) const {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ return (const TYPE&)(*(volatile const TYPE*)NULL);
}
+ return ((const TYPE*)m_pData)[nIndex];
+ }
- TYPE& ElementAt(int nIndex)
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- return *(TYPE*)NULL;
- }
- return ((TYPE*)m_pData)[nIndex];
+ FX_BOOL SetAt(int nIndex, TYPE newElement) {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ return FALSE;
}
+ ((TYPE*)m_pData)[nIndex] = newElement;
+ return TRUE;
+ }
- const TYPE* GetData() const
- {
- return (const TYPE*)m_pData;
+ TYPE& ElementAt(int nIndex) {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ return *(TYPE*)NULL;
}
+ return ((TYPE*)m_pData)[nIndex];
+ }
- TYPE* GetData()
- {
- return (TYPE*)m_pData;
- }
+ const TYPE* GetData() const { return (const TYPE*)m_pData; }
- FX_BOOL SetAtGrow(int nIndex, TYPE newElement)
- {
- if (nIndex < 0) {
- return FALSE;
- }
- if (nIndex >= m_nSize)
- if (!SetSize(nIndex + 1)) {
- return FALSE;
- }
- ((TYPE*)m_pData)[nIndex] = newElement;
- return TRUE;
- }
+ TYPE* GetData() { return (TYPE*)m_pData; }
- FX_BOOL Add(TYPE newElement)
- {
- if (m_nSize < m_nMaxSize) {
- m_nSize ++;
- } else if (!SetSize(m_nSize + 1)) {
- return FALSE;
- }
- ((TYPE*)m_pData)[m_nSize - 1] = newElement;
- return TRUE;
+ FX_BOOL SetAtGrow(int nIndex, TYPE newElement) {
+ if (nIndex < 0) {
+ return FALSE;
}
+ if (nIndex >= m_nSize)
+ if (!SetSize(nIndex + 1)) {
+ return FALSE;
+ }
+ ((TYPE*)m_pData)[nIndex] = newElement;
+ return TRUE;
+ }
- FX_BOOL Append(const CFX_ArrayTemplate& src)
- {
- return CFX_BasicArray::Append(src);
+ FX_BOOL Add(TYPE newElement) {
+ if (m_nSize < m_nMaxSize) {
+ m_nSize++;
+ } else if (!SetSize(m_nSize + 1)) {
+ return FALSE;
}
+ ((TYPE*)m_pData)[m_nSize - 1] = newElement;
+ return TRUE;
+ }
- FX_BOOL Copy(const CFX_ArrayTemplate& src)
- {
- return CFX_BasicArray::Copy(src);
- }
+ FX_BOOL Append(const CFX_ArrayTemplate& src) {
+ return CFX_BasicArray::Append(src);
+ }
- TYPE* GetDataPtr(int index)
- {
- return (TYPE*)CFX_BasicArray::GetDataPtr(index);
- }
+ FX_BOOL Copy(const CFX_ArrayTemplate& src) {
+ return CFX_BasicArray::Copy(src);
+ }
- TYPE* AddSpace()
- {
- return (TYPE*)CFX_BasicArray::InsertSpaceAt(m_nSize, 1);
- }
+ TYPE* GetDataPtr(int index) {
+ return (TYPE*)CFX_BasicArray::GetDataPtr(index);
+ }
- TYPE* InsertSpaceAt(int nIndex, int nCount)
- {
- return (TYPE*)CFX_BasicArray::InsertSpaceAt(nIndex, nCount);
- }
+ TYPE* AddSpace() { return (TYPE*)CFX_BasicArray::InsertSpaceAt(m_nSize, 1); }
- const TYPE operator[](int nIndex) const
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- *(volatile char*)0 = '\0';
- }
- return ((const TYPE*)m_pData)[nIndex];
- }
+ TYPE* InsertSpaceAt(int nIndex, int nCount) {
+ return (TYPE*)CFX_BasicArray::InsertSpaceAt(nIndex, nCount);
+ }
- TYPE& operator[](int nIndex)
- {
- if (nIndex < 0 || nIndex >= m_nSize) {
- *(volatile char*)0 = '\0';
- }
- return ((TYPE*)m_pData)[nIndex];
+ const TYPE operator[](int nIndex) const {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ *(volatile char*)0 = '\0';
}
+ return ((const TYPE*)m_pData)[nIndex];
+ }
- FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount = 1)
- {
- if (!InsertSpaceAt(nIndex, nCount)) {
- return FALSE;
- }
- while (nCount--) {
- ((TYPE*)m_pData)[nIndex++] = newElement;
- }
- return TRUE;
+ TYPE& operator[](int nIndex) {
+ if (nIndex < 0 || nIndex >= m_nSize) {
+ *(volatile char*)0 = '\0';
}
+ return ((TYPE*)m_pData)[nIndex];
+ }
- FX_BOOL RemoveAt(int nIndex, int nCount = 1)
- {
- return CFX_BasicArray::RemoveAt(nIndex, nCount);
+ FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount = 1) {
+ if (!InsertSpaceAt(nIndex, nCount)) {
+ return FALSE;
}
-
- FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray)
- {
- return CFX_BasicArray::InsertAt(nStartIndex, pNewArray);
+ while (nCount--) {
+ ((TYPE*)m_pData)[nIndex++] = newElement;
}
+ return TRUE;
+ }
- int Find(TYPE data, int iStart = 0) const
- {
- if (iStart < 0) {
- return -1;
- }
- for (; iStart < (int)m_nSize; iStart ++)
- if (((TYPE*)m_pData)[iStart] == data) {
- return iStart;
- }
- return -1;
+ FX_BOOL RemoveAt(int nIndex, int nCount = 1) {
+ return CFX_BasicArray::RemoveAt(nIndex, nCount);
+ }
+
+ FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray) {
+ return CFX_BasicArray::InsertAt(nStartIndex, pNewArray);
+ }
+
+ int Find(TYPE data, int iStart = 0) const {
+ if (iStart < 0) {
+ return -1;
}
+ for (; iStart < (int)m_nSize; iStart++)
+ if (((TYPE*)m_pData)[iStart] == data) {
+ return iStart;
+ }
+ return -1;
+ }
};
-typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray;
-typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray;
-typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray;
-typedef CFX_ArrayTemplate<void*> CFX_PtrArray;
-typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray;
-typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
-typedef CFX_ArrayTemplate<int32_t> CFX_Int32Array;
+typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray;
+typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray;
+typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray;
+typedef CFX_ArrayTemplate<void*> CFX_PtrArray;
+typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray;
+typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
+typedef CFX_ArrayTemplate<int32_t> CFX_Int32Array;
template <class ObjectClass>
-class CFX_ObjectArray : public CFX_BasicArray
-{
-public:
- CFX_ObjectArray() : CFX_BasicArray(sizeof(ObjectClass)) {}
-
- ~CFX_ObjectArray()
- {
- RemoveAll();
- }
+class CFX_ObjectArray : public CFX_BasicArray {
+ public:
+ CFX_ObjectArray() : CFX_BasicArray(sizeof(ObjectClass)) {}
- void Add(const ObjectClass& data)
- {
- new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
- }
+ ~CFX_ObjectArray() { RemoveAll(); }
- ObjectClass& Add()
- {
- return *(ObjectClass*) new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
- }
+ void Add(const ObjectClass& data) {
+ new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
+ }
- void* AddSpace()
- {
- return InsertSpaceAt(m_nSize, 1);
- }
+ ObjectClass& Add() {
+ return *(ObjectClass*)new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
+ }
- int32_t Append(const CFX_ObjectArray& src, int32_t nStart = 0, int32_t nCount = -1)
- {
- if (nCount == 0) {
- return 0;
- }
- int32_t nSize = src.GetSize();
- if (!nSize) {
- return 0;
- }
- FXSYS_assert(nStart > -1 && nStart < nSize);
- if (nCount < 0) {
- nCount = nSize;
- }
- if (nStart + nCount > nSize) {
- nCount = nSize - nStart;
- }
- if (nCount < 1) {
- return 0;
- }
- nSize = m_nSize;
- InsertSpaceAt(m_nSize, nCount);
- ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize);
- nSize = nStart + nCount;
- for (int32_t i = nStart; i < nSize; i ++, pStartObj++) {
- new ((void*)pStartObj) ObjectClass(src[i]);
- }
- return nCount;
- }
+ void* AddSpace() { return InsertSpaceAt(m_nSize, 1); }
- int32_t Copy(const CFX_ObjectArray& src, int32_t nStart = 0, int32_t nCount = -1)
- {
- if (nCount == 0) {
- return 0;
- }
- int32_t nSize = src.GetSize();
- if (!nSize) {
- return 0;
- }
- FXSYS_assert(nStart > -1 && nStart < nSize);
- if (nCount < 0) {
- nCount = nSize;
- }
- if (nStart + nCount > nSize) {
- nCount = nSize - nStart;
- }
- if (nCount < 1) {
- return 0;
- }
- RemoveAll();
- SetSize(nCount);
- ObjectClass* pStartObj = (ObjectClass*)m_pData;
- nSize = nStart + nCount;
- for (int32_t i = nStart; i < nSize; i ++, pStartObj++) {
- new ((void*)pStartObj) ObjectClass(src[i]);
- }
- return nCount;
+ int32_t Append(const CFX_ObjectArray& src,
+ int32_t nStart = 0,
+ int32_t nCount = -1) {
+ if (nCount == 0) {
+ return 0;
}
-
- int GetSize() const
- {
- return m_nSize;
+ int32_t nSize = src.GetSize();
+ if (!nSize) {
+ return 0;
}
-
- ObjectClass& operator[] (int index) const
- {
- FXSYS_assert(index < m_nSize);
- return *(ObjectClass*)CFX_BasicArray::GetDataPtr(index);
+ FXSYS_assert(nStart > -1 && nStart < nSize);
+ if (nCount < 0) {
+ nCount = nSize;
}
-
- ObjectClass* GetDataPtr(int index)
- {
- return (ObjectClass*)CFX_BasicArray::GetDataPtr(index);
+ if (nStart + nCount > nSize) {
+ nCount = nSize - nStart;
+ }
+ if (nCount < 1) {
+ return 0;
+ }
+ nSize = m_nSize;
+ InsertSpaceAt(m_nSize, nCount);
+ ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize);
+ nSize = nStart + nCount;
+ for (int32_t i = nStart; i < nSize; i++, pStartObj++) {
+ new ((void*)pStartObj) ObjectClass(src[i]);
}
+ return nCount;
+ }
- void RemoveAt(int index)
- {
- FXSYS_assert(index < m_nSize);
- ((ObjectClass*)GetDataPtr(index))->~ObjectClass();
- CFX_BasicArray::RemoveAt(index, 1);
+ int32_t Copy(const CFX_ObjectArray& src,
+ int32_t nStart = 0,
+ int32_t nCount = -1) {
+ if (nCount == 0) {
+ return 0;
+ }
+ int32_t nSize = src.GetSize();
+ if (!nSize) {
+ return 0;
+ }
+ FXSYS_assert(nStart > -1 && nStart < nSize);
+ if (nCount < 0) {
+ nCount = nSize;
+ }
+ if (nStart + nCount > nSize) {
+ nCount = nSize - nStart;
}
+ if (nCount < 1) {
+ return 0;
+ }
+ RemoveAll();
+ SetSize(nCount);
+ ObjectClass* pStartObj = (ObjectClass*)m_pData;
+ nSize = nStart + nCount;
+ for (int32_t i = nStart; i < nSize; i++, pStartObj++) {
+ new ((void*)pStartObj) ObjectClass(src[i]);
+ }
+ return nCount;
+ }
- void RemoveAll()
- {
- for (int i = 0; i < m_nSize; i ++) {
- ((ObjectClass*)GetDataPtr(i))->~ObjectClass();
- }
- CFX_BasicArray::SetSize(0);
+ int GetSize() const { return m_nSize; }
+
+ ObjectClass& operator[](int index) const {
+ FXSYS_assert(index < m_nSize);
+ return *(ObjectClass*)CFX_BasicArray::GetDataPtr(index);
+ }
+
+ ObjectClass* GetDataPtr(int index) {
+ return (ObjectClass*)CFX_BasicArray::GetDataPtr(index);
+ }
+
+ void RemoveAt(int index) {
+ FXSYS_assert(index < m_nSize);
+ ((ObjectClass*)GetDataPtr(index))->~ObjectClass();
+ CFX_BasicArray::RemoveAt(index, 1);
+ }
+
+ void RemoveAll() {
+ for (int i = 0; i < m_nSize; i++) {
+ ((ObjectClass*)GetDataPtr(i))->~ObjectClass();
}
+ CFX_BasicArray::SetSize(0);
+ }
};
typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray;
typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray;
-class CFX_BaseSegmentedArray
-{
-public:
- CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index_size = 8);
+class CFX_BaseSegmentedArray {
+ public:
+ CFX_BaseSegmentedArray(int unit_size = 1,
+ int segment_units = 512,
+ int index_size = 8);
- ~CFX_BaseSegmentedArray();
+ ~CFX_BaseSegmentedArray();
- void SetUnitSize(int unit_size, int segment_units, int index_size = 8);
+ void SetUnitSize(int unit_size, int segment_units, int index_size = 8);
- void* Add();
+ void* Add();
- void* GetAt(int index) const;
+ void* GetAt(int index) const;
- void RemoveAll();
+ void RemoveAll();
- void Delete(int index, int count = 1);
+ void Delete(int index, int count = 1);
- int GetSize() const
- {
- return m_DataSize;
- }
+ int GetSize() const { return m_DataSize; }
- int GetSegmentSize() const
- {
- return m_SegmentSize;
- }
+ int GetSegmentSize() const { return m_SegmentSize; }
- int GetUnitSize() const
- {
- return m_UnitSize;
- }
+ int GetUnitSize() const { return m_UnitSize; }
- void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* param) const;
-private:
+ void* Iterate(FX_BOOL (*callback)(void* param, void* pData),
+ void* param) const;
- int m_UnitSize;
+ private:
+ int m_UnitSize;
- short m_SegmentSize;
+ short m_SegmentSize;
- uint8_t m_IndexSize;
+ uint8_t m_IndexSize;
- uint8_t m_IndexDepth;
+ uint8_t m_IndexDepth;
- int m_DataSize;
+ int m_DataSize;
- void* m_pIndex;
- void** GetIndex(int seg_index) const;
- void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
- void* IterateSegment(const uint8_t* pSegment, int count, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
+ void* m_pIndex;
+ void** GetIndex(int seg_index) const;
+ void* IterateIndex(int level,
+ int& start,
+ void** pIndex,
+ FX_BOOL (*callback)(void* param, void* pData),
+ void* param) const;
+ void* IterateSegment(const uint8_t* pSegment,
+ int count,
+ FX_BOOL (*callback)(void* param, void* pData),
+ void* param) const;
};
template <class ElementType>
-class CFX_SegmentedArray : public CFX_BaseSegmentedArray
-{
-public:
- CFX_SegmentedArray(int segment_units, int index_size = 8)
- : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size)
- {}
-
- void Add(ElementType data)
- {
- *(ElementType*)CFX_BaseSegmentedArray::Add() = data;
- }
-
- ElementType& operator [] (int index)
- {
- return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index);
- }
+class CFX_SegmentedArray : public CFX_BaseSegmentedArray {
+ public:
+ CFX_SegmentedArray(int segment_units, int index_size = 8)
+ : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size) {
+ }
+
+ void Add(ElementType data) {
+ *(ElementType*)CFX_BaseSegmentedArray::Add() = data;
+ }
+
+ ElementType& operator[](int index) {
+ return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index);
+ }
};
template <class DataType, int FixedSize>
-class CFX_FixedBufGrow
-{
-public:
- CFX_FixedBufGrow() : m_pData(NULL)
- {}
- CFX_FixedBufGrow(int data_size) : m_pData(NULL)
- {
- if (data_size > FixedSize) {
- m_pData = FX_Alloc(DataType, data_size);
- } else {
- FXSYS_memset(m_Data, 0, sizeof(DataType)*FixedSize);
- }
- }
- void SetDataSize(int data_size)
- {
- if (m_pData) {
- FX_Free(m_pData);
- }
- m_pData = NULL;
- if (data_size > FixedSize) {
- m_pData = FX_Alloc(DataType, data_size);
- } else {
- FXSYS_memset(m_Data, 0, sizeof(DataType)*FixedSize);
- }
- }
- ~CFX_FixedBufGrow()
- {
- if (m_pData) {
- FX_Free(m_pData);
- }
- }
- operator DataType*()
- {
- return m_pData ? m_pData : m_Data;
- }
-private:
- DataType m_Data[FixedSize];
- DataType* m_pData;
+class CFX_FixedBufGrow {
+ public:
+ CFX_FixedBufGrow() : m_pData(NULL) {}
+ CFX_FixedBufGrow(int data_size) : m_pData(NULL) {
+ if (data_size > FixedSize) {
+ m_pData = FX_Alloc(DataType, data_size);
+ } else {
+ FXSYS_memset(m_Data, 0, sizeof(DataType) * FixedSize);
+ }
+ }
+ void SetDataSize(int data_size) {
+ if (m_pData) {
+ FX_Free(m_pData);
+ }
+ m_pData = NULL;
+ if (data_size > FixedSize) {
+ m_pData = FX_Alloc(DataType, data_size);
+ } else {
+ FXSYS_memset(m_Data, 0, sizeof(DataType) * FixedSize);
+ }
+ }
+ ~CFX_FixedBufGrow() {
+ if (m_pData) {
+ FX_Free(m_pData);
+ }
+ }
+ operator DataType*() { return m_pData ? m_pData : m_Data; }
+
+ private:
+ DataType m_Data[FixedSize];
+ DataType* m_pData;
};
-class CFX_MapPtrToPtr
-{
-protected:
-
- struct CAssoc {
+class CFX_MapPtrToPtr {
+ protected:
+ struct CAssoc {
+ CAssoc* pNext;
- CAssoc* pNext;
+ void* key;
- void* key;
+ void* value;
+ };
- void* value;
- };
-public:
- CFX_MapPtrToPtr(int nBlockSize = 10);
+ public:
+ CFX_MapPtrToPtr(int nBlockSize = 10);
- ~CFX_MapPtrToPtr();
+ ~CFX_MapPtrToPtr();
- int GetCount() const
- {
- return m_nCount;
- }
+ int GetCount() const { return m_nCount; }
- FX_BOOL IsEmpty() const
- {
- return m_nCount == 0;
- }
+ FX_BOOL IsEmpty() const { return m_nCount == 0; }
- FX_BOOL Lookup(void* key, void*& rValue) const;
+ FX_BOOL Lookup(void* key, void*& rValue) const;
- void* GetValueAt(void* key) const;
+ void* GetValueAt(void* key) const;
- void*& operator[](void* key);
+ void*& operator[](void* key);
- void SetAt(void* key, void* newValue)
- {
- (*this)[key] = newValue;
- }
+ void SetAt(void* key, void* newValue) { (*this)[key] = newValue; }
- FX_BOOL RemoveKey(void* key);
+ FX_BOOL RemoveKey(void* key);
- void RemoveAll();
+ void RemoveAll();
- FX_POSITION GetStartPosition() const
- {
- return (m_nCount == 0) ? NULL : (FX_POSITION) - 1;
- }
+ FX_POSITION GetStartPosition() const {
+ return (m_nCount == 0) ? NULL : (FX_POSITION)-1;
+ }
- void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) const;
+ void GetNextAssoc(FX_POSITION& rNextPosition,
+ void*& rKey,
+ void*& rValue) const;
- FX_DWORD GetHashTableSize() const
- {
- return m_nHashTableSize;
- }
+ FX_DWORD GetHashTableSize() const { return m_nHashTableSize; }
- void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
-protected:
+ void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
- CAssoc** m_pHashTable;
+ protected:
+ CAssoc** m_pHashTable;
- FX_DWORD m_nHashTableSize;
+ FX_DWORD m_nHashTableSize;
- int m_nCount;
+ int m_nCount;
- CAssoc* m_pFreeList;
+ CAssoc* m_pFreeList;
- struct CFX_Plex* m_pBlocks;
+ struct CFX_Plex* m_pBlocks;
- int m_nBlockSize;
+ int m_nBlockSize;
- FX_DWORD HashKey(void* key) const;
+ FX_DWORD HashKey(void* key) const;
- CAssoc* NewAssoc();
+ CAssoc* NewAssoc();
- void FreeAssoc(CAssoc* pAssoc);
+ void FreeAssoc(CAssoc* pAssoc);
- CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const;
+ CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const;
};
template <class KeyType, class ValueType>
-class CFX_MapPtrTemplate : public CFX_MapPtrToPtr
-{
-public:
- CFX_MapPtrTemplate() : CFX_MapPtrToPtr(10) {}
-
- FX_BOOL Lookup(KeyType key, ValueType& rValue) const
- {
- void* pValue = NULL;
- if (!CFX_MapPtrToPtr::Lookup((void*)(uintptr_t)key, pValue)) {
- return FALSE;
- }
- rValue = (ValueType)(uintptr_t)pValue;
- return TRUE;
- }
-
- ValueType& operator[](KeyType key)
- {
- return (ValueType&)CFX_MapPtrToPtr::operator []((void*)(uintptr_t)key);
- }
-
- void SetAt(KeyType key, ValueType newValue)
- {
- CFX_MapPtrToPtr::SetAt((void*)(uintptr_t)key, (void*)(uintptr_t)newValue);
- }
-
- FX_BOOL RemoveKey(KeyType key)
- {
- return CFX_MapPtrToPtr::RemoveKey((void*)(uintptr_t)key);
- }
-
- void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey, ValueType& rValue) const
- {
- void* pKey = NULL;
- void* pValue = NULL;
- CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue);
- rKey = (KeyType)(uintptr_t)pKey;
- rValue = (ValueType)(uintptr_t)pValue;
- }
+class CFX_MapPtrTemplate : public CFX_MapPtrToPtr {
+ public:
+ CFX_MapPtrTemplate() : CFX_MapPtrToPtr(10) {}
+
+ FX_BOOL Lookup(KeyType key, ValueType& rValue) const {
+ void* pValue = NULL;
+ if (!CFX_MapPtrToPtr::Lookup((void*)(uintptr_t)key, pValue)) {
+ return FALSE;
+ }
+ rValue = (ValueType)(uintptr_t)pValue;
+ return TRUE;
+ }
+
+ ValueType& operator[](KeyType key) {
+ return (ValueType&)CFX_MapPtrToPtr::operator[]((void*)(uintptr_t)key);
+ }
+
+ void SetAt(KeyType key, ValueType newValue) {
+ CFX_MapPtrToPtr::SetAt((void*)(uintptr_t)key, (void*)(uintptr_t)newValue);
+ }
+
+ FX_BOOL RemoveKey(KeyType key) {
+ return CFX_MapPtrToPtr::RemoveKey((void*)(uintptr_t)key);
+ }
+
+ void GetNextAssoc(FX_POSITION& rNextPosition,
+ KeyType& rKey,
+ ValueType& rValue) const {
+ void* pKey = NULL;
+ void* pValue = NULL;
+ CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue);
+ rKey = (KeyType)(uintptr_t)pKey;
+ rValue = (ValueType)(uintptr_t)pValue;
+ }
};
-class CFX_CMapDWordToDWord
-{
-public:
-
- FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const;
+class CFX_CMapDWordToDWord {
+ public:
+ FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const;
- void SetAt(FX_DWORD key, FX_DWORD value);
+ void SetAt(FX_DWORD key, FX_DWORD value);
- void EstimateSize(FX_DWORD size, FX_DWORD grow_by);
+ void EstimateSize(FX_DWORD size, FX_DWORD grow_by);
- FX_POSITION GetStartPosition() const;
+ FX_POSITION GetStartPosition() const;
- void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const;
-protected:
+ void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const;
- CFX_BinaryBuf m_Buffer;
+ protected:
+ CFX_BinaryBuf m_Buffer;
};
-class CFX_MapByteStringToPtr
-{
-protected:
+class CFX_MapByteStringToPtr {
+ protected:
+ struct CAssoc {
+ CAssoc* pNext;
- struct CAssoc {
+ FX_DWORD nHashValue;
- CAssoc* pNext;
+ CFX_ByteString key;
- FX_DWORD nHashValue;
+ void* value;
+ };
- CFX_ByteString key;
+ public:
+ CFX_MapByteStringToPtr(int nBlockSize = 10);
- void* value;
- };
-public:
- CFX_MapByteStringToPtr(int nBlockSize = 10);
+ int GetCount() const { return m_nCount; }
- int GetCount() const
- {
- return m_nCount;
- }
+ FX_BOOL IsEmpty() const { return m_nCount == 0; }
- FX_BOOL IsEmpty() const
- {
- return m_nCount == 0;
- }
+ FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const;
- FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const;
+ void*& operator[](const CFX_ByteStringC& key);
- void*& operator[](const CFX_ByteStringC& key);
+ void SetAt(const CFX_ByteStringC& key, void* newValue) {
+ (*this)[key] = newValue;
+ }
- void SetAt(const CFX_ByteStringC& key, void* newValue)
- {
- (*this)[key] = newValue;
- }
+ FX_BOOL RemoveKey(const CFX_ByteStringC& key);
- FX_BOOL RemoveKey(const CFX_ByteStringC& key);
+ void RemoveAll();
- void RemoveAll();
+ FX_POSITION GetStartPosition() const {
+ return (m_nCount == 0) ? NULL : (FX_POSITION)-1;
+ }
- FX_POSITION GetStartPosition() const
- {
- return (m_nCount == 0) ? NULL : (FX_POSITION) - 1;
- }
+ void GetNextAssoc(FX_POSITION& rNextPosition,
+ CFX_ByteString& rKey,
+ void*& rValue) const;
- void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
+ void* GetNextValue(FX_POSITION& rNextPosition) const;
- void* GetNextValue(FX_POSITION& rNextPosition) const;
+ FX_DWORD GetHashTableSize() const { return m_nHashTableSize; }
- FX_DWORD GetHashTableSize() const
- {
- return m_nHashTableSize;
- }
-
- void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
+ void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
- FX_DWORD HashKey(const CFX_ByteStringC& key) const;
-protected:
+ FX_DWORD HashKey(const CFX_ByteStringC& key) const;
- CAssoc** m_pHashTable;
+ protected:
+ CAssoc** m_pHashTable;
- FX_DWORD m_nHashTableSize;
+ FX_DWORD m_nHashTableSize;
- int m_nCount;
+ int m_nCount;
- CAssoc* m_pFreeList;
+ CAssoc* m_pFreeList;
- struct CFX_Plex* m_pBlocks;
+ struct CFX_Plex* m_pBlocks;
- int m_nBlockSize;
+ int m_nBlockSize;
- CAssoc* NewAssoc();
+ CAssoc* NewAssoc();
- void FreeAssoc(CAssoc* pAssoc);
+ void FreeAssoc(CAssoc* pAssoc);
- CAssoc* GetAssocAt(const CFX_ByteStringC& key, FX_DWORD& hash) const;
-public:
+ CAssoc* GetAssocAt(const CFX_ByteStringC& key, FX_DWORD& hash) const;
- ~CFX_MapByteStringToPtr();
+ public:
+ ~CFX_MapByteStringToPtr();
};
-class CFX_CMapByteStringToPtr
-{
-public:
- CFX_CMapByteStringToPtr();
+class CFX_CMapByteStringToPtr {
+ public:
+ CFX_CMapByteStringToPtr();
- ~CFX_CMapByteStringToPtr();
+ ~CFX_CMapByteStringToPtr();
- void RemoveAll();
+ void RemoveAll();
- FX_POSITION GetStartPosition() const;
+ FX_POSITION GetStartPosition() const;
- void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
+ void GetNextAssoc(FX_POSITION& rNextPosition,
+ CFX_ByteString& rKey,
+ void*& rValue) const;
- void* GetNextValue(FX_POSITION& rNextPosition) const;
+ void* GetNextValue(FX_POSITION& rNextPosition) const;
- FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const;
+ FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const;
- void SetAt(const CFX_ByteStringC& key, void* value);
+ void SetAt(const CFX_ByteStringC& key, void* value);
- void RemoveKey(const CFX_ByteStringC& key);
+ void RemoveKey(const CFX_ByteStringC& key);
- int GetCount() const;
+ int GetCount() const;
- void AddValue(const CFX_ByteStringC& key, void* pValue);
-private:
+ void AddValue(const CFX_ByteStringC& key, void* pValue);
- CFX_BaseSegmentedArray m_Buffer;
+ private:
+ CFX_BaseSegmentedArray m_Buffer;
};
-class CFX_PtrList
-{
-protected:
+class CFX_PtrList {
+ protected:
+ struct CNode {
+ CNode* pNext;
- struct CNode {
+ CNode* pPrev;
- CNode* pNext;
+ void* data;
+ };
- CNode* pPrev;
+ public:
+ CFX_PtrList(int nBlockSize = 10);
- void* data;
- };
-public:
- CFX_PtrList(int nBlockSize = 10);
+ FX_POSITION GetHeadPosition() const { return (FX_POSITION)m_pNodeHead; }
- FX_POSITION GetHeadPosition() const
- {
- return (FX_POSITION)m_pNodeHead;
- }
+ FX_POSITION GetTailPosition() const { return (FX_POSITION)m_pNodeTail; }
- FX_POSITION GetTailPosition() const
- {
- return (FX_POSITION)m_pNodeTail;
- }
-
- void* GetNext(FX_POSITION& rPosition) const
- {
- CNode* pNode = (CNode*) rPosition;
- rPosition = (FX_POSITION) pNode->pNext;
- return pNode->data;
- }
+ void* GetNext(FX_POSITION& rPosition) const {
+ CNode* pNode = (CNode*)rPosition;
+ rPosition = (FX_POSITION)pNode->pNext;
+ return pNode->data;
+ }
- void* GetPrev(FX_POSITION& rPosition) const
- {
- CNode* pNode = (CNode*) rPosition;
- rPosition = (FX_POSITION) pNode->pPrev;
- return pNode->data;
- }
+ void* GetPrev(FX_POSITION& rPosition) const {
+ CNode* pNode = (CNode*)rPosition;
+ rPosition = (FX_POSITION)pNode->pPrev;
+ return pNode->data;
+ }
- FX_POSITION GetNextPosition(FX_POSITION pos) const
- {
- return ((CNode*)pos)->pNext;
- }
+ FX_POSITION GetNextPosition(FX_POSITION pos) const {
+ return ((CNode*)pos)->pNext;
+ }
- FX_POSITION GetPrevPosition(FX_POSITION pos) const
- {
- return ((CNode*)pos)->pPrev;
- }
+ FX_POSITION GetPrevPosition(FX_POSITION pos) const {
+ return ((CNode*)pos)->pPrev;
+ }
- void* GetAt(FX_POSITION rPosition) const
- {
- CNode* pNode = (CNode*) rPosition;
- return pNode->data;
- }
+ void* GetAt(FX_POSITION rPosition) const {
+ CNode* pNode = (CNode*)rPosition;
+ return pNode->data;
+ }
- int GetCount() const
- {
- return m_nCount;
- }
+ int GetCount() const { return m_nCount; }
- FX_POSITION AddTail(void* newElement);
+ FX_POSITION AddTail(void* newElement);
- FX_POSITION AddHead(void* newElement);
+ FX_POSITION AddHead(void* newElement);
- void SetAt(FX_POSITION pos, void* newElement)
- {
- CNode* pNode = (CNode*) pos;
- pNode->data = newElement;
- }
+ void SetAt(FX_POSITION pos, void* newElement) {
+ CNode* pNode = (CNode*)pos;
+ pNode->data = newElement;
+ }
- FX_POSITION InsertAfter(FX_POSITION pos, void* newElement);
+ FX_POSITION InsertAfter(FX_POSITION pos, void* newElement);
- FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL ) const;
+ FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL) const;
- FX_POSITION FindIndex(int index) const;
+ FX_POSITION FindIndex(int index) const;
- void RemoveAt(FX_POSITION pos);
+ void RemoveAt(FX_POSITION pos);
- void RemoveAll();
-protected:
+ void RemoveAll();
- CNode* m_pNodeHead;
+ protected:
+ CNode* m_pNodeHead;
- CNode* m_pNodeTail;
+ CNode* m_pNodeTail;
- int m_nCount;
+ int m_nCount;
- CNode* m_pNodeFree;
+ CNode* m_pNodeFree;
- struct CFX_Plex* m_pBlocks;
+ struct CFX_Plex* m_pBlocks;
- int m_nBlockSize;
+ int m_nBlockSize;
- CNode* NewNode(CNode* pPrev, CNode* pNext);
+ CNode* NewNode(CNode* pPrev, CNode* pNext);
- void FreeNode(CNode* pNode);
-public:
+ void FreeNode(CNode* pNode);
- ~CFX_PtrList();
+ public:
+ ~CFX_PtrList();
};
typedef void (*PD_CALLBACK_FREEDATA)(void* pData);
struct FX_PRIVATEDATA {
+ void FreeData();
- void FreeData();
-
- void* m_pModuleId;
+ void* m_pModuleId;
- void* m_pData;
+ void* m_pData;
- PD_CALLBACK_FREEDATA m_pCallback;
+ PD_CALLBACK_FREEDATA m_pCallback;
- FX_BOOL m_bSelfDestruct;
+ FX_BOOL m_bSelfDestruct;
};
-class CFX_PrivateData
-{
-public:
+class CFX_PrivateData {
+ public:
+ ~CFX_PrivateData();
- ~CFX_PrivateData();
+ void ClearAll();
- void ClearAll();
+ void SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback);
- void SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback);
+ void SetPrivateObj(void* module_id, CFX_DestructObject* pObj);
- void SetPrivateObj(void* module_id, CFX_DestructObject* pObj);
+ void* GetPrivateData(void* module_id);
- void* GetPrivateData(void* module_id);
-
- FX_BOOL LookupPrivateData(void* module_id, void* &pData) const
- {
- if (!module_id) {
- return FALSE;
- }
- FX_DWORD nCount = m_DataList.GetSize();
- for (FX_DWORD n = 0; n < nCount; n ++) {
- if (m_DataList[n].m_pModuleId == module_id) {
- pData = m_DataList[n].m_pData;
- return TRUE;
- }
- }
- return FALSE;
+ FX_BOOL LookupPrivateData(void* module_id, void*& pData) const {
+ if (!module_id) {
+ return FALSE;
+ }
+ FX_DWORD nCount = m_DataList.GetSize();
+ for (FX_DWORD n = 0; n < nCount; n++) {
+ if (m_DataList[n].m_pModuleId == module_id) {
+ pData = m_DataList[n].m_pData;
+ return TRUE;
+ }
}
+ return FALSE;
+ }
- FX_BOOL RemovePrivateData(void* module_id);
-protected:
+ FX_BOOL RemovePrivateData(void* module_id);
- CFX_ArrayTemplate<FX_PRIVATEDATA> m_DataList;
+ protected:
+ CFX_ArrayTemplate<FX_PRIVATEDATA> m_DataList;
- void AddData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback, FX_BOOL bSelfDestruct);
+ void AddData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback,
+ FX_BOOL bSelfDestruct);
};
-class CFX_BitStream
-{
-public:
+class CFX_BitStream {
+ public:
+ void Init(const uint8_t* pData, FX_DWORD dwSize);
- void Init(const uint8_t* pData, FX_DWORD dwSize);
+ FX_DWORD GetBits(FX_DWORD nBits);
+ void ByteAlign();
- FX_DWORD GetBits(FX_DWORD nBits);
+ FX_BOOL IsEOF() { return m_BitPos >= m_BitSize; }
- void ByteAlign();
+ void SkipBits(FX_DWORD nBits) { m_BitPos += nBits; }
- FX_BOOL IsEOF()
- {
- return m_BitPos >= m_BitSize;
- }
+ void Rewind() { m_BitPos = 0; }
- void SkipBits(FX_DWORD nBits)
- {
- m_BitPos += nBits;
- }
-
- void Rewind()
- {
- m_BitPos = 0;
- }
-protected:
+ protected:
+ FX_DWORD m_BitPos;
- FX_DWORD m_BitPos;
+ FX_DWORD m_BitSize;
- FX_DWORD m_BitSize;
-
- const uint8_t* m_pData;
+ const uint8_t* m_pData;
};
-template <class ObjClass> class CFX_CountRef
-{
-public:
-
- typedef CFX_CountRef<ObjClass> Ref;
+template <class ObjClass>
+class CFX_CountRef {
+ public:
+ typedef CFX_CountRef<ObjClass> Ref;
- class CountedObj : public ObjClass
- {
- public:
+ class CountedObj : public ObjClass {
+ public:
+ CountedObj() {}
- CountedObj() {}
+ CountedObj(const CountedObj& src) : ObjClass(src) {}
- CountedObj(const CountedObj& src) : ObjClass(src) {}
+ int m_RefCount;
+ };
- int m_RefCount;
- };
+ CFX_CountRef() { m_pObject = NULL; }
- CFX_CountRef()
- {
- m_pObject = NULL;
+ CFX_CountRef(const Ref& ref) {
+ m_pObject = ref.m_pObject;
+ if (m_pObject) {
+ m_pObject->m_RefCount++;
}
+ }
- CFX_CountRef(const Ref& ref)
- {
- m_pObject = ref.m_pObject;
- if (m_pObject) {
- m_pObject->m_RefCount ++;
- }
+ ~CFX_CountRef() {
+ if (!m_pObject) {
+ return;
}
-
- ~CFX_CountRef()
- {
- if (!m_pObject) {
- return;
- }
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
+ m_pObject->m_RefCount--;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
}
+ }
- ObjClass* New()
- {
- if (m_pObject) {
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
- m_pObject = NULL;
- }
- m_pObject = FX_NEW CountedObj;
- if (!m_pObject) {
- return NULL;
- }
- m_pObject->m_RefCount = 1;
- return m_pObject;
+ ObjClass* New() {
+ if (m_pObject) {
+ m_pObject->m_RefCount--;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
+ }
+ m_pObject = NULL;
}
-
- void operator = (const Ref& ref)
- {
- if (ref.m_pObject) {
- ref.m_pObject->m_RefCount ++;
- }
- if (m_pObject) {
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
- }
- m_pObject = ref.m_pObject;
+ m_pObject = FX_NEW CountedObj;
+ if (!m_pObject) {
+ return NULL;
}
+ m_pObject->m_RefCount = 1;
+ return m_pObject;
+ }
- void operator = (void* p)
- {
- FXSYS_assert(p == 0);
- if (m_pObject == NULL) {
- return;
- }
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
- m_pObject = NULL;
+ void operator=(const Ref& ref) {
+ if (ref.m_pObject) {
+ ref.m_pObject->m_RefCount++;
}
-
- const ObjClass* GetObject() const
- {
- return m_pObject;
+ if (m_pObject) {
+ m_pObject->m_RefCount--;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
+ }
}
+ m_pObject = ref.m_pObject;
+ }
- operator const ObjClass*() const
- {
- return m_pObject;
+ void operator=(void* p) {
+ FXSYS_assert(p == 0);
+ if (m_pObject == NULL) {
+ return;
}
-
- FX_BOOL IsNull() const
- {
- return m_pObject == NULL;
+ m_pObject->m_RefCount--;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
}
+ m_pObject = NULL;
+ }
- FX_BOOL NotNull() const
- {
- return m_pObject != NULL;
- }
+ const ObjClass* GetObject() const { return m_pObject; }
- ObjClass* GetModify()
- {
- if (m_pObject == NULL) {
- m_pObject = FX_NEW CountedObj;
- if (m_pObject) {
- m_pObject->m_RefCount = 1;
- }
- } else if (m_pObject->m_RefCount > 1) {
- m_pObject->m_RefCount --;
- CountedObj* pOldObject = m_pObject;
- m_pObject = NULL;
- m_pObject = FX_NEW CountedObj(*pOldObject);
- if (m_pObject) {
- m_pObject->m_RefCount = 1;
- }
- }
- return m_pObject;
- }
+ operator const ObjClass*() const { return m_pObject; }
- void SetNull()
- {
- if (m_pObject == NULL) {
- return;
- }
- m_pObject->m_RefCount --;
- if (m_pObject->m_RefCount <= 0) {
- delete m_pObject;
- }
- m_pObject = NULL;
+ FX_BOOL IsNull() const { return m_pObject == NULL; }
+
+ FX_BOOL NotNull() const { return m_pObject != NULL; }
+
+ ObjClass* GetModify() {
+ if (m_pObject == NULL) {
+ m_pObject = FX_NEW CountedObj;
+ if (m_pObject) {
+ m_pObject->m_RefCount = 1;
+ }
+ } else if (m_pObject->m_RefCount > 1) {
+ m_pObject->m_RefCount--;
+ CountedObj* pOldObject = m_pObject;
+ m_pObject = NULL;
+ m_pObject = FX_NEW CountedObj(*pOldObject);
+ if (m_pObject) {
+ m_pObject->m_RefCount = 1;
+ }
}
+ return m_pObject;
+ }
- FX_BOOL operator == (const Ref& ref) const
- {
- return m_pObject == ref.m_pObject;
+ void SetNull() {
+ if (m_pObject == NULL) {
+ return;
+ }
+ m_pObject->m_RefCount--;
+ if (m_pObject->m_RefCount <= 0) {
+ delete m_pObject;
}
-protected:
+ m_pObject = NULL;
+ }
+
+ FX_BOOL operator==(const Ref& ref) const {
+ return m_pObject == ref.m_pObject;
+ }
- CountedObj* m_pObject;
+ protected:
+ CountedObj* m_pObject;
};
-class IFX_Pause
-{
-public:
- virtual ~IFX_Pause() { }
- virtual FX_BOOL NeedToPauseNow() = 0;
+class IFX_Pause {
+ public:
+ virtual ~IFX_Pause() {}
+ virtual FX_BOOL NeedToPauseNow() = 0;
};
-class CFX_DataFilter
-{
-public:
+class CFX_DataFilter {
+ public:
+ virtual ~CFX_DataFilter();
- virtual ~CFX_DataFilter();
+ void SetDestFilter(CFX_DataFilter* pFilter);
- void SetDestFilter(CFX_DataFilter* pFilter);
+ FX_BOOL IsEOF() const { return m_bEOF; }
- FX_BOOL IsEOF() const
- {
- return m_bEOF;
- }
-
- FX_DWORD GetSrcPos()
- {
- return m_SrcPos;
- }
+ FX_DWORD GetSrcPos() { return m_SrcPos; }
- void FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
+ void FilterIn(const uint8_t* src_buf,
+ FX_DWORD src_size,
+ CFX_BinaryBuf& dest_buf);
- void FilterFinish(CFX_BinaryBuf& dest_buf);
-protected:
+ void FilterFinish(CFX_BinaryBuf& dest_buf);
- CFX_DataFilter();
- virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0;
- virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0;
- void ReportEOF(FX_DWORD left_input);
+ protected:
+ CFX_DataFilter();
+ virtual void v_FilterIn(const uint8_t* src_buf,
+ FX_DWORD src_size,
+ CFX_BinaryBuf& dest_buf) = 0;
+ virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0;
+ void ReportEOF(FX_DWORD left_input);
- FX_BOOL m_bEOF;
+ FX_BOOL m_bEOF;
- FX_DWORD m_SrcPos;
+ FX_DWORD m_SrcPos;
- CFX_DataFilter* m_pDestFilter;
+ CFX_DataFilter* m_pDestFilter;
};
-template<typename T>
+template <typename T>
class CFX_AutoRestorer {
-public:
- explicit CFX_AutoRestorer(T* location) {
- m_Location = location;
- m_OldValue = *location;
- }
- ~CFX_AutoRestorer() { *m_Location = m_OldValue; }
-
-private:
+ public:
+ explicit CFX_AutoRestorer(T* location) {
+ m_Location = location;
+ m_OldValue = *location;
+ }
+ ~CFX_AutoRestorer() { *m_Location = m_OldValue; }
+
+ private:
T* m_Location;
T m_OldValue;
};
template <class T>
-class CFX_SmartPointer
-{
-public:
- CFX_SmartPointer(T *pObj) : m_pObj(pObj) {}
- ~CFX_SmartPointer()
- {
- m_pObj->Release();
- }
- T* Get(void)
- {
- return m_pObj;
- }
- T& operator *(void)
- {
- return *m_pObj;
- }
- T* operator ->(void)
- {
- return m_pObj;
- }
-protected:
- T *m_pObj;
+class CFX_SmartPointer {
+ public:
+ CFX_SmartPointer(T* pObj) : m_pObj(pObj) {}
+ ~CFX_SmartPointer() { m_pObj->Release(); }
+ T* Get(void) { return m_pObj; }
+ T& operator*(void) { return *m_pObj; }
+ T* operator->(void) { return m_pObj; }
+
+ protected:
+ T* m_pObj;
};
-#define FX_DATALIST_LENGTH 1024
-template<size_t unit>
-class CFX_SortListArray
-{
-protected:
-
- struct DataList {
-
- int32_t start;
-
- int32_t count;
- uint8_t* data;
- };
-public:
-
- CFX_SortListArray() : m_CurList(0) {}
-
- ~CFX_SortListArray()
- {
- Clear();
- }
-
-
- void Clear()
- {
- for (int32_t i = m_DataLists.GetUpperBound(); i >= 0; i--) {
- DataList list = m_DataLists.ElementAt(i);
- if (list.data) {
- FX_Free(list.data);
- }
- }
- m_DataLists.RemoveAll();
- m_CurList = 0;
- }
-
- void Append(int32_t nStart, int32_t nCount)
- {
- if (nStart < 0) {
- return;
- }
- while (nCount > 0) {
- int32_t temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
- DataList list;
- list.data = FX_Alloc2D(uint8_t, temp_count, unit);
- list.start = nStart;
- list.count = temp_count;
- Append(list);
- nCount -= temp_count;
- nStart += temp_count;
- }
- }
-
- uint8_t* GetAt(int32_t nIndex)
- {
- if (nIndex < 0) {
- return NULL;
- }
- if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) {
- return NULL;
+#define FX_DATALIST_LENGTH 1024
+template <size_t unit>
+class CFX_SortListArray {
+ protected:
+ struct DataList {
+ int32_t start;
+
+ int32_t count;
+ uint8_t* data;
+ };
+
+ public:
+ CFX_SortListArray() : m_CurList(0) {}
+
+ ~CFX_SortListArray() { Clear(); }
+
+ void Clear() {
+ for (int32_t i = m_DataLists.GetUpperBound(); i >= 0; i--) {
+ DataList list = m_DataLists.ElementAt(i);
+ if (list.data) {
+ FX_Free(list.data);
+ }
+ }
+ m_DataLists.RemoveAll();
+ m_CurList = 0;
+ }
+
+ void Append(int32_t nStart, int32_t nCount) {
+ if (nStart < 0) {
+ return;
+ }
+ while (nCount > 0) {
+ int32_t temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
+ DataList list;
+ list.data = FX_Alloc2D(uint8_t, temp_count, unit);
+ list.start = nStart;
+ list.count = temp_count;
+ Append(list);
+ nCount -= temp_count;
+ nStart += temp_count;
+ }
+ }
+
+ uint8_t* GetAt(int32_t nIndex) {
+ if (nIndex < 0) {
+ return NULL;
+ }
+ if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) {
+ return NULL;
+ }
+ DataList* pCurList = m_DataLists.GetDataPtr(m_CurList);
+ if (!pCurList || nIndex < pCurList->start ||
+ nIndex >= pCurList->start + pCurList->count) {
+ pCurList = NULL;
+ int32_t iStart = 0;
+ int32_t iEnd = m_DataLists.GetUpperBound();
+ int32_t iMid = 0;
+ while (iStart <= iEnd) {
+ iMid = (iStart + iEnd) / 2;
+ DataList* list = m_DataLists.GetDataPtr(iMid);
+ if (nIndex < list->start) {
+ iEnd = iMid - 1;
+ } else if (nIndex >= list->start + list->count) {
+ iStart = iMid + 1;
+ } else {
+ pCurList = list;
+ m_CurList = iMid;
+ break;
}
- DataList *pCurList = m_DataLists.GetDataPtr(m_CurList);
- if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count) {
- pCurList = NULL;
- int32_t iStart = 0;
- int32_t iEnd = m_DataLists.GetUpperBound();
- int32_t iMid = 0;
- while (iStart <= iEnd) {
- iMid = (iStart + iEnd) / 2;
- DataList* list = m_DataLists.GetDataPtr(iMid);
- if (nIndex < list->start) {
- iEnd = iMid - 1;
- } else if (nIndex >= list->start + list->count) {
- iStart = iMid + 1;
- } else {
- pCurList = list;
- m_CurList = iMid;
- break;
- }
- }
+ }
+ }
+ return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : NULL;
+ }
+
+ protected:
+ void Append(const DataList& list) {
+ int32_t iStart = 0;
+ int32_t iEnd = m_DataLists.GetUpperBound();
+ int32_t iFind = 0;
+ while (iStart <= iEnd) {
+ int32_t iMid = (iStart + iEnd) / 2;
+ DataList* cur_list = m_DataLists.GetDataPtr(iMid);
+ if (list.start < cur_list->start + cur_list->count) {
+ iEnd = iMid - 1;
+ } else {
+ if (iMid == iEnd) {
+ iFind = iMid + 1;
+ break;
}
- return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : NULL;
- }
-protected:
- void Append(const DataList& list)
- {
- int32_t iStart = 0;
- int32_t iEnd = m_DataLists.GetUpperBound();
- int32_t iFind = 0;
- while (iStart <= iEnd) {
- int32_t iMid = (iStart + iEnd) / 2;
- DataList* cur_list = m_DataLists.GetDataPtr(iMid);
- if (list.start < cur_list->start + cur_list->count) {
- iEnd = iMid - 1;
- } else {
- if (iMid == iEnd) {
- iFind = iMid + 1;
- break;
- }
- DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
- if (list.start < next_list->start) {
- iFind = iMid + 1;
- break;
- } else {
- iStart = iMid + 1;
- }
- }
+ DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
+ if (list.start < next_list->start) {
+ iFind = iMid + 1;
+ break;
+ } else {
+ iStart = iMid + 1;
}
- m_DataLists.InsertAt(iFind, list);
+ }
}
- int32_t m_CurList;
- CFX_ArrayTemplate<DataList> m_DataLists;
+ m_DataLists.InsertAt(iFind, list);
+ }
+ int32_t m_CurList;
+ CFX_ArrayTemplate<DataList> m_DataLists;
};
-template<typename T1, typename T2>
-class CFX_ListArrayTemplate
-{
-public:
-
- void Clear()
- {
- m_Data.Clear();
- }
+template <typename T1, typename T2>
+class CFX_ListArrayTemplate {
+ public:
+ void Clear() { m_Data.Clear(); }
- void Add(int32_t nStart, int32_t nCount)
- {
- m_Data.Append(nStart, nCount);
- }
+ void Add(int32_t nStart, int32_t nCount) { m_Data.Append(nStart, nCount); }
- T2& operator [] (int32_t nIndex)
- {
- uint8_t* data = m_Data.GetAt(nIndex);
- FXSYS_assert(data != NULL);
- return (T2&)(*(volatile T2*)data);
- }
+ T2& operator[](int32_t nIndex) {
+ uint8_t* data = m_Data.GetAt(nIndex);
+ FXSYS_assert(data != NULL);
+ return (T2&)(*(volatile T2*)data);
+ }
- T2* GetPtrAt(int32_t nIndex)
- {
- return (T2*)m_Data.GetAt(nIndex);
- }
-protected:
- T1 m_Data;
+ T2* GetPtrAt(int32_t nIndex) { return (T2*)m_Data.GetAt(nIndex); }
+
+ protected:
+ T1 m_Data;
};
-typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>, FX_FILESIZE> CFX_FileSizeListArray;
-typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_DWORD)>, FX_DWORD> CFX_DWordListArray;
+typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>,
+ FX_FILESIZE> CFX_FileSizeListArray;
+typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_DWORD)>, FX_DWORD>
+ CFX_DWordListArray;
typedef enum {
- Ready,
- ToBeContinued,
- Found,
- NotFound,
- Failed,
- Done
+ Ready,
+ ToBeContinued,
+ Found,
+ NotFound,
+ Failed,
+ Done
} FX_ProgressiveStatus;
-#define ProgressiveStatus FX_ProgressiveStatus
-#define FX_NAMESPACE_DECLARE(namespace, type) namespace::type
-class IFX_Unknown
-{
-public:
- virtual ~IFX_Unknown() {}
- virtual FX_DWORD Release() = 0;
- virtual FX_DWORD AddRef() = 0;
+#define ProgressiveStatus FX_ProgressiveStatus
+#define FX_NAMESPACE_DECLARE(namespace, type) namespace ::type
+class IFX_Unknown {
+ public:
+ virtual ~IFX_Unknown() {}
+ virtual FX_DWORD Release() = 0;
+ virtual FX_DWORD AddRef() = 0;
};
-#define FX_IsOdd(a) ((a) & 1)
-
-class CFX_Vector_3by1
-{
-public:
+#define FX_IsOdd(a) ((a)&1)
- CFX_Vector_3by1() :
- a(0.0f), b(0.0f), c(0.0f)
- {}
+class CFX_Vector_3by1 {
+ public:
+ CFX_Vector_3by1() : a(0.0f), b(0.0f), c(0.0f) {}
- CFX_Vector_3by1(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1):
- a(a1), b(b1), c(c1)
- {}
+ CFX_Vector_3by1(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1)
+ : a(a1), b(b1), c(c1) {}
- FX_FLOAT a;
- FX_FLOAT b;
- FX_FLOAT c;
+ FX_FLOAT a;
+ FX_FLOAT b;
+ FX_FLOAT c;
};
-class CFX_Matrix_3by3
-{
-public:
-
- CFX_Matrix_3by3():
- a(0.0f), b(0.0f), c(0.0f), d(0.0f), e(0.0f), f(0.0f), g(0.0f), h(0.0f), i(0.0f)
- {}
-
- CFX_Matrix_3by3(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, FX_FLOAT f1, FX_FLOAT g1, FX_FLOAT h1, FX_FLOAT i1) :
- a(a1), b(b1), c(c1), d(d1), e(e1), f(f1), g(g1), h(h1), i(i1)
- {}
-
- CFX_Matrix_3by3 Inverse();
-
- CFX_Matrix_3by3 Multiply(const CFX_Matrix_3by3 &m);
-
- CFX_Vector_3by1 TransformVector(const CFX_Vector_3by1 &v);
-
- FX_FLOAT a;
- FX_FLOAT b;
- FX_FLOAT c;
- FX_FLOAT d;
- FX_FLOAT e;
- FX_FLOAT f;
- FX_FLOAT g;
- FX_FLOAT h;
- FX_FLOAT i;
+class CFX_Matrix_3by3 {
+ public:
+ CFX_Matrix_3by3()
+ : a(0.0f),
+ b(0.0f),
+ c(0.0f),
+ d(0.0f),
+ e(0.0f),
+ f(0.0f),
+ g(0.0f),
+ h(0.0f),
+ i(0.0f) {}
+
+ CFX_Matrix_3by3(FX_FLOAT a1,
+ FX_FLOAT b1,
+ FX_FLOAT c1,
+ FX_FLOAT d1,
+ FX_FLOAT e1,
+ FX_FLOAT f1,
+ FX_FLOAT g1,
+ FX_FLOAT h1,
+ FX_FLOAT i1)
+ : a(a1), b(b1), c(c1), d(d1), e(e1), f(f1), g(g1), h(h1), i(i1) {}
+
+ CFX_Matrix_3by3 Inverse();
+
+ CFX_Matrix_3by3 Multiply(const CFX_Matrix_3by3& m);
+
+ CFX_Vector_3by1 TransformVector(const CFX_Vector_3by1& v);
+
+ FX_FLOAT a;
+ FX_FLOAT b;
+ FX_FLOAT c;
+ FX_FLOAT d;
+ FX_FLOAT e;
+ FX_FLOAT f;
+ FX_FLOAT g;
+ FX_FLOAT h;
+ FX_FLOAT i;
};
#endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_
diff --git a/core/include/fxcrt/fx_coordinates.h b/core/include/fxcrt/fx_coordinates.h
index 3689a4b270..ddd0f572c8 100644
--- a/core/include/fxcrt/fx_coordinates.h
+++ b/core/include/fxcrt/fx_coordinates.h
@@ -9,905 +9,744 @@
#include "fx_basic.h"
-template<class baseType> class CFX_PSVTemplate;
-template<class baseType> class CFX_VTemplate;
-template<class baseType> class CFX_PRLTemplate;
-template<class baseType> class CFX_RTemplate;
-template<class baseType> class CFX_ETemplate;
-template<class baseType> class CFX_ATemplate;
-template<class baseType> class CFX_RRTemplate;
+template <class baseType>
+class CFX_PSVTemplate;
+template <class baseType>
+class CFX_VTemplate;
+template <class baseType>
+class CFX_PRLTemplate;
+template <class baseType>
+class CFX_RTemplate;
+template <class baseType>
+class CFX_ETemplate;
+template <class baseType>
+class CFX_ATemplate;
+template <class baseType>
+class CFX_RRTemplate;
class CFX_Matrix;
-template<class baseType>
-class CFX_PSVTemplate
-{
-public:
- typedef CFX_PSVTemplate<baseType> FXT_PSV;
- typedef CFX_PSVTemplate<baseType> FXT_POINT;
- typedef CFX_PSVTemplate<baseType> FXT_SIZE;
- void Set(baseType x, baseType y)
- {
- FXT_PSV::x = x, FXT_PSV::y = y;
- }
- void Set(const FXT_PSV &psv)
- {
- FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;
- }
- void Add(baseType x, baseType y)
- {
- FXT_PSV::x += x, FXT_PSV::y += y;
- }
- void Subtract(baseType x, baseType y)
- {
- FXT_PSV::x -= x, FXT_PSV::y -= y;
- }
- void Reset()
- {
- FXT_PSV::x = FXT_PSV::y = 0;
- }
- FXT_PSV& operator += (const FXT_PSV &obj)
- {
- x += obj.x;
- y += obj.y;
- return *this;
- }
- FXT_PSV& operator -= (const FXT_PSV &obj)
- {
- x -= obj.x;
- y -= obj.y;
- return *this;
- }
- FXT_PSV& operator *= (baseType lamda)
- {
- x *= lamda;
- y *= lamda;
- return *this;
- }
- FXT_PSV& operator /= (baseType lamda)
- {
- x /= lamda;
- y /= lamda;
- return *this;
- }
- friend FX_BOOL operator == (const FXT_PSV &obj1, const FXT_PSV &obj2)
- {
- return obj1.x == obj2.x && obj1.y == obj2.y;
- }
- friend FX_BOOL operator != (const FXT_PSV &obj1, const FXT_PSV &obj2)
- {
- return obj1.x != obj2.x || obj1.y != obj2.y;
- }
- friend FXT_PSV operator + (const FXT_PSV &obj1, const FXT_PSV &obj2)
- {
- CFX_PSVTemplate obj;
- obj.x = obj1.x + obj2.x;
- obj.y = obj1.y + obj2.y;
- return obj;
- }
- friend FXT_PSV operator - (const FXT_PSV &obj1, const FXT_PSV &obj2)
- {
- CFX_PSVTemplate obj;
- obj.x = obj1.x - obj2.x;
- obj.y = obj1.y - obj2.y;
- return obj;
- }
- friend FXT_PSV operator * (const FXT_PSV &obj, baseType lamda)
- {
- CFX_PSVTemplate t;
- t.x = obj.x * lamda;
- t.y = obj.y * lamda;
- return t;
- }
- friend FXT_PSV operator * (baseType lamda, const FXT_PSV &obj)
- {
- CFX_PSVTemplate t;
- t.x = lamda * obj.x;
- t.y = lamda * obj.y;
- return t;
- }
- friend FXT_PSV operator / (const FXT_PSV &obj, baseType lamda)
- {
- CFX_PSVTemplate t;
- t.x = obj.x / lamda;
- t.y = obj.y / lamda;
- return t;
- }
- baseType x, y;
+template <class baseType>
+class CFX_PSVTemplate {
+ public:
+ typedef CFX_PSVTemplate<baseType> FXT_PSV;
+ typedef CFX_PSVTemplate<baseType> FXT_POINT;
+ typedef CFX_PSVTemplate<baseType> FXT_SIZE;
+ void Set(baseType x, baseType y) { FXT_PSV::x = x, FXT_PSV::y = y; }
+ void Set(const FXT_PSV& psv) { FXT_PSV::x = psv.x, FXT_PSV::y = psv.y; }
+ void Add(baseType x, baseType y) { FXT_PSV::x += x, FXT_PSV::y += y; }
+ void Subtract(baseType x, baseType y) { FXT_PSV::x -= x, FXT_PSV::y -= y; }
+ void Reset() { FXT_PSV::x = FXT_PSV::y = 0; }
+ FXT_PSV& operator+=(const FXT_PSV& obj) {
+ x += obj.x;
+ y += obj.y;
+ return *this;
+ }
+ FXT_PSV& operator-=(const FXT_PSV& obj) {
+ x -= obj.x;
+ y -= obj.y;
+ return *this;
+ }
+ FXT_PSV& operator*=(baseType lamda) {
+ x *= lamda;
+ y *= lamda;
+ return *this;
+ }
+ FXT_PSV& operator/=(baseType lamda) {
+ x /= lamda;
+ y /= lamda;
+ return *this;
+ }
+ friend FX_BOOL operator==(const FXT_PSV& obj1, const FXT_PSV& obj2) {
+ return obj1.x == obj2.x && obj1.y == obj2.y;
+ }
+ friend FX_BOOL operator!=(const FXT_PSV& obj1, const FXT_PSV& obj2) {
+ return obj1.x != obj2.x || obj1.y != obj2.y;
+ }
+ friend FXT_PSV operator+(const FXT_PSV& obj1, const FXT_PSV& obj2) {
+ CFX_PSVTemplate obj;
+ obj.x = obj1.x + obj2.x;
+ obj.y = obj1.y + obj2.y;
+ return obj;
+ }
+ friend FXT_PSV operator-(const FXT_PSV& obj1, const FXT_PSV& obj2) {
+ CFX_PSVTemplate obj;
+ obj.x = obj1.x - obj2.x;
+ obj.y = obj1.y - obj2.y;
+ return obj;
+ }
+ friend FXT_PSV operator*(const FXT_PSV& obj, baseType lamda) {
+ CFX_PSVTemplate t;
+ t.x = obj.x * lamda;
+ t.y = obj.y * lamda;
+ return t;
+ }
+ friend FXT_PSV operator*(baseType lamda, const FXT_PSV& obj) {
+ CFX_PSVTemplate t;
+ t.x = lamda * obj.x;
+ t.y = lamda * obj.y;
+ return t;
+ }
+ friend FXT_PSV operator/(const FXT_PSV& obj, baseType lamda) {
+ CFX_PSVTemplate t;
+ t.x = obj.x / lamda;
+ t.y = obj.y / lamda;
+ return t;
+ }
+ baseType x, y;
};
-typedef CFX_PSVTemplate<int32_t> CFX_Point;
-typedef CFX_PSVTemplate<FX_FLOAT> CFX_PointF;
-typedef CFX_PSVTemplate<int32_t> CFX_Size;
-typedef CFX_PSVTemplate<FX_FLOAT> CFX_SizeF;
-typedef CFX_ArrayTemplate<CFX_Point> CFX_Points;
-typedef CFX_ArrayTemplate<CFX_PointF> CFX_PointsF;
-typedef CFX_PSVTemplate<int32_t> * FX_LPPOINT;
-typedef CFX_PSVTemplate<FX_FLOAT> * FX_LPPOINTF;
-typedef CFX_PSVTemplate<int32_t> const * FX_LPCPOINT;
-typedef CFX_PSVTemplate<FX_FLOAT> const * FX_LPCPOINTF;
-#define CFX_FloatPoint CFX_PointF
-template<class baseType>
-class CFX_VTemplate: public CFX_PSVTemplate<baseType>
-{
-public:
- typedef CFX_PSVTemplate<baseType> FXT_PSV;
- typedef CFX_PSVTemplate<baseType> FXT_POINT;
- typedef CFX_PSVTemplate<baseType> FXT_SIZE;
- typedef CFX_VTemplate<baseType> FXT_VECTOR;
- void Set(baseType newx, baseType newy)
- {
- FXT_PSV::x = newx;
- FXT_PSV::y = newy;
- }
- void Set(const FXT_PSV &psv)
- {
- FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;
- }
- void Set(const FXT_POINT &p1, const FXT_POINT &p2)
- {
- FXT_PSV::x = p2.x - p1.x, FXT_PSV::y = p2.y - p1.y;
- }
- void Reset()
- {
- FXT_PSV::x = FXT_PSV::y = 0;
- }
- baseType SquareLength() const
- {
- return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y;
- }
- baseType Length() const
- {
- return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
- }
- void Normalize()
- {
- FX_FLOAT fLen = FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
- if (fLen < 0.0001f) {
- return;
- }
- FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen;
- FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen;
- }
- baseType DotProduct(baseType otherx, baseType othery) const
- {
- return FXT_PSV::x * otherx + FXT_PSV::y * othery;
- }
- baseType DotProduct(const FXT_VECTOR &v) const
- {
- return FXT_PSV::x * v.x + FXT_PSV::y * v.y;
- }
- FX_BOOL IsParallel(baseType otherx, baseType othery) const
- {
- baseType t = FXT_PSV::x * othery - FXT_PSV::y * otherx;
- return FXSYS_fabs(t) < 0x0001f;
- }
- FX_BOOL IsParallel(const FXT_VECTOR &v) const
- {
- return IsParallel(v.x, v.y);
- }
- FX_BOOL IsPerpendicular(baseType otherx, baseType othery) const
- {
- baseType t = DotProduct(otherx, othery);
- return FXSYS_fabs(t) < 0x0001f;
- }
- FX_BOOL IsPerpendicular(const FXT_VECTOR &v) const
- {
- return IsPerpendicular(v.x, v.y);
- }
- void Translate(baseType dx, baseType dy)
- {
- FXT_PSV::x += dx, FXT_PSV::y += dy;
- }
- void Scale(baseType sx, baseType sy)
- {
- FXT_PSV::x *= sx, FXT_PSV::y *= sy;
- }
- void Rotate(FX_FLOAT fRadian)
- {
- FX_FLOAT xx = (FX_FLOAT)FXT_PSV::x;
- FX_FLOAT yy = (FX_FLOAT)FXT_PSV::y;
- FX_FLOAT cosValue = FXSYS_cos(fRadian);
- FX_FLOAT sinValue = FXSYS_sin(fRadian);
- FXT_PSV::x = xx * cosValue - yy * sinValue;
- FXT_PSV::y = xx * sinValue + yy * cosValue;
- }
- friend FX_FLOAT Cosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
- {
- FXSYS_assert(v1.SquareLength() != 0 && v2.SquareLength() != 0);
- FX_FLOAT dotProduct = v1.DotProduct(v2);
- return dotProduct / (FX_FLOAT)FXSYS_sqrt(v1.SquareLength() * v2.SquareLength());
- }
- friend FX_FLOAT ArcCosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
- {
- return (FX_FLOAT)FXSYS_acos(Cosine(v1, v2));
- }
- friend FX_FLOAT SlopeAngle(const FXT_VECTOR &v)
- {
- CFX_VTemplate vx;
- vx.Set(1, 0);
- FX_FLOAT fSlope = ArcCosine(v, vx);
- return v.y < 0 ? -fSlope : fSlope;
- }
+typedef CFX_PSVTemplate<int32_t> CFX_Point;
+typedef CFX_PSVTemplate<FX_FLOAT> CFX_PointF;
+typedef CFX_PSVTemplate<int32_t> CFX_Size;
+typedef CFX_PSVTemplate<FX_FLOAT> CFX_SizeF;
+typedef CFX_ArrayTemplate<CFX_Point> CFX_Points;
+typedef CFX_ArrayTemplate<CFX_PointF> CFX_PointsF;
+typedef CFX_PSVTemplate<int32_t>* FX_LPPOINT;
+typedef CFX_PSVTemplate<FX_FLOAT>* FX_LPPOINTF;
+typedef CFX_PSVTemplate<int32_t> const* FX_LPCPOINT;
+typedef CFX_PSVTemplate<FX_FLOAT> const* FX_LPCPOINTF;
+#define CFX_FloatPoint CFX_PointF
+template <class baseType>
+class CFX_VTemplate : public CFX_PSVTemplate<baseType> {
+ public:
+ typedef CFX_PSVTemplate<baseType> FXT_PSV;
+ typedef CFX_PSVTemplate<baseType> FXT_POINT;
+ typedef CFX_PSVTemplate<baseType> FXT_SIZE;
+ typedef CFX_VTemplate<baseType> FXT_VECTOR;
+ void Set(baseType newx, baseType newy) {
+ FXT_PSV::x = newx;
+ FXT_PSV::y = newy;
+ }
+ void Set(const FXT_PSV& psv) { FXT_PSV::x = psv.x, FXT_PSV::y = psv.y; }
+ void Set(const FXT_POINT& p1, const FXT_POINT& p2) {
+ FXT_PSV::x = p2.x - p1.x, FXT_PSV::y = p2.y - p1.y;
+ }
+ void Reset() { FXT_PSV::x = FXT_PSV::y = 0; }
+ baseType SquareLength() const {
+ return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y;
+ }
+ baseType Length() const {
+ return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
+ }
+ void Normalize() {
+ FX_FLOAT fLen =
+ FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
+ if (fLen < 0.0001f) {
+ return;
+ }
+ FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen;
+ FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen;
+ }
+ baseType DotProduct(baseType otherx, baseType othery) const {
+ return FXT_PSV::x * otherx + FXT_PSV::y * othery;
+ }
+ baseType DotProduct(const FXT_VECTOR& v) const {
+ return FXT_PSV::x * v.x + FXT_PSV::y * v.y;
+ }
+ FX_BOOL IsParallel(baseType otherx, baseType othery) const {
+ baseType t = FXT_PSV::x * othery - FXT_PSV::y * otherx;
+ return FXSYS_fabs(t) < 0x0001f;
+ }
+ FX_BOOL IsParallel(const FXT_VECTOR& v) const { return IsParallel(v.x, v.y); }
+ FX_BOOL IsPerpendicular(baseType otherx, baseType othery) const {
+ baseType t = DotProduct(otherx, othery);
+ return FXSYS_fabs(t) < 0x0001f;
+ }
+ FX_BOOL IsPerpendicular(const FXT_VECTOR& v) const {
+ return IsPerpendicular(v.x, v.y);
+ }
+ void Translate(baseType dx, baseType dy) {
+ FXT_PSV::x += dx, FXT_PSV::y += dy;
+ }
+ void Scale(baseType sx, baseType sy) { FXT_PSV::x *= sx, FXT_PSV::y *= sy; }
+ void Rotate(FX_FLOAT fRadian) {
+ FX_FLOAT xx = (FX_FLOAT)FXT_PSV::x;
+ FX_FLOAT yy = (FX_FLOAT)FXT_PSV::y;
+ FX_FLOAT cosValue = FXSYS_cos(fRadian);
+ FX_FLOAT sinValue = FXSYS_sin(fRadian);
+ FXT_PSV::x = xx * cosValue - yy * sinValue;
+ FXT_PSV::y = xx * sinValue + yy * cosValue;
+ }
+ friend FX_FLOAT Cosine(const FXT_VECTOR& v1, const FXT_VECTOR& v2) {
+ FXSYS_assert(v1.SquareLength() != 0 && v2.SquareLength() != 0);
+ FX_FLOAT dotProduct = v1.DotProduct(v2);
+ return dotProduct /
+ (FX_FLOAT)FXSYS_sqrt(v1.SquareLength() * v2.SquareLength());
+ }
+ friend FX_FLOAT ArcCosine(const FXT_VECTOR& v1, const FXT_VECTOR& v2) {
+ return (FX_FLOAT)FXSYS_acos(Cosine(v1, v2));
+ }
+ friend FX_FLOAT SlopeAngle(const FXT_VECTOR& v) {
+ CFX_VTemplate vx;
+ vx.Set(1, 0);
+ FX_FLOAT fSlope = ArcCosine(v, vx);
+ return v.y < 0 ? -fSlope : fSlope;
+ }
};
typedef CFX_VTemplate<int32_t> CFX_Vector;
typedef CFX_VTemplate<FX_FLOAT> CFX_VectorF;
-template<class baseType>
-class CFX_RTemplate
-{
-public:
- typedef CFX_PSVTemplate<baseType> FXT_POINT;
- typedef CFX_PSVTemplate<baseType> FXT_SIZE;
- typedef CFX_VTemplate<baseType> FXT_VECTOR;
- typedef CFX_PRLTemplate<baseType> FXT_PARAL;
- typedef CFX_RTemplate<baseType> FXT_RECT;
- void Set(baseType left, baseType top, baseType width, baseType height)
- {
- FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height;
- }
- void Set(baseType left, baseType top, const FXT_SIZE &size)
- {
- FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);
- }
- void Set(const FXT_POINT &p, baseType width, baseType height)
- {
- TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;
- }
- void Set(const FXT_POINT &p1, const FXT_POINT &p2)
- {
- TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_RECT::Normalize();
- }
- void Set(const FXT_POINT &p, const FXT_VECTOR &v)
- {
- TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RECT::Normalize();
- }
- void Reset()
- {
- FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;
- }
- FXT_RECT& operator += (const FXT_POINT &p)
- {
- left += p.x, top += p.y;
- return *this;
- }
- FXT_RECT& operator -= (const FXT_POINT &p)
- {
- left -= p.x, top -= p.y;
- return *this;
- }
- baseType right() const
- {
- return left + width;
- }
- baseType bottom() const
- {
- return top + height;
- }
- void Normalize()
- {
- if (width < 0) {
- left += width;
- width = -width;
- }
- if (height < 0) {
- top += height;
- height = -height;
- }
- }
- void Offset(baseType dx, baseType dy)
- {
- left += dx;
- top += dy;
- }
- void Inflate(baseType x, baseType y)
- {
- left -= x;
- width += x * 2;
- top -= y;
- height += y * 2;
- }
- void Inflate(const FXT_POINT &p)
- {
- Inflate(p.x, p.y);
- }
- void Inflate(baseType left, baseType top, baseType right, baseType bottom)
- {
- FXT_RECT::left -= left;
- FXT_RECT::top -= top;
- FXT_RECT::width += left + right;
- FXT_RECT::height += top + bottom;
- }
- void Inflate(const FXT_RECT &rt)
- {
- Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height);
- }
- void Deflate(baseType x, baseType y)
- {
- left += x;
- width -= x * 2;
- top += y;
- height -= y * 2;
- }
- void Deflate(const FXT_POINT &p)
- {
- Deflate(p.x, p.y);
- }
- void Deflate(baseType left, baseType top, baseType right, baseType bottom)
- {
- FXT_RECT::left += left;
- FXT_RECT::top += top;
- FXT_RECT::width -= left + right;
- FXT_RECT::height -= top + bottom;
- }
- void Deflate(const FXT_RECT &rt)
- {
- Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height);
- }
- FX_BOOL IsEmpty() const
- {
- return width <= 0 || height <= 0;
- }
- FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const
- {
- return width <= fEpsilon || height <= fEpsilon;
- }
- void Empty()
- {
- width = height = 0;
- }
- FX_BOOL Contains(baseType x, baseType y) const
- {
- return x >= left && x < left + width && y >= top && y < top + height;
- }
- FX_BOOL Contains(const FXT_POINT &p) const
- {
- return Contains(p.x, p.y);
- }
- FX_BOOL Contains(const FXT_RECT &rt) const
- {
- return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.bottom() <= bottom();
- }
- baseType Width() const
- {
- return width;
- }
- baseType Height() const
- {
- return height;
- }
- FXT_SIZE Size() const
- {
- FXT_SIZE size;
- size.Set(width, height);
- return size;
- }
- void Size(FXT_SIZE s)
- {
- width = s.x, height = s.y;
- }
- FXT_POINT TopLeft() const
- {
- FXT_POINT p;
- p.x = left;
- p.y = top;
- return p;
- }
- FXT_POINT TopRight() const
- {
- FXT_POINT p;
- p.x = left + width;
- p.y = top;
- return p;
- }
- FXT_POINT BottomLeft() const
- {
- FXT_POINT p;
- p.x = left;
- p.y = top + height;
- return p;
- }
- FXT_POINT BottomRight() const
- {
- FXT_POINT p;
- p.x = left + width;
- p.y = top + height;
- return p;
- }
- void TopLeft(FXT_POINT tl)
- {
- left = tl.x;
- top = tl.y;
- }
- void TopRight(FXT_POINT tr)
- {
- width = tr.x - left;
- top = tr.y;
- }
- void BottomLeft(FXT_POINT bl)
- {
- left = bl.x;
- height = bl.y - top;
- }
- void BottomRight(FXT_POINT br)
- {
- width = br.x - left;
- height = br.y - top;
- }
- FXT_POINT Center() const
- {
- FXT_POINT p;
- p.x = left + width / 2;
- p.y = top + height / 2;
- return p;
- }
- void GetParallelogram(FXT_PARAL &pg) const
- {
- pg.x = left, pg.y = top;
- pg.x1 = width, pg.y1 = 0;
- pg.x2 = 0, pg.y2 = height;
- }
- void Union(baseType x, baseType y)
- {
- baseType r = right(), b = bottom();
- if (left > x) {
- left = x;
- }
- if (r < x) {
- r = x;
- }
- if (top > y) {
- top = y;
- }
- if (b < y) {
- b = y;
- }
- width = r - left;
- height = b - top;
- }
- void Union(const FXT_POINT &p)
- {
- Union(p.x, p.y);
- }
- void Union(const FXT_RECT &rt)
- {
- baseType r = right(), b = bottom();
- if (left > rt.left) {
- left = rt.left;
- }
- if (r < rt.right()) {
- r = rt.right();
- }
- if (top > rt.top) {
- top = rt.top;
- }
- if (b < rt.bottom()) {
- b = rt.bottom();
- }
- width = r - left;
- height = b - top;
- }
- void Intersect(const FXT_RECT &rt)
- {
- baseType r = right(), b = bottom();
- if (left < rt.left) {
- left = rt.left;
- }
- if (r > rt.right()) {
- r = rt.right();
- }
- if (top < rt.top) {
- top = rt.top;
- }
- if (b > rt.bottom()) {
- b = rt.bottom();
- }
- width = r - left;
- height = b - top;
- }
- FX_BOOL IntersectWith(const FXT_RECT &rt) const
- {
- FXT_RECT rect = rt;
- rect.Intersect(*this);
- return !rect.IsEmpty();
- }
- FX_BOOL IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) const
- {
- FXT_RECT rect = rt;
- rect.Intersect(*this);
- return !rect.IsEmpty(fEpsilon);
- }
- friend FX_BOOL operator == (const FXT_RECT &rc1, const FXT_RECT &rc2)
- {
- return rc1.left == rc2.left && rc1.top == rc2.top && rc1.width == rc2.width && rc1.height == rc2.height;
- }
- friend FX_BOOL operator != (const FXT_RECT &rc1, const FXT_RECT &rc2)
- {
- return rc1.left != rc2.left || rc1.top != rc2.top || rc1.width != rc2.width || rc1.height != rc2.height;
- }
- baseType left, top;
- baseType width, height;
+template <class baseType>
+class CFX_RTemplate {
+ public:
+ typedef CFX_PSVTemplate<baseType> FXT_POINT;
+ typedef CFX_PSVTemplate<baseType> FXT_SIZE;
+ typedef CFX_VTemplate<baseType> FXT_VECTOR;
+ typedef CFX_PRLTemplate<baseType> FXT_PARAL;
+ typedef CFX_RTemplate<baseType> FXT_RECT;
+ void Set(baseType left, baseType top, baseType width, baseType height) {
+ FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width,
+ FXT_RECT::height = height;
+ }
+ void Set(baseType left, baseType top, const FXT_SIZE& size) {
+ FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);
+ }
+ void Set(const FXT_POINT& p, baseType width, baseType height) {
+ TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;
+ }
+ void Set(const FXT_POINT& p1, const FXT_POINT& p2) {
+ TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y,
+ FXT_RECT::Normalize();
+ }
+ void Set(const FXT_POINT& p, const FXT_VECTOR& v) {
+ TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y,
+ FXT_RECT::Normalize();
+ }
+ void Reset() {
+ FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;
+ }
+ FXT_RECT& operator+=(const FXT_POINT& p) {
+ left += p.x, top += p.y;
+ return *this;
+ }
+ FXT_RECT& operator-=(const FXT_POINT& p) {
+ left -= p.x, top -= p.y;
+ return *this;
+ }
+ baseType right() const { return left + width; }
+ baseType bottom() const { return top + height; }
+ void Normalize() {
+ if (width < 0) {
+ left += width;
+ width = -width;
+ }
+ if (height < 0) {
+ top += height;
+ height = -height;
+ }
+ }
+ void Offset(baseType dx, baseType dy) {
+ left += dx;
+ top += dy;
+ }
+ void Inflate(baseType x, baseType y) {
+ left -= x;
+ width += x * 2;
+ top -= y;
+ height += y * 2;
+ }
+ void Inflate(const FXT_POINT& p) { Inflate(p.x, p.y); }
+ void Inflate(baseType left, baseType top, baseType right, baseType bottom) {
+ FXT_RECT::left -= left;
+ FXT_RECT::top -= top;
+ FXT_RECT::width += left + right;
+ FXT_RECT::height += top + bottom;
+ }
+ void Inflate(const FXT_RECT& rt) {
+ Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height);
+ }
+ void Deflate(baseType x, baseType y) {
+ left += x;
+ width -= x * 2;
+ top += y;
+ height -= y * 2;
+ }
+ void Deflate(const FXT_POINT& p) { Deflate(p.x, p.y); }
+ void Deflate(baseType left, baseType top, baseType right, baseType bottom) {
+ FXT_RECT::left += left;
+ FXT_RECT::top += top;
+ FXT_RECT::width -= left + right;
+ FXT_RECT::height -= top + bottom;
+ }
+ void Deflate(const FXT_RECT& rt) {
+ Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height);
+ }
+ FX_BOOL IsEmpty() const { return width <= 0 || height <= 0; }
+ FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const {
+ return width <= fEpsilon || height <= fEpsilon;
+ }
+ void Empty() { width = height = 0; }
+ FX_BOOL Contains(baseType x, baseType y) const {
+ return x >= left && x < left + width && y >= top && y < top + height;
+ }
+ FX_BOOL Contains(const FXT_POINT& p) const { return Contains(p.x, p.y); }
+ FX_BOOL Contains(const FXT_RECT& rt) const {
+ return rt.left >= left && rt.right() <= right() && rt.top >= top &&
+ rt.bottom() <= bottom();
+ }
+ baseType Width() const { return width; }
+ baseType Height() const { return height; }
+ FXT_SIZE Size() const {
+ FXT_SIZE size;
+ size.Set(width, height);
+ return size;
+ }
+ void Size(FXT_SIZE s) { width = s.x, height = s.y; }
+ FXT_POINT TopLeft() const {
+ FXT_POINT p;
+ p.x = left;
+ p.y = top;
+ return p;
+ }
+ FXT_POINT TopRight() const {
+ FXT_POINT p;
+ p.x = left + width;
+ p.y = top;
+ return p;
+ }
+ FXT_POINT BottomLeft() const {
+ FXT_POINT p;
+ p.x = left;
+ p.y = top + height;
+ return p;
+ }
+ FXT_POINT BottomRight() const {
+ FXT_POINT p;
+ p.x = left + width;
+ p.y = top + height;
+ return p;
+ }
+ void TopLeft(FXT_POINT tl) {
+ left = tl.x;
+ top = tl.y;
+ }
+ void TopRight(FXT_POINT tr) {
+ width = tr.x - left;
+ top = tr.y;
+ }
+ void BottomLeft(FXT_POINT bl) {
+ left = bl.x;
+ height = bl.y - top;
+ }
+ void BottomRight(FXT_POINT br) {
+ width = br.x - left;
+ height = br.y - top;
+ }
+ FXT_POINT Center() const {
+ FXT_POINT p;
+ p.x = left + width / 2;
+ p.y = top + height / 2;
+ return p;
+ }
+ void GetParallelogram(FXT_PARAL& pg) const {
+ pg.x = left, pg.y = top;
+ pg.x1 = width, pg.y1 = 0;
+ pg.x2 = 0, pg.y2 = height;
+ }
+ void Union(baseType x, baseType y) {
+ baseType r = right(), b = bottom();
+ if (left > x) {
+ left = x;
+ }
+ if (r < x) {
+ r = x;
+ }
+ if (top > y) {
+ top = y;
+ }
+ if (b < y) {
+ b = y;
+ }
+ width = r - left;
+ height = b - top;
+ }
+ void Union(const FXT_POINT& p) { Union(p.x, p.y); }
+ void Union(const FXT_RECT& rt) {
+ baseType r = right(), b = bottom();
+ if (left > rt.left) {
+ left = rt.left;
+ }
+ if (r < rt.right()) {
+ r = rt.right();
+ }
+ if (top > rt.top) {
+ top = rt.top;
+ }
+ if (b < rt.bottom()) {
+ b = rt.bottom();
+ }
+ width = r - left;
+ height = b - top;
+ }
+ void Intersect(const FXT_RECT& rt) {
+ baseType r = right(), b = bottom();
+ if (left < rt.left) {
+ left = rt.left;
+ }
+ if (r > rt.right()) {
+ r = rt.right();
+ }
+ if (top < rt.top) {
+ top = rt.top;
+ }
+ if (b > rt.bottom()) {
+ b = rt.bottom();
+ }
+ width = r - left;
+ height = b - top;
+ }
+ FX_BOOL IntersectWith(const FXT_RECT& rt) const {
+ FXT_RECT rect = rt;
+ rect.Intersect(*this);
+ return !rect.IsEmpty();
+ }
+ FX_BOOL IntersectWith(const FXT_RECT& rt, FX_FLOAT fEpsilon) const {
+ FXT_RECT rect = rt;
+ rect.Intersect(*this);
+ return !rect.IsEmpty(fEpsilon);
+ }
+ friend FX_BOOL operator==(const FXT_RECT& rc1, const FXT_RECT& rc2) {
+ return rc1.left == rc2.left && rc1.top == rc2.top &&
+ rc1.width == rc2.width && rc1.height == rc2.height;
+ }
+ friend FX_BOOL operator!=(const FXT_RECT& rc1, const FXT_RECT& rc2) {
+ return rc1.left != rc2.left || rc1.top != rc2.top ||
+ rc1.width != rc2.width || rc1.height != rc2.height;
+ }
+ baseType left, top;
+ baseType width, height;
};
-typedef CFX_RTemplate<int32_t> CFX_Rect;
-typedef CFX_RTemplate<FX_FLOAT> CFX_RectF;
-typedef CFX_RTemplate<int32_t> * FX_LPRECT;
-typedef CFX_RTemplate<FX_FLOAT> * FX_LPRECTF;
-typedef CFX_RTemplate<int32_t> const * FX_LPCRECT;
-typedef CFX_RTemplate<FX_FLOAT> const * FX_LPCRECTF;
-typedef CFX_ArrayTemplate<CFX_RectF> CFX_RectFArray;
+typedef CFX_RTemplate<int32_t> CFX_Rect;
+typedef CFX_RTemplate<FX_FLOAT> CFX_RectF;
+typedef CFX_RTemplate<int32_t>* FX_LPRECT;
+typedef CFX_RTemplate<FX_FLOAT>* FX_LPRECTF;
+typedef CFX_RTemplate<int32_t> const* FX_LPCRECT;
+typedef CFX_RTemplate<FX_FLOAT> const* FX_LPCRECTF;
+typedef CFX_ArrayTemplate<CFX_RectF> CFX_RectFArray;
struct FX_RECT {
+ int left;
- int left;
+ int top;
- int top;
+ int right;
- int right;
+ int bottom;
- int bottom;
+ FX_RECT() : left(0), top(0), right(0), bottom(0) {}
- FX_RECT(): left(0), top(0), right(0), bottom(0) { }
+ FX_RECT(int left1, int top1, int right1, int bottom1) {
+ left = left1;
+ top = top1;
+ right = right1;
+ bottom = bottom1;
+ }
- FX_RECT(int left1, int top1, int right1, int bottom1)
- {
- left = left1;
- top = top1;
- right = right1;
- bottom = bottom1;
- }
+ int Width() const { return right - left; }
- int Width() const
- {
- return right - left;
- }
+ int Height() const { return bottom - top; }
- int Height() const
- {
- return bottom - top;
- }
+ FX_BOOL IsEmpty() const { return right <= left || bottom <= top; }
- FX_BOOL IsEmpty() const
- {
- return right <= left || bottom <= top;
- }
+ void Normalize();
- void Normalize();
+ void Intersect(const FX_RECT& src);
- void Intersect(const FX_RECT& src);
+ void Intersect(int left1, int top1, int right1, int bottom1) {
+ Intersect(FX_RECT(left1, top1, right1, bottom1));
+ }
- void Intersect(int left1, int top1, int right1, int bottom1)
- {
- Intersect(FX_RECT(left1, top1, right1, bottom1));
- }
+ void Union(const FX_RECT& other_rect);
- void Union(const FX_RECT& other_rect);
+ FX_BOOL operator==(const FX_RECT& src) const {
+ return left == src.left && right == src.right && top == src.top &&
+ bottom == src.bottom;
+ }
- FX_BOOL operator == (const FX_RECT& src) const
- {
- return left == src.left && right == src.right && top == src.top && bottom == src.bottom;
- }
+ void Offset(int dx, int dy) {
+ left += dx;
+ right += dx;
+ top += dy;
+ bottom += dy;
+ }
- void Offset(int dx, int dy)
- {
- left += dx;
- right += dx;
- top += dy;
- bottom += dy;
- }
-
- FX_BOOL Contains(const FX_RECT& other_rect) const
- {
- return other_rect.left >= left && other_rect.right <= right && other_rect.top >= top && other_rect.bottom <= bottom;
- }
+ FX_BOOL Contains(const FX_RECT& other_rect) const {
+ return other_rect.left >= left && other_rect.right <= right &&
+ other_rect.top >= top && other_rect.bottom <= bottom;
+ }
- FX_BOOL Contains(int x, int y) const
- {
- return x >= left && x < right && y >= top && y < bottom;
- }
+ FX_BOOL Contains(int x, int y) const {
+ return x >= left && x < right && y >= top && y < bottom;
+ }
};
struct FX_SMALL_RECT {
+ int16_t Left;
- int16_t Left;
+ int16_t Top;
- int16_t Top;
+ int16_t Right;
- int16_t Right;
-
- int16_t Bottom;
+ int16_t Bottom;
};
-class CFX_FloatRect
-{
-public:
+class CFX_FloatRect {
+ public:
+ CFX_FloatRect() { left = right = bottom = top = 0; }
- CFX_FloatRect()
- {
- left = right = bottom = top = 0;
- }
+ CFX_FloatRect(FX_FLOAT left1,
+ FX_FLOAT bottom1,
+ FX_FLOAT right1,
+ FX_FLOAT top1) {
+ left = left1;
+ bottom = bottom1;
+ right = right1;
+ top = top1;
+ }
- CFX_FloatRect(FX_FLOAT left1, FX_FLOAT bottom1, FX_FLOAT right1, FX_FLOAT top1)
- {
- left = left1;
- bottom = bottom1;
- right = right1;
- top = top1;
- }
+ CFX_FloatRect(const FX_FLOAT* pArray) {
+ left = pArray[0];
+ bottom = pArray[1];
+ right = pArray[2];
+ top = pArray[3];
+ }
- CFX_FloatRect(const FX_FLOAT* pArray)
- {
- left = pArray[0];
- bottom = pArray[1];
- right = pArray[2];
- top = pArray[3];
- }
+ CFX_FloatRect(const FX_RECT& rect);
- CFX_FloatRect(const FX_RECT& rect);
+ FX_BOOL IsEmpty() const { return left >= right || bottom >= top; }
- FX_BOOL IsEmpty() const
- {
- return left >= right || bottom >= top;
- }
+ void Normalize();
- void Normalize();
+ void Reset() { left = right = bottom = top = 0; }
- void Reset()
- {
- left = right = bottom = top = 0;
- }
-
- FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
+ FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
- FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
+ FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
- void Transform(const CFX_Matrix* pMatrix);
+ void Transform(const CFX_Matrix* pMatrix);
- void Intersect(const CFX_FloatRect& other_rect);
+ void Intersect(const CFX_FloatRect& other_rect);
- void Union(const CFX_FloatRect& other_rect);
+ void Union(const CFX_FloatRect& other_rect);
- FX_RECT GetInnerRect() const;
+ FX_RECT GetInnerRect() const;
- FX_RECT GetOutterRect() const;
+ FX_RECT GetOutterRect() const;
- FX_RECT GetClosestRect() const;
+ FX_RECT GetClosestRect() const;
- int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
+ int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
- void InitRect(FX_FLOAT x, FX_FLOAT y)
- {
- left = right = x;
- bottom = top = y;
- }
+ void InitRect(FX_FLOAT x, FX_FLOAT y) {
+ left = right = x;
+ bottom = top = y;
+ }
- void UpdateRect(FX_FLOAT x, FX_FLOAT y);
+ void UpdateRect(FX_FLOAT x, FX_FLOAT y);
- FX_FLOAT Width() const
- {
- return right - left;
- }
+ FX_FLOAT Width() const { return right - left; }
- FX_FLOAT Height() const
- {
- return top - bottom;
- }
+ FX_FLOAT Height() const { return top - bottom; }
- void Inflate(FX_FLOAT x, FX_FLOAT y)
- {
- Normalize();
- left -= x;
- right += x;
- bottom -= y;
- top += y;
- }
+ void Inflate(FX_FLOAT x, FX_FLOAT y) {
+ Normalize();
+ left -= x;
+ right += x;
+ bottom -= y;
+ top += y;
+ }
- void Inflate(FX_FLOAT other_left,
- FX_FLOAT other_bottom,
- FX_FLOAT other_right,
- FX_FLOAT other_top)
- {
- Normalize();
- left -= other_left;
- bottom -= other_bottom;
- right += other_right;
- top += other_top;
- }
+ void Inflate(FX_FLOAT other_left,
+ FX_FLOAT other_bottom,
+ FX_FLOAT other_right,
+ FX_FLOAT other_top) {
+ Normalize();
+ left -= other_left;
+ bottom -= other_bottom;
+ right += other_right;
+ top += other_top;
+ }
- void Inflate(const CFX_FloatRect &rt)
- {
- Inflate(rt.left, rt.bottom, rt.right, rt.top);
- }
+ void Inflate(const CFX_FloatRect& rt) {
+ Inflate(rt.left, rt.bottom, rt.right, rt.top);
+ }
- void Deflate(FX_FLOAT x, FX_FLOAT y)
- {
- Normalize();
- left += x;
- right -= x;
- bottom += y;
- top -= y;
- }
+ void Deflate(FX_FLOAT x, FX_FLOAT y) {
+ Normalize();
+ left += x;
+ right -= x;
+ bottom += y;
+ top -= y;
+ }
- void Deflate(FX_FLOAT other_left,
- FX_FLOAT other_bottom,
- FX_FLOAT other_right,
- FX_FLOAT other_top)
- {
- Normalize();
- left += other_left;
- bottom += other_bottom;
- right -= other_right;
- top -= other_top;
- }
+ void Deflate(FX_FLOAT other_left,
+ FX_FLOAT other_bottom,
+ FX_FLOAT other_right,
+ FX_FLOAT other_top) {
+ Normalize();
+ left += other_left;
+ bottom += other_bottom;
+ right -= other_right;
+ top -= other_top;
+ }
- void Deflate(const CFX_FloatRect &rt)
- {
- Deflate(rt.left, rt.bottom, rt.right, rt.top);
- }
+ void Deflate(const CFX_FloatRect& rt) {
+ Deflate(rt.left, rt.bottom, rt.right, rt.top);
+ }
- void Translate(FX_FLOAT e, FX_FLOAT f)
- {
- left += e;
- right += e;
- top += f;
- bottom += f;
- }
+ void Translate(FX_FLOAT e, FX_FLOAT f) {
+ left += e;
+ right += e;
+ top += f;
+ bottom += f;
+ }
- static CFX_FloatRect GetBBox(const CFX_FloatPoint* pPoints, int nPoints);
+ static CFX_FloatRect GetBBox(const CFX_FloatPoint* pPoints, int nPoints);
- FX_FLOAT left;
+ FX_FLOAT left;
- FX_FLOAT right;
+ FX_FLOAT right;
- FX_FLOAT bottom;
+ FX_FLOAT bottom;
- FX_FLOAT top;
+ FX_FLOAT top;
};
-class CFX_Matrix
-{
-public:
-
- CFX_Matrix()
- {
- a = d = 1;
- b = c = e = f = 0;
- }
+class CFX_Matrix {
+ public:
+ CFX_Matrix() {
+ a = d = 1;
+ b = c = e = f = 0;
+ }
+
+ CFX_Matrix(FX_FLOAT a1,
+ FX_FLOAT b1,
+ FX_FLOAT c1,
+ FX_FLOAT d1,
+ FX_FLOAT e1,
+ FX_FLOAT f1) {
+ a = a1;
+ b = b1;
+ c = c1;
+ d = d1;
+ e = e1;
+ f = f1;
+ }
+
+ void Set(FX_FLOAT a,
+ FX_FLOAT b,
+ FX_FLOAT c,
+ FX_FLOAT d,
+ FX_FLOAT e,
+ FX_FLOAT f);
+ void Set(const FX_FLOAT n[6]);
+
+ void SetIdentity() {
+ a = d = 1;
+ b = c = e = f = 0;
+ }
- CFX_Matrix(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, FX_FLOAT f1)
- {
- a = a1;
- b = b1;
- c = c1;
- d = d1;
- e = e1;
- f = f1;
- }
-
- void Set(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f);
- void Set(const FX_FLOAT n[6]);
-
- void SetIdentity()
- {
- a = d = 1;
- b = c = e = f = 0;
- }
-
- void SetReverse(const CFX_Matrix &m);
-
- void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended = FALSE);
-
- void Concat(const CFX_Matrix &m, FX_BOOL bPrepended = FALSE);
-
- void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE);
- void Reset()
- {
- SetIdentity();
- }
-
- void Copy(const CFX_Matrix& m)
- {
- *this = m;
- }
-
- FX_BOOL IsIdentity() const
- {
- return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0;
- }
- FX_BOOL IsInvertible() const;
-
- FX_BOOL Is90Rotated() const;
-
- FX_BOOL IsScaled() const;
-
- void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
-
- void TranslateI(int32_t x, int32_t y, FX_BOOL bPrepended = FALSE)
- {
- Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended);
- }
+ void SetReverse(const CFX_Matrix& m);
- void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE);
+ void Concat(FX_FLOAT a,
+ FX_FLOAT b,
+ FX_FLOAT c,
+ FX_FLOAT d,
+ FX_FLOAT e,
+ FX_FLOAT f,
+ FX_BOOL bPrepended = FALSE);
+
+ void Concat(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE);
+
+ void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE);
+ void Reset() { SetIdentity(); }
+
+ void Copy(const CFX_Matrix& m) { *this = m; }
+
+ FX_BOOL IsIdentity() const {
+ return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0;
+ }
+ FX_BOOL IsInvertible() const;
+
+ FX_BOOL Is90Rotated() const;
+
+ FX_BOOL IsScaled() const;
+
+ void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
+
+ void TranslateI(int32_t x, int32_t y, FX_BOOL bPrepended = FALSE) {
+ Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended);
+ }
+
+ void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE);
+
+ void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE);
+
+ void RotateAt(FX_FLOAT fRadian,
+ FX_FLOAT x,
+ FX_FLOAT y,
+ FX_BOOL bPrepended = FALSE);
+
+ void Shear(FX_FLOAT fAlphaRadian,
+ FX_FLOAT fBetaRadian,
+ FX_BOOL bPrepended = FALSE);
+
+ void MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src);
+
+ FX_FLOAT GetXUnit() const;
+
+ FX_FLOAT GetYUnit() const;
+ void GetUnitRect(CFX_RectF& rect) const;
+
+ CFX_FloatRect GetUnitRect() const;
+
+ FX_FLOAT GetUnitArea() const;
+ FX_FLOAT TransformXDistance(FX_FLOAT dx) const;
+ int32_t TransformXDistance(int32_t dx) const;
+ FX_FLOAT TransformYDistance(FX_FLOAT dy) const;
+ int32_t TransformYDistance(int32_t dy) const;
+ FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const;
+ int32_t TransformDistance(int32_t dx, int32_t dy) const;
+
+ FX_FLOAT TransformDistance(FX_FLOAT distance) const;
+ void TransformPoint(FX_FLOAT& x, FX_FLOAT& y) const;
+ void TransformPoint(int32_t& x, int32_t& y) const;
+ void TransformPoints(CFX_PointF* points, int32_t iCount) const;
+ void TransformPoints(CFX_Point* points, int32_t iCount) const;
+
+ void Transform(FX_FLOAT& x, FX_FLOAT& y) const { TransformPoint(x, y); }
- void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE);
+ void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const {
+ x1 = x, y1 = y;
+ TransformPoint(x1, y1);
+ }
+ void TransformVector(CFX_VectorF& v) const;
+ void TransformVector(CFX_Vector& v) const;
+ void TransformRect(CFX_RectF& rect) const;
+ void TransformRect(CFX_Rect& rect) const;
- void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
+ void TransformRect(FX_FLOAT& left,
+ FX_FLOAT& right,
+ FX_FLOAT& top,
+ FX_FLOAT& bottom) const;
- void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended = FALSE);
+ void TransformRect(CFX_FloatRect& rect) const {
+ TransformRect(rect.left, rect.right, rect.top, rect.bottom);
+ }
- void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src);
+ FX_FLOAT GetA() const { return a; }
- FX_FLOAT GetXUnit() const;
+ FX_FLOAT GetB() const { return b; }
- FX_FLOAT GetYUnit() const;
- void GetUnitRect(CFX_RectF &rect) const;
+ FX_FLOAT GetC() const { return c; }
- CFX_FloatRect GetUnitRect() const;
+ FX_FLOAT GetD() const { return d; }
- FX_FLOAT GetUnitArea() const;
- FX_FLOAT TransformXDistance(FX_FLOAT dx) const;
- int32_t TransformXDistance(int32_t dx) const;
- FX_FLOAT TransformYDistance(FX_FLOAT dy) const;
- int32_t TransformYDistance(int32_t dy) const;
- FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const;
- int32_t TransformDistance(int32_t dx, int32_t dy) const;
+ FX_FLOAT GetE() const { return e; }
- FX_FLOAT TransformDistance(FX_FLOAT distance) const;
- void TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const;
- void TransformPoint(int32_t &x, int32_t &y) const;
- void TransformPoints(CFX_PointF *points, int32_t iCount) const;
- void TransformPoints(CFX_Point *points, int32_t iCount) const;
+ FX_FLOAT GetF() const { return f; }
- void Transform(FX_FLOAT& x, FX_FLOAT& y) const
- {
- TransformPoint(x, y);
- }
-
- void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const
- {
- x1 = x, y1 = y;
- TransformPoint(x1, y1);
- }
- void TransformVector(CFX_VectorF &v) const;
- void TransformVector(CFX_Vector &v) const;
- void TransformRect(CFX_RectF &rect) const;
- void TransformRect(CFX_Rect &rect) const;
-
- void TransformRect(FX_FLOAT& left, FX_FLOAT& right, FX_FLOAT& top, FX_FLOAT& bottom) const;
-
- void TransformRect(CFX_FloatRect& rect) const
- {
- TransformRect(rect.left, rect.right, rect.top, rect.bottom);
- }
-
- FX_FLOAT GetA() const
- {
- return a;
- }
-
- FX_FLOAT GetB() const
- {
- return b;
- }
-
- FX_FLOAT GetC() const
- {
- return c;
- }
-
- FX_FLOAT GetD() const
- {
- return d;
- }
-
- FX_FLOAT GetE() const
- {
- return e;
- }
-
- FX_FLOAT GetF() const
- {
- return f;
- }
-public:
- FX_FLOAT a;
- FX_FLOAT b;
- FX_FLOAT c;
- FX_FLOAT d;
- FX_FLOAT e;
- FX_FLOAT f;
+ public:
+ FX_FLOAT a;
+ FX_FLOAT b;
+ FX_FLOAT c;
+ FX_FLOAT d;
+ FX_FLOAT e;
+ FX_FLOAT f;
};
-#define CFX_AffineMatrix CFX_Matrix
+#define CFX_AffineMatrix CFX_Matrix
#endif // CORE_INCLUDE_FXCRT_FX_COORDINATES_H_
diff --git a/core/include/fxcrt/fx_ext.h b/core/include/fxcrt/fx_ext.h
index 55e522ad1a..0853c89531 100644
--- a/core/include/fxcrt/fx_ext.h
+++ b/core/include/fxcrt/fx_ext.h
@@ -14,33 +14,37 @@
extern "C" {
#endif
-FX_FLOAT FXSYS_tan(FX_FLOAT a);
-FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x);
-FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, int32_t iLength = -1, int32_t *pUsedLen = NULL);
-FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, int32_t iLength = -1, int32_t *pUsedLen = NULL);
-FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count);
-int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count);
-int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count);
-
-inline FX_BOOL FXSYS_islower(int32_t ch)
-{
- return ch >= 'a' && ch <= 'z';
+FX_FLOAT FXSYS_tan(FX_FLOAT a);
+FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x);
+FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr,
+ int32_t iLength = -1,
+ int32_t* pUsedLen = NULL);
+FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr,
+ int32_t iLength = -1,
+ int32_t* pUsedLen = NULL);
+FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count);
+int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count);
+int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count);
+
+inline FX_BOOL FXSYS_islower(int32_t ch) {
+ return ch >= 'a' && ch <= 'z';
}
-inline FX_BOOL FXSYS_isupper(int32_t ch)
-{
- return ch >= 'A' && ch <= 'Z';
+inline FX_BOOL FXSYS_isupper(int32_t ch) {
+ return ch >= 'A' && ch <= 'Z';
}
-inline int32_t FXSYS_tolower(int32_t ch)
-{
- return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20);
+inline int32_t FXSYS_tolower(int32_t ch) {
+ return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20);
}
-inline int32_t FXSYS_toupper(int32_t ch)
-{
- return ch < 'a' || ch > 'z' ? ch : (ch - 0x20);
+inline int32_t FXSYS_toupper(int32_t ch) {
+ return ch < 'a' || ch > 'z' ? ch : (ch - 0x20);
}
-FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase = FALSE);
-FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase = FALSE);
+FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr,
+ int32_t iLength,
+ FX_BOOL bIgnoreCase = FALSE);
+FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr,
+ int32_t iLength,
+ FX_BOOL bIgnoreCase = FALSE);
#ifdef __cplusplus
}
@@ -49,17 +53,17 @@ FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr, int32_t iLength, FX_BOOL
extern "C" {
#endif
-void* FX_Random_MT_Start(FX_DWORD dwSeed);
+void* FX_Random_MT_Start(FX_DWORD dwSeed);
-FX_DWORD FX_Random_MT_Generate(void* pContext);
+FX_DWORD FX_Random_MT_Generate(void* pContext);
-void FX_Random_MT_Close(void* pContext);
+void FX_Random_MT_Close(void* pContext);
-void FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount);
+void FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount);
-void FX_Random_GenerateMT(FX_DWORD* pBuffer, int32_t iCount);
+void FX_Random_GenerateMT(FX_DWORD* pBuffer, int32_t iCount);
-void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount);
+void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount);
#ifdef __cplusplus
}
#endif
@@ -68,42 +72,42 @@ extern "C" {
#endif
typedef struct FX_GUID {
- FX_DWORD data1;
- FX_WORD data2;
- FX_WORD data3;
- uint8_t data4[8];
-} FX_GUID, * FX_LPGUID;
-typedef FX_GUID const * FX_LPCGUID;
-
-void FX_GUID_CreateV4(FX_LPGUID pGUID);
-
-void FX_GUID_ToString(FX_LPCGUID pGUID, CFX_ByteString &bsStr, FX_BOOL bSeparator = TRUE);
+ FX_DWORD data1;
+ FX_WORD data2;
+ FX_WORD data3;
+ uint8_t data4[8];
+} FX_GUID, *FX_LPGUID;
+typedef FX_GUID const* FX_LPCGUID;
+
+void FX_GUID_CreateV4(FX_LPGUID pGUID);
+
+void FX_GUID_ToString(FX_LPCGUID pGUID,
+ CFX_ByteString& bsStr,
+ FX_BOOL bSeparator = TRUE);
#ifdef __cplusplus
}
#endif
-template<class baseType>
-class CFX_SSortTemplate
-{
-public:
- void ShellSort(baseType *pArray, int32_t iCount)
- {
- FXSYS_assert(pArray != NULL && iCount > 0);
- int32_t i, j, gap;
- baseType v1, v2;
- gap = iCount >> 1;
- while (gap > 0) {
- for (i = gap; i < iCount; i ++) {
- j = i - gap;
- v1 = pArray[i];
- while (j > -1 && (v2 = pArray[j]) > v1) {
- pArray[j + gap] = v2;
- j -= gap;
- }
- pArray[j + gap] = v1;
- }
- gap >>= 1;
+template <class baseType>
+class CFX_SSortTemplate {
+ public:
+ void ShellSort(baseType* pArray, int32_t iCount) {
+ FXSYS_assert(pArray != NULL && iCount > 0);
+ int32_t i, j, gap;
+ baseType v1, v2;
+ gap = iCount >> 1;
+ while (gap > 0) {
+ for (i = gap; i < iCount; i++) {
+ j = i - gap;
+ v1 = pArray[i];
+ while (j > -1 && (v2 = pArray[j]) > v1) {
+ pArray[j + gap] = v2;
+ j -= gap;
}
+ pArray[j + gap] = v1;
+ }
+ gap >>= 1;
}
+ }
};
#endif // CORE_INCLUDE_FXCRT_FX_EXT_H_
diff --git a/core/include/fxcrt/fx_memory.h b/core/include/fxcrt/fx_memory.h
index d19a3b32ab..e24aa3ecf4 100644
--- a/core/include/fxcrt/fx_memory.h
+++ b/core/include/fxcrt/fx_memory.h
@@ -13,9 +13,9 @@
extern "C" {
#endif
// For external C libraries to malloc through PDFium. These may return NULL.
-void* FXMEM_DefaultAlloc(size_t byte_size, int flags);
-void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags);
-void FXMEM_DefaultFree(void* pointer, int flags);
+void* FXMEM_DefaultAlloc(size_t byte_size, int flags);
+void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags);
+void FXMEM_DefaultFree(void* pointer, int flags);
#ifdef __cplusplus
} // extern "C"
@@ -28,94 +28,84 @@ void FXMEM_DefaultFree(void* pointer, int flags);
NEVER_INLINE void FX_OutOfMemoryTerminate();
inline void* FX_SafeRealloc(void* ptr, size_t num_members, size_t member_size) {
- if (num_members < std::numeric_limits<size_t>::max() / member_size) {
- return realloc(ptr, num_members * member_size);
- }
- return nullptr;
+ if (num_members < std::numeric_limits<size_t>::max() / member_size) {
+ return realloc(ptr, num_members * member_size);
+ }
+ return nullptr;
}
inline void* FX_AllocOrDie(size_t num_members, size_t member_size) {
- // TODO(tsepez): See if we can avoid the implicit memset(0).
- if (void* result = calloc(num_members, member_size)) {
- return result;
- }
- FX_OutOfMemoryTerminate(); // Never returns.
- return nullptr; // Suppress compiler warning.
+ // TODO(tsepez): See if we can avoid the implicit memset(0).
+ if (void* result = calloc(num_members, member_size)) {
+ return result;
+ }
+ FX_OutOfMemoryTerminate(); // Never returns.
+ return nullptr; // Suppress compiler warning.
}
inline void* FX_AllocOrDie2D(size_t w, size_t h, size_t member_size) {
- if (w < std::numeric_limits<size_t>::max() / h) {
- return FX_AllocOrDie(w * h, member_size);
- }
- FX_OutOfMemoryTerminate(); // Never returns.
- return nullptr; // Suppress compiler warning.
+ if (w < std::numeric_limits<size_t>::max() / h) {
+ return FX_AllocOrDie(w * h, member_size);
+ }
+ FX_OutOfMemoryTerminate(); // Never returns.
+ return nullptr; // Suppress compiler warning.
}
-inline void* FX_ReallocOrDie(void* ptr, size_t num_members, size_t member_size) {
- if (void* result = FX_SafeRealloc(ptr, num_members, member_size)) {
- return result;
- }
- FX_OutOfMemoryTerminate(); // Never returns.
- return nullptr; // Suppress compiler warning.
+inline void* FX_ReallocOrDie(void* ptr,
+ size_t num_members,
+ size_t member_size) {
+ if (void* result = FX_SafeRealloc(ptr, num_members, member_size)) {
+ return result;
+ }
+ FX_OutOfMemoryTerminate(); // Never returns.
+ return nullptr; // Suppress compiler warning.
}
// Never returns NULL.
-#define FX_Alloc(type, size) (type*)FX_AllocOrDie(size, sizeof(type))
-#define FX_Alloc2D(type, w, h) (type*)FX_AllocOrDie2D(w, h, sizeof(type))
+#define FX_Alloc(type, size) (type*) FX_AllocOrDie(size, sizeof(type))
+#define FX_Alloc2D(type, w, h) (type*) FX_AllocOrDie2D(w, h, sizeof(type))
#define FX_Realloc(type, ptr, size) \
- (type*)FX_ReallocOrDie(ptr, size, sizeof(type))
+ (type*) FX_ReallocOrDie(ptr, size, sizeof(type))
// May return NULL.
-#define FX_TryAlloc(type, size) (type*)calloc(size, sizeof(type))
+#define FX_TryAlloc(type, size) (type*) calloc(size, sizeof(type))
#define FX_TryRealloc(type, ptr, size) \
- (type*)FX_SafeRealloc(ptr, size, sizeof(type))
+ (type*) FX_SafeRealloc(ptr, size, sizeof(type))
#define FX_Free(ptr) free(ptr)
-class CFX_DestructObject
-{
-public:
-
- virtual ~CFX_DestructObject() {}
+class CFX_DestructObject {
+ public:
+ virtual ~CFX_DestructObject() {}
};
-class CFX_GrowOnlyPool
-{
-public:
-
- CFX_GrowOnlyPool(size_t trunk_size = 16384);
+class CFX_GrowOnlyPool {
+ public:
+ CFX_GrowOnlyPool(size_t trunk_size = 16384);
- ~CFX_GrowOnlyPool();
+ ~CFX_GrowOnlyPool();
- void SetTrunkSize(size_t trunk_size)
- {
- m_TrunkSize = trunk_size;
- }
+ void SetTrunkSize(size_t trunk_size) { m_TrunkSize = trunk_size; }
- void* AllocDebug(size_t size, const FX_CHAR* file, int line)
- {
- return Alloc(size);
- }
+ void* AllocDebug(size_t size, const FX_CHAR* file, int line) {
+ return Alloc(size);
+ }
- void* Alloc(size_t size);
+ void* Alloc(size_t size);
- void* ReallocDebug(void* p, size_t new_size, const FX_CHAR* file, int line)
- {
- return NULL;
- }
+ void* ReallocDebug(void* p, size_t new_size, const FX_CHAR* file, int line) {
+ return NULL;
+ }
- void* Realloc(void* p, size_t new_size)
- {
- return NULL;
- }
+ void* Realloc(void* p, size_t new_size) { return NULL; }
- void Free(void*) {}
+ void Free(void*) {}
- void FreeAll();
-private:
+ void FreeAll();
- size_t m_TrunkSize;
+ private:
+ size_t m_TrunkSize;
- void* m_pFirstTrunk;
+ void* m_pFirstTrunk;
};
#endif // __cplusplus
diff --git a/core/include/fxcrt/fx_stream.h b/core/include/fxcrt/fx_stream.h
index b6fdcfcb6a..e51c2bd244 100644
--- a/core/include/fxcrt/fx_stream.h
+++ b/core/include/fxcrt/fx_stream.h
@@ -11,187 +11,179 @@
void* FX_OpenFolder(const FX_CHAR* path);
void* FX_OpenFolder(const FX_WCHAR* path);
-FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder);
-FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder);
+FX_BOOL FX_GetNextFile(void* handle,
+ CFX_ByteString& filename,
+ FX_BOOL& bFolder);
+FX_BOOL FX_GetNextFile(void* handle,
+ CFX_WideString& filename,
+ FX_BOOL& bFolder);
void FX_CloseFolder(void* handle);
FX_WCHAR FX_GetFolderSeparator();
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#define FX_FILESIZE int32_t
+#define FX_FILESIZE int32_t
#else
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#ifndef O_BINARY
-#define O_BINARY 0
+#define O_BINARY 0
#endif
#ifndef O_LARGEFILE
-#define O_LARGEFILE 0
+#define O_LARGEFILE 0
#endif
-#define FX_FILESIZE off_t
+#define FX_FILESIZE off_t
#endif
-#define FX_GETBYTEOFFSET32(a) 0
-#define FX_GETBYTEOFFSET40(a) 0
-#define FX_GETBYTEOFFSET48(a) 0
-#define FX_GETBYTEOFFSET56(a) 0
-#define FX_GETBYTEOFFSET24(a) ((uint8_t)(a>>24))
-#define FX_GETBYTEOFFSET16(a) ((uint8_t)(a>>16))
-#define FX_GETBYTEOFFSET8(a) ((uint8_t)(a>>8))
-#define FX_GETBYTEOFFSET0(a) ((uint8_t)(a))
-#define FX_FILEMODE_Write 0
-#define FX_FILEMODE_ReadOnly 1
-#define FX_FILEMODE_Truncate 2
-FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName);
-FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName);
-FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName);
-FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName);
-FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst);
-FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst);
-FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst);
-FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst);
-class IFX_StreamWrite
-{
-public:
- virtual ~IFX_StreamWrite() {}
- virtual void Release() = 0;
- virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
+#define FX_GETBYTEOFFSET32(a) 0
+#define FX_GETBYTEOFFSET40(a) 0
+#define FX_GETBYTEOFFSET48(a) 0
+#define FX_GETBYTEOFFSET56(a) 0
+#define FX_GETBYTEOFFSET24(a) ((uint8_t)(a >> 24))
+#define FX_GETBYTEOFFSET16(a) ((uint8_t)(a >> 16))
+#define FX_GETBYTEOFFSET8(a) ((uint8_t)(a >> 8))
+#define FX_GETBYTEOFFSET0(a) ((uint8_t)(a))
+#define FX_FILEMODE_Write 0
+#define FX_FILEMODE_ReadOnly 1
+#define FX_FILEMODE_Truncate 2
+FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName);
+FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName);
+FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName);
+FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName);
+FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc,
+ const CFX_ByteStringC& fileNameDst);
+FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc,
+ const CFX_WideStringC& fileNameDst);
+FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc,
+ const CFX_ByteStringC& fileNameDst);
+FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc,
+ const CFX_WideStringC& fileNameDst);
+class IFX_StreamWrite {
+ public:
+ virtual ~IFX_StreamWrite() {}
+ virtual void Release() = 0;
+ virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
};
-class IFX_FileWrite : public IFX_StreamWrite
-{
-public:
+class IFX_FileWrite : public IFX_StreamWrite {
+ public:
+ virtual void Release() = 0;
- virtual void Release() = 0;
+ virtual FX_FILESIZE GetSize() = 0;
- virtual FX_FILESIZE GetSize() = 0;
+ virtual FX_BOOL Flush() = 0;
- virtual FX_BOOL Flush() = 0;
-
- virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) = 0;
- virtual FX_BOOL WriteBlock(const void* pData, size_t size)
- {
- return WriteBlock(pData, GetSize(), size);
- }
+ virtual FX_BOOL WriteBlock(const void* pData,
+ FX_FILESIZE offset,
+ size_t size) = 0;
+ virtual FX_BOOL WriteBlock(const void* pData, size_t size) {
+ return WriteBlock(pData, GetSize(), size);
+ }
};
IFX_FileWrite* FX_CreateFileWrite(const FX_CHAR* filename);
IFX_FileWrite* FX_CreateFileWrite(const FX_WCHAR* filename);
-class IFX_StreamRead
-{
-public:
- virtual ~IFX_StreamRead() { }
+class IFX_StreamRead {
+ public:
+ virtual ~IFX_StreamRead() {}
- virtual void Release() = 0;
+ virtual void Release() = 0;
- virtual FX_BOOL IsEOF() = 0;
+ virtual FX_BOOL IsEOF() = 0;
- virtual FX_FILESIZE GetPosition() = 0;
+ virtual FX_FILESIZE GetPosition() = 0;
- virtual size_t ReadBlock(void* buffer, size_t size) = 0;
+ virtual size_t ReadBlock(void* buffer, size_t size) = 0;
};
-class IFX_FileRead : IFX_StreamRead
-{
-public:
- virtual void Release() = 0;
+class IFX_FileRead : IFX_StreamRead {
+ public:
+ virtual void Release() = 0;
- virtual FX_FILESIZE GetSize() = 0;
+ virtual FX_FILESIZE GetSize() = 0;
- virtual FX_BOOL IsEOF()
- {
- return FALSE;
- }
+ virtual FX_BOOL IsEOF() { return FALSE; }
- virtual FX_FILESIZE GetPosition()
- {
- return 0;
- }
+ virtual FX_FILESIZE GetPosition() { return 0; }
- virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size)
- {
- return FALSE;
- }
+ virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) {
+ return FALSE;
+ }
- virtual void ClearRange() {}
+ virtual void ClearRange() {}
- virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
+ virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
- virtual size_t ReadBlock(void* buffer, size_t size)
- {
- return 0;
- }
+ virtual size_t ReadBlock(void* buffer, size_t size) { return 0; }
};
IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename);
IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename);
-class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite
-{
-public:
-
- virtual IFX_FileStream* Retain() = 0;
+class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite {
+ public:
+ virtual IFX_FileStream* Retain() = 0;
- virtual void Release() = 0;
+ virtual void Release() = 0;
- virtual FX_FILESIZE GetSize() = 0;
+ virtual FX_FILESIZE GetSize() = 0;
- virtual FX_BOOL IsEOF() = 0;
+ virtual FX_BOOL IsEOF() = 0;
- virtual FX_FILESIZE GetPosition() = 0;
+ virtual FX_FILESIZE GetPosition() = 0;
- virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
+ virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
- virtual size_t ReadBlock(void* buffer, size_t size) = 0;
+ virtual size_t ReadBlock(void* buffer, size_t size) = 0;
- virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) = 0;
- virtual FX_BOOL WriteBlock(const void* buffer, size_t size)
- {
- return WriteBlock(buffer, GetSize(), size);
- }
+ virtual FX_BOOL WriteBlock(const void* buffer,
+ FX_FILESIZE offset,
+ size_t size) = 0;
+ virtual FX_BOOL WriteBlock(const void* buffer, size_t size) {
+ return WriteBlock(buffer, GetSize(), size);
+ }
- virtual FX_BOOL Flush() = 0;
+ virtual FX_BOOL Flush() = 0;
};
-IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes);
-IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD dwModes);
-class IFX_FileAccess
-{
-public:
- virtual ~IFX_FileAccess() {}
- virtual void Release() = 0;
- virtual IFX_FileAccess* Retain() = 0;
- virtual void GetPath(CFX_WideString& wsPath) = 0;
- virtual IFX_FileStream* CreateFileStream(FX_DWORD dwModes) = 0;
+IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes);
+IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD dwModes);
+class IFX_FileAccess {
+ public:
+ virtual ~IFX_FileAccess() {}
+ virtual void Release() = 0;
+ virtual IFX_FileAccess* Retain() = 0;
+ virtual void GetPath(CFX_WideString& wsPath) = 0;
+ virtual IFX_FileStream* CreateFileStream(FX_DWORD dwModes) = 0;
};
IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath);
-class IFX_MemoryStream : public IFX_FileStream
-{
-public:
+class IFX_MemoryStream : public IFX_FileStream {
+ public:
+ virtual FX_BOOL IsConsecutive() const = 0;
- virtual FX_BOOL IsConsecutive() const = 0;
+ virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
- virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
+ virtual uint8_t* GetBuffer() const = 0;
- virtual uint8_t* GetBuffer() const = 0;
+ virtual void AttachBuffer(uint8_t* pBuffer,
+ size_t nSize,
+ FX_BOOL bTakeOver = FALSE) = 0;
- virtual void AttachBuffer(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE) = 0;
-
- virtual void DetachBuffer() = 0;
+ virtual void DetachBuffer() = 0;
};
-IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE);
-IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
-class IFX_BufferRead : public IFX_StreamRead
-{
-public:
-
- virtual void Release() = 0;
+IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
+ size_t nSize,
+ FX_BOOL bTakeOver = FALSE);
+IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
+class IFX_BufferRead : public IFX_StreamRead {
+ public:
+ virtual void Release() = 0;
- virtual FX_BOOL IsEOF() = 0;
+ virtual FX_BOOL IsEOF() = 0;
- virtual FX_FILESIZE GetPosition() = 0;
+ virtual FX_FILESIZE GetPosition() = 0;
- virtual size_t ReadBlock(void* buffer, size_t size) = 0;
+ virtual size_t ReadBlock(void* buffer, size_t size) = 0;
- virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
+ virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
- virtual const uint8_t* GetBlockBuffer() = 0;
+ virtual const uint8_t* GetBlockBuffer() = 0;
- virtual size_t GetBlockSize() = 0;
+ virtual size_t GetBlockSize() = 0;
- virtual FX_FILESIZE GetBlockOffset() = 0;
+ virtual FX_FILESIZE GetBlockOffset() = 0;
};
#endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_
diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h
index 8d73555814..f493c53ed9 100644
--- a/core/include/fxcrt/fx_string.h
+++ b/core/include/fxcrt/fx_string.h
@@ -20,891 +20,790 @@ struct CFX_CharMap;
// An immutable string with caller-provided storage which must outlive the
// string itself.
-class CFX_ByteStringC
-{
-public:
- typedef FX_CHAR value_type;
-
- CFX_ByteStringC()
- {
- m_Ptr = NULL;
- m_Length = 0;
- }
-
- CFX_ByteStringC(const uint8_t* ptr, FX_STRSIZE size)
- {
- m_Ptr = ptr;
- m_Length = size;
- }
-
- CFX_ByteStringC(const FX_CHAR* ptr)
- {
- m_Ptr = (const uint8_t*)ptr;
- m_Length = ptr ? FXSYS_strlen(ptr) : 0;
- }
-
- // |ch| must be an lvalue that outlives the the CFX_ByteStringC. However,
- // the use of char rvalues are not caught at compile time. They are
- // implicitly promoted to CFX_ByteString (see below) and then the
- // CFX_ByteStringC is constructed from the CFX_ByteString via the alternate
- // constructor below. The CFX_ByteString then typically goes out of scope
- // and |m_Ptr| may be left pointing to invalid memory. Beware.
- // TODO(tsepez): Mark single-argument string constructors as explicit.
- CFX_ByteStringC(FX_CHAR& ch)
- {
- m_Ptr = (const uint8_t*)&ch;
- m_Length = 1;
- }
-
- CFX_ByteStringC(const FX_CHAR* ptr, FX_STRSIZE len)
- {
- m_Ptr = (const uint8_t*)ptr;
- m_Length = (len == -1) ? FXSYS_strlen(ptr) : len;
- }
-
- CFX_ByteStringC(const CFX_ByteStringC& src)
- {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- }
+class CFX_ByteStringC {
+ public:
+ typedef FX_CHAR value_type;
+
+ CFX_ByteStringC() {
+ m_Ptr = NULL;
+ m_Length = 0;
+ }
+
+ CFX_ByteStringC(const uint8_t* ptr, FX_STRSIZE size) {
+ m_Ptr = ptr;
+ m_Length = size;
+ }
+
+ CFX_ByteStringC(const FX_CHAR* ptr) {
+ m_Ptr = (const uint8_t*)ptr;
+ m_Length = ptr ? FXSYS_strlen(ptr) : 0;
+ }
+
+ // |ch| must be an lvalue that outlives the the CFX_ByteStringC. However,
+ // the use of char rvalues are not caught at compile time. They are
+ // implicitly promoted to CFX_ByteString (see below) and then the
+ // CFX_ByteStringC is constructed from the CFX_ByteString via the alternate
+ // constructor below. The CFX_ByteString then typically goes out of scope
+ // and |m_Ptr| may be left pointing to invalid memory. Beware.
+ // TODO(tsepez): Mark single-argument string constructors as explicit.
+ CFX_ByteStringC(FX_CHAR& ch) {
+ m_Ptr = (const uint8_t*)&ch;
+ m_Length = 1;
+ }
+
+ CFX_ByteStringC(const FX_CHAR* ptr, FX_STRSIZE len) {
+ m_Ptr = (const uint8_t*)ptr;
+ m_Length = (len == -1) ? FXSYS_strlen(ptr) : len;
+ }
+
+ CFX_ByteStringC(const CFX_ByteStringC& src) {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ }
+
+ CFX_ByteStringC(const CFX_ByteString& src);
+
+ CFX_ByteStringC& operator=(const FX_CHAR* src) {
+ m_Ptr = (const uint8_t*)src;
+ m_Length = m_Ptr ? FXSYS_strlen(src) : 0;
+ return *this;
+ }
- CFX_ByteStringC(const CFX_ByteString& src);
+ CFX_ByteStringC& operator=(const CFX_ByteStringC& src) {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ return *this;
+ }
- CFX_ByteStringC& operator = (const FX_CHAR* src)
- {
- m_Ptr = (const uint8_t*)src;
- m_Length = m_Ptr ? FXSYS_strlen(src) : 0;
- return *this;
- }
+ CFX_ByteStringC& operator=(const CFX_ByteString& src);
- CFX_ByteStringC& operator = (const CFX_ByteStringC& src)
- {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- return *this;
- }
+ bool operator==(const char* ptr) const {
+ return FXSYS_strlen(ptr) == m_Length &&
+ FXSYS_memcmp(ptr, m_Ptr, m_Length) == 0;
+ }
+ bool operator==(const CFX_ByteStringC& other) const {
+ return other.m_Length == m_Length &&
+ FXSYS_memcmp(other.m_Ptr, m_Ptr, m_Length) == 0;
+ }
+ bool operator!=(const char* ptr) const { return !(*this == ptr); }
+ bool operator!=(const CFX_ByteStringC& other) const {
+ return !(*this == other);
+ }
- CFX_ByteStringC& operator = (const CFX_ByteString& src);
+ FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
- bool operator== (const char* ptr) const {
- return FXSYS_strlen(ptr) == m_Length &&
- FXSYS_memcmp(ptr, m_Ptr, m_Length) == 0;
- }
- bool operator== (const CFX_ByteStringC& other) const {
- return other.m_Length == m_Length &&
- FXSYS_memcmp(other.m_Ptr, m_Ptr, m_Length) == 0;
- }
- bool operator!= (const char* ptr) const { return !(*this == ptr); }
- bool operator!= (const CFX_ByteStringC& other) const {
- return !(*this == other);
- }
+ const uint8_t* GetPtr() const { return m_Ptr; }
- FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
+ const FX_CHAR* GetCStr() const { return (const FX_CHAR*)m_Ptr; }
- const uint8_t* GetPtr() const
- {
- return m_Ptr;
- }
+ FX_STRSIZE GetLength() const { return m_Length; }
- const FX_CHAR* GetCStr() const
- {
- return (const FX_CHAR*)m_Ptr;
- }
+ bool IsEmpty() const { return m_Length == 0; }
- FX_STRSIZE GetLength() const
- {
- return m_Length;
- }
+ uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
- bool IsEmpty() const
- {
- return m_Length == 0;
+ CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
+ if (index < 0) {
+ index = 0;
}
-
- uint8_t GetAt(FX_STRSIZE index) const
- {
- return m_Ptr[index];
+ if (index > m_Length) {
+ return CFX_ByteStringC();
}
-
- CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
- {
- if (index < 0) {
- index = 0;
- }
- if (index > m_Length) {
- return CFX_ByteStringC();
- }
- if (count < 0 || count > m_Length - index) {
- count = m_Length - index;
- }
- return CFX_ByteStringC(m_Ptr + index, count);
+ if (count < 0 || count > m_Length - index) {
+ count = m_Length - index;
}
+ return CFX_ByteStringC(m_Ptr + index, count);
+ }
- const uint8_t& operator[] (size_t index) const
- {
- return m_Ptr[index];
- }
+ const uint8_t& operator[](size_t index) const { return m_Ptr[index]; }
- bool operator< (const CFX_ByteStringC& that) const
- {
- int result = memcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
- return result < 0 || (result == 0 && m_Length < that.m_Length);
- }
+ bool operator<(const CFX_ByteStringC& that) const {
+ int result = memcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
+ return result < 0 || (result == 0 && m_Length < that.m_Length);
+ }
-protected:
- const uint8_t* m_Ptr;
- FX_STRSIZE m_Length;
+ protected:
+ const uint8_t* m_Ptr;
+ FX_STRSIZE m_Length;
-private:
- void* operator new (size_t) throw()
- {
- return NULL;
- }
+ private:
+ void* operator new(size_t) throw() { return NULL; }
};
-inline bool operator== (const char* lhs, const CFX_ByteStringC& rhs) {
- return rhs == lhs;
+inline bool operator==(const char* lhs, const CFX_ByteStringC& rhs) {
+ return rhs == lhs;
}
-inline bool operator!= (const char* lhs, const CFX_ByteStringC& rhs) {
- return rhs != lhs;
+inline bool operator!=(const char* lhs, const CFX_ByteStringC& rhs) {
+ return rhs != lhs;
}
-#define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str-1)
+#define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str - 1)
#define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4))
// A mutable string with shared buffers using copy-on-write semantics that
// avoids the cost of std::string's iterator stability guarantees.
-class CFX_ByteString
-{
-public:
- typedef FX_CHAR value_type;
+class CFX_ByteString {
+ public:
+ typedef FX_CHAR value_type;
- CFX_ByteString() : m_pData(nullptr) { }
+ CFX_ByteString() : m_pData(nullptr) {}
- // Copy constructor.
- CFX_ByteString(const CFX_ByteString& str);
+ // Copy constructor.
+ CFX_ByteString(const CFX_ByteString& str);
- // Move constructor.
- inline CFX_ByteString(CFX_ByteString&& other) {
- m_pData = other.m_pData;
- other.m_pData = nullptr;
- }
+ // Move constructor.
+ inline CFX_ByteString(CFX_ByteString&& other) {
+ m_pData = other.m_pData;
+ other.m_pData = nullptr;
+ }
- CFX_ByteString(char ch);
- CFX_ByteString(const FX_CHAR* ptr)
- : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) { }
+ CFX_ByteString(char ch);
+ CFX_ByteString(const FX_CHAR* ptr)
+ : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {}
- CFX_ByteString(const FX_CHAR* ptr, FX_STRSIZE len);
- CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len);
+ CFX_ByteString(const FX_CHAR* ptr, FX_STRSIZE len);
+ CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len);
- CFX_ByteString(const CFX_ByteStringC& bstrc);
- CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2);
+ CFX_ByteString(const CFX_ByteStringC& bstrc);
+ CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2);
- ~CFX_ByteString();
+ ~CFX_ByteString();
- static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1);
+ static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1);
- static CFX_ByteString FromUnicode(const CFX_WideString& str);
+ static CFX_ByteString FromUnicode(const CFX_WideString& str);
- // Explicit conversion to raw string
- const FX_CHAR* c_str() const
- {
- return m_pData ? m_pData->m_String : "";
- }
+ // Explicit conversion to raw string
+ const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; }
- // Implicit conversion to C-style string -- deprecated
- operator const FX_CHAR*() const
- {
- return m_pData ? m_pData->m_String : "";
- }
+ // Implicit conversion to C-style string -- deprecated
+ operator const FX_CHAR*() const { return m_pData ? m_pData->m_String : ""; }
- operator const uint8_t*() const
- {
- return m_pData ? (const uint8_t*)m_pData->m_String : NULL;
- }
+ operator const uint8_t*() const {
+ return m_pData ? (const uint8_t*)m_pData->m_String : NULL;
+ }
- FX_STRSIZE GetLength() const
- {
- return m_pData ? m_pData->m_nDataLength : 0;
- }
-
- bool IsEmpty() const
- {
- return !GetLength();
- }
-
- int Compare(const CFX_ByteStringC& str) const;
+ FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
+ bool IsEmpty() const { return !GetLength(); }
- bool Equal(const char* ptr) const;
- bool Equal(const CFX_ByteStringC& str) const;
- bool Equal(const CFX_ByteString& other) const;
+ int Compare(const CFX_ByteStringC& str) const;
- bool EqualNoCase(const CFX_ByteStringC& str) const;
+ bool Equal(const char* ptr) const;
+ bool Equal(const CFX_ByteStringC& str) const;
+ bool Equal(const CFX_ByteString& other) const;
- bool operator== (const char* ptr) const { return Equal(ptr); }
- bool operator== (const CFX_ByteStringC& str) const { return Equal(str); }
- bool operator== (const CFX_ByteString& other) const { return Equal(other); }
-
- bool operator!= (const char* ptr) const { return !(*this == ptr); }
- bool operator!= (const CFX_ByteStringC& str) const {
- return !(*this == str);
- }
- bool operator!= (const CFX_ByteString& other) const {
- return !(*this == other);
- }
+ bool EqualNoCase(const CFX_ByteStringC& str) const;
- bool operator< (const CFX_ByteString& str) const
- {
- int result = FXSYS_memcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength()));
- return result < 0 || (result == 0 && GetLength() < str.GetLength());
- }
+ bool operator==(const char* ptr) const { return Equal(ptr); }
+ bool operator==(const CFX_ByteStringC& str) const { return Equal(str); }
+ bool operator==(const CFX_ByteString& other) const { return Equal(other); }
- void Empty();
+ bool operator!=(const char* ptr) const { return !(*this == ptr); }
+ bool operator!=(const CFX_ByteStringC& str) const { return !(*this == str); }
+ bool operator!=(const CFX_ByteString& other) const {
+ return !(*this == other);
+ }
- const CFX_ByteString& operator = (const FX_CHAR* str);
+ bool operator<(const CFX_ByteString& str) const {
+ int result = FXSYS_memcmp(c_str(), str.c_str(),
+ std::min(GetLength(), str.GetLength()));
+ return result < 0 || (result == 0 && GetLength() < str.GetLength());
+ }
- const CFX_ByteString& operator = (const CFX_ByteStringC& bstrc);
+ void Empty();
- const CFX_ByteString& operator = (const CFX_ByteString& stringSrc);
+ const CFX_ByteString& operator=(const FX_CHAR* str);
- const CFX_ByteString& operator = (const CFX_BinaryBuf& buf);
+ const CFX_ByteString& operator=(const CFX_ByteStringC& bstrc);
- void Load(const uint8_t* str, FX_STRSIZE len);
+ const CFX_ByteString& operator=(const CFX_ByteString& stringSrc);
- const CFX_ByteString& operator += (FX_CHAR ch);
+ const CFX_ByteString& operator=(const CFX_BinaryBuf& buf);
- const CFX_ByteString& operator += (const FX_CHAR* str);
+ void Load(const uint8_t* str, FX_STRSIZE len);
- const CFX_ByteString& operator += (const CFX_ByteString& str);
+ const CFX_ByteString& operator+=(FX_CHAR ch);
- const CFX_ByteString& operator += (const CFX_ByteStringC& bstrc);
+ const CFX_ByteString& operator+=(const FX_CHAR* str);
- uint8_t GetAt(FX_STRSIZE nIndex) const
- {
- return m_pData ? m_pData->m_String[nIndex] : 0;
- }
+ const CFX_ByteString& operator+=(const CFX_ByteString& str);
- uint8_t operator[](FX_STRSIZE nIndex) const
- {
- return m_pData ? m_pData->m_String[nIndex] : 0;
- }
+ const CFX_ByteString& operator+=(const CFX_ByteStringC& bstrc);
- void SetAt(FX_STRSIZE nIndex, FX_CHAR ch);
+ uint8_t GetAt(FX_STRSIZE nIndex) const {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+ }
- FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch);
+ uint8_t operator[](FX_STRSIZE nIndex) const {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+ }
- FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
+ void SetAt(FX_STRSIZE nIndex, FX_CHAR ch);
+ FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch);
- void Format(const FX_CHAR* lpszFormat, ... );
+ FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
- void FormatV(const FX_CHAR* lpszFormat, va_list argList);
+ void Format(const FX_CHAR* lpszFormat, ...);
+ void FormatV(const FX_CHAR* lpszFormat, va_list argList);
- void Reserve(FX_STRSIZE len);
+ void Reserve(FX_STRSIZE len);
- FX_CHAR* GetBuffer(FX_STRSIZE len);
+ FX_CHAR* GetBuffer(FX_STRSIZE len);
- void ReleaseBuffer(FX_STRSIZE len = -1);
+ void ReleaseBuffer(FX_STRSIZE len = -1);
- CFX_ByteString Mid(FX_STRSIZE first) const;
+ CFX_ByteString Mid(FX_STRSIZE first) const;
- CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
+ CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
- CFX_ByteString Left(FX_STRSIZE count) const;
+ CFX_ByteString Left(FX_STRSIZE count) const;
- CFX_ByteString Right(FX_STRSIZE count) const;
+ CFX_ByteString Right(FX_STRSIZE count) const;
- FX_STRSIZE Find(const CFX_ByteStringC& lpszSub, FX_STRSIZE start = 0) const;
+ FX_STRSIZE Find(const CFX_ByteStringC& lpszSub, FX_STRSIZE start = 0) const;
- FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start = 0) const;
+ FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start = 0) const;
- FX_STRSIZE ReverseFind(FX_CHAR ch) const;
+ FX_STRSIZE ReverseFind(FX_CHAR ch) const;
- void MakeLower();
+ void MakeLower();
- void MakeUpper();
+ void MakeUpper();
- void TrimRight();
+ void TrimRight();
- void TrimRight(FX_CHAR chTarget);
+ void TrimRight(FX_CHAR chTarget);
- void TrimRight(const CFX_ByteStringC& lpszTargets);
+ void TrimRight(const CFX_ByteStringC& lpszTargets);
- void TrimLeft();
+ void TrimLeft();
- void TrimLeft(FX_CHAR chTarget);
+ void TrimLeft(FX_CHAR chTarget);
- void TrimLeft(const CFX_ByteStringC& lpszTargets);
+ void TrimLeft(const CFX_ByteStringC& lpszTargets);
- FX_STRSIZE Replace(const CFX_ByteStringC& lpszOld, const CFX_ByteStringC& lpszNew);
+ FX_STRSIZE Replace(const CFX_ByteStringC& lpszOld,
+ const CFX_ByteStringC& lpszNew);
- FX_STRSIZE Remove(FX_CHAR ch);
+ FX_STRSIZE Remove(FX_CHAR ch);
- CFX_WideString UTF8Decode() const;
+ CFX_WideString UTF8Decode() const;
- void ConvertFrom(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL);
+ void ConvertFrom(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL);
- FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
+ FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
-#define FXFORMAT_SIGNED 1
-#define FXFORMAT_HEX 2
-#define FXFORMAT_CAPITAL 4
+#define FXFORMAT_SIGNED 1
+#define FXFORMAT_HEX 2
+#define FXFORMAT_CAPITAL 4
- static CFX_ByteString FormatInteger(int i, FX_DWORD flags = 0);
- static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
+ static CFX_ByteString FormatInteger(int i, FX_DWORD flags = 0);
+ static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
-protected:
- // To ensure ref counts do not overflow, consider the worst possible case:
- // the entire address space contains nothing but pointers to this object.
- // Since the count increments with each new pointer, the largest value is
- // the number of pointers that can fit into the address space. The size of
- // the address space itself is a good upper bound on it; we need not go
- // larger.
- class StringData {
- public:
- static StringData* Create(int nLen);
- void Retain() { ++m_nRefs; }
- void Release() { if (--m_nRefs <= 0) FX_Free(this); }
+ protected:
+ // To ensure ref counts do not overflow, consider the worst possible case:
+ // the entire address space contains nothing but pointers to this object.
+ // Since the count increments with each new pointer, the largest value is
+ // the number of pointers that can fit into the address space. The size of
+ // the address space itself is a good upper bound on it; we need not go
+ // larger.
+ class StringData {
+ public:
+ static StringData* Create(int nLen);
+ void Retain() { ++m_nRefs; }
+ void Release() {
+ if (--m_nRefs <= 0)
+ FX_Free(this);
+ }
- intptr_t m_nRefs; // Would prefer ssize_t, but no windows support.
- FX_STRSIZE m_nDataLength;
- FX_STRSIZE m_nAllocLength;
- FX_CHAR m_String[1];
+ intptr_t m_nRefs; // Would prefer ssize_t, but no windows support.
+ FX_STRSIZE m_nDataLength;
+ FX_STRSIZE m_nAllocLength;
+ FX_CHAR m_String[1];
- private:
- StringData(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
- : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
- FXSYS_assert(dataLen >= 0);
- FXSYS_assert(allocLen >= 0);
- FXSYS_assert(dataLen <= allocLen);
- m_String[dataLen] = 0;
- }
- ~StringData() = delete;
- };
+ private:
+ StringData(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
+ : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
+ FXSYS_assert(dataLen >= 0);
+ FXSYS_assert(allocLen >= 0);
+ FXSYS_assert(dataLen <= allocLen);
+ m_String[dataLen] = 0;
+ }
+ ~StringData() = delete;
+ };
- void AllocCopy(CFX_ByteString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const;
- void AssignCopy(FX_STRSIZE nSrcLen, const FX_CHAR* lpszSrcData);
- void ConcatCopy(FX_STRSIZE nSrc1Len, const FX_CHAR* lpszSrc1Data, FX_STRSIZE nSrc2Len, const FX_CHAR* lpszSrc2Data);
- void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_CHAR* lpszSrcData);
- void CopyBeforeWrite();
- void AllocBeforeWrite(FX_STRSIZE nLen);
+ void AllocCopy(CFX_ByteString& dest,
+ FX_STRSIZE nCopyLen,
+ FX_STRSIZE nCopyIndex) const;
+ void AssignCopy(FX_STRSIZE nSrcLen, const FX_CHAR* lpszSrcData);
+ void ConcatCopy(FX_STRSIZE nSrc1Len,
+ const FX_CHAR* lpszSrc1Data,
+ FX_STRSIZE nSrc2Len,
+ const FX_CHAR* lpszSrc2Data);
+ void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_CHAR* lpszSrcData);
+ void CopyBeforeWrite();
+ void AllocBeforeWrite(FX_STRSIZE nLen);
- StringData* m_pData;
- friend class fxcrt_ByteStringConcatInPlace_Test;
+ StringData* m_pData;
+ friend class fxcrt_ByteStringConcatInPlace_Test;
};
-inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src)
-{
- m_Ptr = (const uint8_t*)src;
- m_Length = src.GetLength();
+inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src) {
+ m_Ptr = (const uint8_t*)src;
+ m_Length = src.GetLength();
}
-inline CFX_ByteStringC& CFX_ByteStringC::operator = (const CFX_ByteString& src)
-{
- m_Ptr = (const uint8_t*)src;
- m_Length = src.GetLength();
- return *this;
+inline CFX_ByteStringC& CFX_ByteStringC::operator=(const CFX_ByteString& src) {
+ m_Ptr = (const uint8_t*)src;
+ m_Length = src.GetLength();
+ return *this;
}
-inline bool operator== (const char* lhs, const CFX_ByteString& rhs) {
- return rhs == lhs;
+inline bool operator==(const char* lhs, const CFX_ByteString& rhs) {
+ return rhs == lhs;
}
-inline bool operator== (const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
- return rhs == lhs;
+inline bool operator==(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
+ return rhs == lhs;
}
-inline bool operator!= (const char* lhs, const CFX_ByteString& rhs) {
- return rhs != lhs;
+inline bool operator!=(const char* lhs, const CFX_ByteString& rhs) {
+ return rhs != lhs;
}
-inline bool operator!= (const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
- return rhs != lhs;
+inline bool operator!=(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
+ return rhs != lhs;
}
-inline CFX_ByteString operator + (const CFX_ByteStringC& str1, const CFX_ByteStringC& str2)
-{
- return CFX_ByteString(str1, str2);
+inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
+ const CFX_ByteStringC& str2) {
+ return CFX_ByteString(str1, str2);
}
-inline CFX_ByteString operator + (const CFX_ByteStringC& str1, const FX_CHAR* str2)
-{
- return CFX_ByteString(str1, str2);
+inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
+ const FX_CHAR* str2) {
+ return CFX_ByteString(str1, str2);
}
-inline CFX_ByteString operator + (const FX_CHAR* str1, const CFX_ByteStringC& str2)
-{
- return CFX_ByteString(str1, str2);
+inline CFX_ByteString operator+(const FX_CHAR* str1,
+ const CFX_ByteStringC& str2) {
+ return CFX_ByteString(str1, str2);
}
-inline CFX_ByteString operator + (const CFX_ByteStringC& str1, FX_CHAR ch)
-{
- return CFX_ByteString(str1, CFX_ByteStringC(ch));
+inline CFX_ByteString operator+(const CFX_ByteStringC& str1, FX_CHAR ch) {
+ return CFX_ByteString(str1, CFX_ByteStringC(ch));
}
-inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteStringC& str2)
-{
- return CFX_ByteString(ch, str2);
+inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteStringC& str2) {
+ return CFX_ByteString(ch, str2);
}
-inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteString& str2)
-{
- return CFX_ByteString(str1, str2);
+inline CFX_ByteString operator+(const CFX_ByteString& str1,
+ const CFX_ByteString& str2) {
+ return CFX_ByteString(str1, str2);
}
-inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch)
-{
- return CFX_ByteString(str1, CFX_ByteStringC(ch));
+inline CFX_ByteString operator+(const CFX_ByteString& str1, FX_CHAR ch) {
+ return CFX_ByteString(str1, CFX_ByteStringC(ch));
}
-inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2)
-{
- return CFX_ByteString(ch, str2);
+inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteString& str2) {
+ return CFX_ByteString(ch, str2);
}
-inline CFX_ByteString operator + (const CFX_ByteString& str1, const FX_CHAR* str2)
-{
- return CFX_ByteString(str1, str2);
+inline CFX_ByteString operator+(const CFX_ByteString& str1,
+ const FX_CHAR* str2) {
+ return CFX_ByteString(str1, str2);
}
-inline CFX_ByteString operator + (const FX_CHAR* str1, const CFX_ByteString& str2)
-{
- return CFX_ByteString(str1, str2);
+inline CFX_ByteString operator+(const FX_CHAR* str1,
+ const CFX_ByteString& str2) {
+ return CFX_ByteString(str1, str2);
}
-inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteStringC& str2)
-{
- return CFX_ByteString(str1, str2);
+inline CFX_ByteString operator+(const CFX_ByteString& str1,
+ const CFX_ByteStringC& str2) {
+ return CFX_ByteString(str1, str2);
}
-inline CFX_ByteString operator + (const CFX_ByteStringC& str1, const CFX_ByteString& str2)
-{
- return CFX_ByteString(str1, str2);
+inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
+ const CFX_ByteString& str2) {
+ return CFX_ByteString(str1, str2);
}
-class CFX_WideStringC
-{
-public:
- typedef FX_WCHAR value_type;
+class CFX_WideStringC {
+ public:
+ typedef FX_WCHAR value_type;
- CFX_WideStringC()
- {
- m_Ptr = NULL;
- m_Length = 0;
- }
+ CFX_WideStringC() {
+ m_Ptr = NULL;
+ m_Length = 0;
+ }
- CFX_WideStringC(const FX_WCHAR* ptr)
- {
- m_Ptr = ptr;
- m_Length = ptr ? FXSYS_wcslen(ptr) : 0;
- }
+ CFX_WideStringC(const FX_WCHAR* ptr) {
+ m_Ptr = ptr;
+ m_Length = ptr ? FXSYS_wcslen(ptr) : 0;
+ }
- CFX_WideStringC(FX_WCHAR& ch)
- {
- m_Ptr = &ch;
- m_Length = 1;
- }
+ CFX_WideStringC(FX_WCHAR& ch) {
+ m_Ptr = &ch;
+ m_Length = 1;
+ }
- CFX_WideStringC(const FX_WCHAR* ptr, FX_STRSIZE len)
- {
- m_Ptr = ptr;
- m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len;
- }
+ CFX_WideStringC(const FX_WCHAR* ptr, FX_STRSIZE len) {
+ m_Ptr = ptr;
+ m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len;
+ }
- CFX_WideStringC(const CFX_WideStringC& src)
- {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- }
+ CFX_WideStringC(const CFX_WideStringC& src) {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ }
- CFX_WideStringC(const CFX_WideString& src);
+ CFX_WideStringC(const CFX_WideString& src);
- CFX_WideStringC& operator = (const FX_WCHAR* src)
- {
- m_Ptr = src;
- m_Length = FXSYS_wcslen(src);
- return *this;
- }
+ CFX_WideStringC& operator=(const FX_WCHAR* src) {
+ m_Ptr = src;
+ m_Length = FXSYS_wcslen(src);
+ return *this;
+ }
- CFX_WideStringC& operator = (const CFX_WideStringC& src)
- {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- return *this;
- }
+ CFX_WideStringC& operator=(const CFX_WideStringC& src) {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ return *this;
+ }
- CFX_WideStringC& operator = (const CFX_WideString& src);
+ CFX_WideStringC& operator=(const CFX_WideString& src);
- bool operator== (const wchar_t* ptr) const {
- return FXSYS_wcslen(ptr) == m_Length &&
- wmemcmp(ptr, m_Ptr, m_Length) == 0;
- }
- bool operator== (const CFX_WideStringC& str) const {
- return str.m_Length == m_Length &&
- wmemcmp(str.m_Ptr, m_Ptr, m_Length) == 0;
- }
- bool operator!= (const wchar_t* ptr) const { return !(*this == ptr); }
- bool operator!= (const CFX_WideStringC& str) const {
- return !(*this == str);
- }
+ bool operator==(const wchar_t* ptr) const {
+ return FXSYS_wcslen(ptr) == m_Length && wmemcmp(ptr, m_Ptr, m_Length) == 0;
+ }
+ bool operator==(const CFX_WideStringC& str) const {
+ return str.m_Length == m_Length && wmemcmp(str.m_Ptr, m_Ptr, m_Length) == 0;
+ }
+ bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
+ bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); }
- const FX_WCHAR* GetPtr() const
- {
- return m_Ptr;
- }
+ const FX_WCHAR* GetPtr() const { return m_Ptr; }
- FX_STRSIZE GetLength() const
- {
- return m_Length;
- }
+ FX_STRSIZE GetLength() const { return m_Length; }
- bool IsEmpty() const
- {
- return m_Length == 0;
- }
+ bool IsEmpty() const { return m_Length == 0; }
- FX_WCHAR GetAt(FX_STRSIZE index) const
- {
- return m_Ptr[index];
- }
+ FX_WCHAR GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
- CFX_WideStringC Left(FX_STRSIZE count) const
- {
- if (count < 1) {
- return CFX_WideStringC();
- }
- if (count > m_Length) {
- count = m_Length;
- }
- return CFX_WideStringC(m_Ptr, count);
+ CFX_WideStringC Left(FX_STRSIZE count) const {
+ if (count < 1) {
+ return CFX_WideStringC();
}
-
- CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
- {
- if (index < 0) {
- index = 0;
- }
- if (index > m_Length) {
- return CFX_WideStringC();
- }
- if (count < 0 || count > m_Length - index) {
- count = m_Length - index;
- }
- return CFX_WideStringC(m_Ptr + index, count);
+ if (count > m_Length) {
+ count = m_Length;
}
+ return CFX_WideStringC(m_Ptr, count);
+ }
- CFX_WideStringC Right(FX_STRSIZE count) const
- {
- if (count < 1) {
- return CFX_WideStringC();
- }
- if (count > m_Length) {
- count = m_Length;
- }
- return CFX_WideStringC(m_Ptr + m_Length - count, count);
+ CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
+ if (index < 0) {
+ index = 0;
}
+ if (index > m_Length) {
+ return CFX_WideStringC();
+ }
+ if (count < 0 || count > m_Length - index) {
+ count = m_Length - index;
+ }
+ return CFX_WideStringC(m_Ptr + index, count);
+ }
- const FX_WCHAR& operator[] (size_t index) const
- {
- return m_Ptr[index];
+ CFX_WideStringC Right(FX_STRSIZE count) const {
+ if (count < 1) {
+ return CFX_WideStringC();
+ }
+ if (count > m_Length) {
+ count = m_Length;
}
+ return CFX_WideStringC(m_Ptr + m_Length - count, count);
+ }
- bool operator< (const CFX_WideStringC& that) const
- {
- int result = wmemcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
- return result < 0 || (result == 0 && m_Length < that.m_Length);
- }
+ const FX_WCHAR& operator[](size_t index) const { return m_Ptr[index]; }
-protected:
- const FX_WCHAR* m_Ptr;
- FX_STRSIZE m_Length;
+ bool operator<(const CFX_WideStringC& that) const {
+ int result = wmemcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
+ return result < 0 || (result == 0 && m_Length < that.m_Length);
+ }
-private:
- void* operator new (size_t) throw()
- {
- return NULL;
- }
+ protected:
+ const FX_WCHAR* m_Ptr;
+ FX_STRSIZE m_Length;
+
+ private:
+ void* operator new(size_t) throw() { return NULL; }
};
-inline bool operator== (const wchar_t* lhs, const CFX_WideStringC& rhs) {
- return rhs == lhs;
+inline bool operator==(const wchar_t* lhs, const CFX_WideStringC& rhs) {
+ return rhs == lhs;
}
-inline bool operator!= (const wchar_t* lhs, const CFX_WideStringC& rhs) {
- return rhs != lhs;
+inline bool operator!=(const wchar_t* lhs, const CFX_WideStringC& rhs) {
+ return rhs != lhs;
}
#define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1)
// A mutable string with shared buffers using copy-on-write semantics that
// avoids the cost of std::string's iterator stability guarantees.
-class CFX_WideString
-{
-public:
- typedef FX_WCHAR value_type;
+class CFX_WideString {
+ public:
+ typedef FX_WCHAR value_type;
- CFX_WideString() : m_pData(nullptr) { }
+ CFX_WideString() : m_pData(nullptr) {}
- // Copy constructor.
- CFX_WideString(const CFX_WideString& str);
+ // Copy constructor.
+ CFX_WideString(const CFX_WideString& str);
- // Move constructor.
- inline CFX_WideString(CFX_WideString&& other) {
- m_pData = other.m_pData;
- other.m_pData = nullptr;
- }
+ // Move constructor.
+ inline CFX_WideString(CFX_WideString&& other) {
+ m_pData = other.m_pData;
+ other.m_pData = nullptr;
+ }
- CFX_WideString(const FX_WCHAR* ptr)
- : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) { }
+ CFX_WideString(const FX_WCHAR* ptr)
+ : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {}
- CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len);
+ CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len);
- CFX_WideString(FX_WCHAR ch);
+ CFX_WideString(FX_WCHAR ch);
- CFX_WideString(const CFX_WideStringC& str);
+ CFX_WideString(const CFX_WideStringC& str);
- CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
+ CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
- ~CFX_WideString();
+ ~CFX_WideString();
- static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
+ static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
- static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len);
+ static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len);
- static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len);
+ static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len);
- static FX_STRSIZE WStringLength(const unsigned short* str);
+ static FX_STRSIZE WStringLength(const unsigned short* str);
- // Explicit conversion to raw string
- const FX_WCHAR* c_str() const
- {
- return m_pData ? m_pData->m_String : L"";
- }
+ // Explicit conversion to raw string
+ const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; }
- // Implicit conversion to C-style wide string -- deprecated
- operator const FX_WCHAR*() const
- {
- return m_pData ? m_pData->m_String : L"";
- }
+ // Implicit conversion to C-style wide string -- deprecated
+ operator const FX_WCHAR*() const { return m_pData ? m_pData->m_String : L""; }
- void Empty();
+ void Empty();
+ FX_BOOL IsEmpty() const { return !GetLength(); }
- FX_BOOL IsEmpty() const
- {
- return !GetLength();
- }
+ FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
- FX_STRSIZE GetLength() const
- {
- return m_pData ? m_pData->m_nDataLength : 0;
- }
+ const CFX_WideString& operator=(const FX_WCHAR* str);
- const CFX_WideString& operator = (const FX_WCHAR* str);
+ const CFX_WideString& operator=(const CFX_WideString& stringSrc);
- const CFX_WideString& operator =(const CFX_WideString& stringSrc);
+ const CFX_WideString& operator=(const CFX_WideStringC& stringSrc);
- const CFX_WideString& operator =(const CFX_WideStringC& stringSrc);
+ const CFX_WideString& operator+=(const FX_WCHAR* str);
- const CFX_WideString& operator += (const FX_WCHAR* str);
+ const CFX_WideString& operator+=(FX_WCHAR ch);
- const CFX_WideString& operator += (FX_WCHAR ch);
+ const CFX_WideString& operator+=(const CFX_WideString& str);
- const CFX_WideString& operator += (const CFX_WideString& str);
+ const CFX_WideString& operator+=(const CFX_WideStringC& str);
- const CFX_WideString& operator += (const CFX_WideStringC& str);
+ bool operator==(const wchar_t* ptr) const { return Equal(ptr); }
+ bool operator==(const CFX_WideStringC& str) const { return Equal(str); }
+ bool operator==(const CFX_WideString& other) const { return Equal(other); }
- bool operator== (const wchar_t* ptr) const { return Equal(ptr); }
- bool operator== (const CFX_WideStringC& str) const { return Equal(str); }
- bool operator== (const CFX_WideString& other) const { return Equal(other); }
+ bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
+ bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); }
+ bool operator!=(const CFX_WideString& other) const {
+ return !(*this == other);
+ }
- bool operator!= (const wchar_t* ptr) const { return !(*this == ptr); }
- bool operator!= (const CFX_WideStringC& str) const {
- return !(*this == str);
- }
- bool operator!= (const CFX_WideString& other) const {
- return !(*this == other);
- }
+ bool operator<(const CFX_WideString& str) const {
+ int result =
+ wmemcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength()));
+ return result < 0 || (result == 0 && GetLength() < str.GetLength());
+ }
- bool operator< (const CFX_WideString& str) const {
- int result = wmemcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength()));
- return result < 0 || (result == 0 && GetLength() < str.GetLength());
- }
+ FX_WCHAR GetAt(FX_STRSIZE nIndex) const {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+ }
- FX_WCHAR GetAt(FX_STRSIZE nIndex) const
- {
- return m_pData ? m_pData->m_String[nIndex] : 0;
- }
-
- FX_WCHAR operator[](FX_STRSIZE nIndex) const
- {
- return m_pData ? m_pData->m_String[nIndex] : 0;
- }
+ FX_WCHAR operator[](FX_STRSIZE nIndex) const {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+ }
- void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
+ void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
- int Compare(const FX_WCHAR* str) const;
+ int Compare(const FX_WCHAR* str) const;
- int Compare(const CFX_WideString& str) const;
+ int Compare(const CFX_WideString& str) const;
- int CompareNoCase(const FX_WCHAR* str) const;
+ int CompareNoCase(const FX_WCHAR* str) const;
- bool Equal(const wchar_t* ptr) const;
- bool Equal(const CFX_WideStringC& str) const;
- bool Equal(const CFX_WideString& other) const;
+ bool Equal(const wchar_t* ptr) const;
+ bool Equal(const CFX_WideStringC& str) const;
+ bool Equal(const CFX_WideString& other) const;
- CFX_WideString Mid(FX_STRSIZE first) const;
+ CFX_WideString Mid(FX_STRSIZE first) const;
- CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
+ CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
- CFX_WideString Left(FX_STRSIZE count) const;
+ CFX_WideString Left(FX_STRSIZE count) const;
- CFX_WideString Right(FX_STRSIZE count) const;
+ CFX_WideString Right(FX_STRSIZE count) const;
- FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
+ FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
- FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
+ FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
- void Format(const FX_WCHAR* lpszFormat, ... );
+ void Format(const FX_WCHAR* lpszFormat, ...);
- void FormatV(const FX_WCHAR* lpszFormat, va_list argList);
+ void FormatV(const FX_WCHAR* lpszFormat, va_list argList);
- void MakeLower();
+ void MakeLower();
- void MakeUpper();
+ void MakeUpper();
- void TrimRight();
+ void TrimRight();
- void TrimRight(FX_WCHAR chTarget);
+ void TrimRight(FX_WCHAR chTarget);
- void TrimRight(const FX_WCHAR* lpszTargets);
+ void TrimRight(const FX_WCHAR* lpszTargets);
- void TrimLeft();
+ void TrimLeft();
- void TrimLeft(FX_WCHAR chTarget);
+ void TrimLeft(FX_WCHAR chTarget);
- void TrimLeft(const FX_WCHAR* lpszTargets);
+ void TrimLeft(const FX_WCHAR* lpszTargets);
- void Reserve(FX_STRSIZE len);
+ void Reserve(FX_STRSIZE len);
- FX_WCHAR* GetBuffer(FX_STRSIZE len);
+ FX_WCHAR* GetBuffer(FX_STRSIZE len);
- void ReleaseBuffer(FX_STRSIZE len = -1);
+ void ReleaseBuffer(FX_STRSIZE len = -1);
- int GetInteger() const;
+ int GetInteger() const;
- FX_FLOAT GetFloat() const;
+ FX_FLOAT GetFloat() const;
- FX_STRSIZE Find(const FX_WCHAR* lpszSub, FX_STRSIZE start = 0) const;
+ FX_STRSIZE Find(const FX_WCHAR* lpszSub, FX_STRSIZE start = 0) const;
- FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0) const;
+ FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0) const;
- FX_STRSIZE Replace(const FX_WCHAR* lpszOld, const FX_WCHAR* lpszNew);
+ FX_STRSIZE Replace(const FX_WCHAR* lpszOld, const FX_WCHAR* lpszNew);
- FX_STRSIZE Remove(FX_WCHAR ch);
+ FX_STRSIZE Remove(FX_WCHAR ch);
- CFX_ByteString UTF8Encode() const;
+ CFX_ByteString UTF8Encode() const;
- CFX_ByteString UTF16LE_Encode() const;
+ CFX_ByteString UTF16LE_Encode() const;
- void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
+ void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
-protected:
- class StringData {
- public:
- static StringData* Create(int nLen);
- void Retain() { ++m_nRefs; }
- void Release() { if (--m_nRefs <= 0) FX_Free(this); }
+ protected:
+ class StringData {
+ public:
+ static StringData* Create(int nLen);
+ void Retain() { ++m_nRefs; }
+ void Release() {
+ if (--m_nRefs <= 0)
+ FX_Free(this);
+ }
- intptr_t m_nRefs; // Would prefer ssize_t, but no windows support.
- FX_STRSIZE m_nDataLength;
- FX_STRSIZE m_nAllocLength;
- FX_WCHAR m_String[1];
+ intptr_t m_nRefs; // Would prefer ssize_t, but no windows support.
+ FX_STRSIZE m_nDataLength;
+ FX_STRSIZE m_nAllocLength;
+ FX_WCHAR m_String[1];
- private:
- StringData(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
- : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
- FXSYS_assert(dataLen >= 0);
- FXSYS_assert(allocLen >= 0);
- FXSYS_assert(dataLen <= allocLen);
- m_String[dataLen] = 0;
- }
- ~StringData() = delete;
- };
+ private:
+ StringData(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
+ : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
+ FXSYS_assert(dataLen >= 0);
+ FXSYS_assert(allocLen >= 0);
+ FXSYS_assert(dataLen <= allocLen);
+ m_String[dataLen] = 0;
+ }
+ ~StringData() = delete;
+ };
- void CopyBeforeWrite();
- void AllocBeforeWrite(FX_STRSIZE nLen);
- void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
- void ConcatCopy(FX_STRSIZE nSrc1Len, const FX_WCHAR* lpszSrc1Data, FX_STRSIZE nSrc2Len, const FX_WCHAR* lpszSrc2Data);
- void AssignCopy(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
- void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const;
+ void CopyBeforeWrite();
+ void AllocBeforeWrite(FX_STRSIZE nLen);
+ void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
+ void ConcatCopy(FX_STRSIZE nSrc1Len,
+ const FX_WCHAR* lpszSrc1Data,
+ FX_STRSIZE nSrc2Len,
+ const FX_WCHAR* lpszSrc2Data);
+ void AssignCopy(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
+ void AllocCopy(CFX_WideString& dest,
+ FX_STRSIZE nCopyLen,
+ FX_STRSIZE nCopyIndex) const;
- StringData* m_pData;
- friend class fxcrt_WideStringConcatInPlace_Test;
+ StringData* m_pData;
+ friend class fxcrt_WideStringConcatInPlace_Test;
};
-inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src)
-{
- m_Ptr = src.c_str();
- m_Length = src.GetLength();
-}
-inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src)
-{
- m_Ptr = src.c_str();
- m_Length = src.GetLength();
- return *this;
+inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src) {
+ m_Ptr = src.c_str();
+ m_Length = src.GetLength();
+}
+inline CFX_WideStringC& CFX_WideStringC::operator=(const CFX_WideString& src) {
+ m_Ptr = src.c_str();
+ m_Length = src.GetLength();
+ return *this;
}
-inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStringC& str2)
-{
- return CFX_WideString(str1, str2);
+inline CFX_WideString operator+(const CFX_WideStringC& str1,
+ const CFX_WideStringC& str2) {
+ return CFX_WideString(str1, str2);
}
-inline CFX_WideString operator + (const CFX_WideStringC& str1, const FX_WCHAR* str2)
-{
- return CFX_WideString(str1, str2);
+inline CFX_WideString operator+(const CFX_WideStringC& str1,
+ const FX_WCHAR* str2) {
+ return CFX_WideString(str1, str2);
}
-inline CFX_WideString operator + (const FX_WCHAR* str1, const CFX_WideStringC& str2)
-{
- return CFX_WideString(str1, str2);
+inline CFX_WideString operator+(const FX_WCHAR* str1,
+ const CFX_WideStringC& str2) {
+ return CFX_WideString(str1, str2);
}
-inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_WCHAR ch)
-{
- return CFX_WideString(str1, CFX_WideStringC(ch));
+inline CFX_WideString operator+(const CFX_WideStringC& str1, FX_WCHAR ch) {
+ return CFX_WideString(str1, CFX_WideStringC(ch));
}
-inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2)
-{
- return CFX_WideString(ch, str2);
+inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideStringC& str2) {
+ return CFX_WideString(ch, str2);
}
-inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideString& str2)
-{
- return CFX_WideString(str1, str2);
+inline CFX_WideString operator+(const CFX_WideString& str1,
+ const CFX_WideString& str2) {
+ return CFX_WideString(str1, str2);
}
-inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch)
-{
- return CFX_WideString(str1, CFX_WideStringC(ch));
+inline CFX_WideString operator+(const CFX_WideString& str1, FX_WCHAR ch) {
+ return CFX_WideString(str1, CFX_WideStringC(ch));
}
-inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2)
-{
- return CFX_WideString(ch, str2);
+inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideString& str2) {
+ return CFX_WideString(ch, str2);
}
-inline CFX_WideString operator + (const CFX_WideString& str1, const FX_WCHAR* str2)
-{
- return CFX_WideString(str1, str2);
+inline CFX_WideString operator+(const CFX_WideString& str1,
+ const FX_WCHAR* str2) {
+ return CFX_WideString(str1, str2);
}
-inline CFX_WideString operator + (const FX_WCHAR* str1, const CFX_WideString& str2)
-{
- return CFX_WideString(str1, str2);
+inline CFX_WideString operator+(const FX_WCHAR* str1,
+ const CFX_WideString& str2) {
+ return CFX_WideString(str1, str2);
}
-inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStringC& str2)
-{
- return CFX_WideString(str1, str2);
+inline CFX_WideString operator+(const CFX_WideString& str1,
+ const CFX_WideStringC& str2) {
+ return CFX_WideString(str1, str2);
}
-inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideString& str2)
-{
- return CFX_WideString(str1, str2);
+inline CFX_WideString operator+(const CFX_WideStringC& str1,
+ const CFX_WideString& str2) {
+ return CFX_WideString(str1, str2);
}
-inline bool operator== (const wchar_t* lhs, const CFX_WideString& rhs) {
- return rhs == lhs;
+inline bool operator==(const wchar_t* lhs, const CFX_WideString& rhs) {
+ return rhs == lhs;
}
-inline bool operator== (const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
- return rhs == lhs;
+inline bool operator==(const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
+ return rhs == lhs;
}
-inline bool operator!= (const wchar_t* lhs, const CFX_WideString& rhs) {
- return rhs != lhs;
+inline bool operator!=(const wchar_t* lhs, const CFX_WideString& rhs) {
+ return rhs != lhs;
}
-inline bool operator!= (const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
- return rhs != lhs;
+inline bool operator!=(const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
+ return rhs != lhs;
}
FX_FLOAT FX_atof(const CFX_ByteStringC& str);
void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData);
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
-CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len);
-inline CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr)
-{
- return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());
-}
-inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr)
-{
- return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength());
+CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len);
+inline CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) {
+ return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());
+}
+inline CFX_ByteString FX_UTF8Encode(const CFX_WideString& wsStr) {
+ return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength());
}
#endif // CORE_INCLUDE_FXCRT_FX_STRING_H_
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h
index 8bc2b4ab2a..f0d403501c 100644
--- a/core/include/fxcrt/fx_system.h
+++ b/core/include/fxcrt/fx_system.h
@@ -18,17 +18,17 @@
#include <wchar.h>
// _FX_OS_ values:
-#define _FX_WIN32_DESKTOP_ 1
-#define _FX_WIN64_DESKTOP_ 2
-#define _FX_LINUX_DESKTOP_ 4
-#define _FX_MACOSX_ 7
-#define _FX_ANDROID_ 12
+#define _FX_WIN32_DESKTOP_ 1
+#define _FX_WIN64_DESKTOP_ 2
+#define _FX_LINUX_DESKTOP_ 4
+#define _FX_MACOSX_ 7
+#define _FX_ANDROID_ 12
// _FXM_PLATFORM_ values;
-#define _FXM_PLATFORM_WINDOWS_ 1 // _FX_WIN32_DESKTOP_ or _FX_WIN64_DESKTOP_.
-#define _FXM_PLATFORM_LINUX_ 2 // _FX_LINUX_DESKTOP_ always.
-#define _FXM_PLATFORM_APPLE_ 3 // _FX_MACOSX_ always.
-#define _FXM_PLATFORM_ANDROID_ 4 // _FX_ANDROID_ always.
+#define _FXM_PLATFORM_WINDOWS_ 1 // _FX_WIN32_DESKTOP_ or _FX_WIN64_DESKTOP_.
+#define _FXM_PLATFORM_LINUX_ 2 // _FX_LINUX_DESKTOP_ always.
+#define _FXM_PLATFORM_APPLE_ 3 // _FX_MACOSX_ always.
+#define _FXM_PLATFORM_ANDROID_ 4 // _FX_ANDROID_ always.
#ifndef _FX_OS_
#if defined(__ANDROID__)
@@ -67,13 +67,13 @@
#ifdef __cplusplus
extern "C" {
#endif
-typedef void* FX_POSITION; // Keep until fxcrt containers gone
-typedef unsigned short FX_WORD; // Keep - "an efficient small type"
-typedef unsigned int FX_DWORD; // Keep - "an efficient type"
-typedef float FX_FLOAT; // Keep, allow upgrade to doubles.
-typedef int FX_BOOL; // Keep, sadly not always 0 or 1.
-typedef char FX_CHAR; // Keep, questionable signedness.
-typedef wchar_t FX_WCHAR; // Keep, maybe bad platform wchars.
+typedef void* FX_POSITION; // Keep until fxcrt containers gone
+typedef unsigned short FX_WORD; // Keep - "an efficient small type"
+typedef unsigned int FX_DWORD; // Keep - "an efficient type"
+typedef float FX_FLOAT; // Keep, allow upgrade to doubles.
+typedef int FX_BOOL; // Keep, sadly not always 0 or 1.
+typedef char FX_CHAR; // Keep, questionable signedness.
+typedef wchar_t FX_WCHAR; // Keep, maybe bad platform wchars.
// PDFium string sizes are limited to 2^31-1, and the value is signed to
// allow -1 as a placeholder for "unknown".
@@ -85,15 +85,15 @@ typedef int FX_STRSIZE;
#endif
#ifndef TRUE
-#define TRUE 1
+#define TRUE 1
#endif
#ifndef FALSE
-#define FALSE 0
+#define FALSE 0
#endif
#ifndef NULL
-#define NULL 0
+#define NULL 0
#endif
#define FXSYS_assert assert
@@ -107,38 +107,41 @@ typedef int FX_STRSIZE;
#define FX_MAX(a, b) (((a) > (b)) ? (a) : (b))
#define FX_MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define FX_PI 3.1415926535897932384626433832795f
+#define FX_PI 3.1415926535897932384626433832795f
// NOTE: prevent use of the return value from snprintf() since some platforms
// have different return values (e.g. windows _vsnprintf()), and provide
// versions that always NUL-terminate.
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900
-void FXSYS_snprintf(char *str, size_t size, _Printf_format_string_ const char* fmt, ...);
-void FXSYS_vsnprintf(char *str, size_t size, const char* fmt, va_list ap);
+void FXSYS_snprintf(char* str,
+ size_t size,
+ _Printf_format_string_ const char* fmt,
+ ...);
+void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap);
#else
-#define FXSYS_snprintf (void) snprintf
-#define FXSYS_vsnprintf (void) vsnprintf
+#define FXSYS_snprintf (void) snprintf
+#define FXSYS_vsnprintf (void) vsnprintf
#endif
-#define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE
-#define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE
-#define FXSYS_strchr strchr
-#define FXSYS_strncmp strncmp
-#define FXSYS_strcmp strcmp
-#define FXSYS_strcpy strcpy
-#define FXSYS_strncpy strncpy
-#define FXSYS_strstr strstr
-#define FXSYS_FILE FILE
-#define FXSYS_fopen fopen
-#define FXSYS_fclose fclose
-#define FXSYS_SEEK_END SEEK_END
-#define FXSYS_SEEK_SET SEEK_SET
-#define FXSYS_fseek fseek
-#define FXSYS_ftell ftell
-#define FXSYS_fread fread
-#define FXSYS_fwrite fwrite
-#define FXSYS_fprintf fprintf
-#define FXSYS_fflush fflush
+#define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE
+#define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE
+#define FXSYS_strchr strchr
+#define FXSYS_strncmp strncmp
+#define FXSYS_strcmp strcmp
+#define FXSYS_strcpy strcpy
+#define FXSYS_strncpy strncpy
+#define FXSYS_strstr strstr
+#define FXSYS_FILE FILE
+#define FXSYS_fopen fopen
+#define FXSYS_fclose fclose
+#define FXSYS_SEEK_END SEEK_END
+#define FXSYS_SEEK_SET SEEK_SET
+#define FXSYS_fseek fseek
+#define FXSYS_ftell ftell
+#define FXSYS_fread fread
+#define FXSYS_fwrite fwrite
+#define FXSYS_fprintf fprintf
+#define FXSYS_fflush fflush
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#ifdef _NATIVE_WCHAR_T_DEFINED
@@ -151,7 +154,7 @@ FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode);
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#ifdef __cplusplus
-} // extern "C"
+} // extern "C"
#include "../../../third_party/base/numerics/safe_conversions.h"
#define FXSYS_strlen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(strlen(ptr))
#define FXSYS_wcslen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(wcslen(ptr))
@@ -161,20 +164,20 @@ extern "C" {
#define FXSYS_wcslen(ptr) ((FX_STRSIZE)wcslen(ptr))
#endif
-#define FXSYS_wcscmp wcscmp
-#define FXSYS_wcschr wcschr
-#define FXSYS_wcsstr wcsstr
-#define FXSYS_wcsncmp wcsncmp
-#define FXSYS_vswprintf vswprintf
-#define FXSYS_mbstowcs mbstowcs
-#define FXSYS_wcstombs wcstombs
-#define FXSYS_memcmp memcmp
-#define FXSYS_memcpy memcpy
-#define FXSYS_memmove memmove
-#define FXSYS_memset memset
-#define FXSYS_memchr memchr
-#define FXSYS_qsort qsort
-#define FXSYS_bsearch bsearch
+#define FXSYS_wcscmp wcscmp
+#define FXSYS_wcschr wcschr
+#define FXSYS_wcsstr wcsstr
+#define FXSYS_wcsncmp wcsncmp
+#define FXSYS_vswprintf vswprintf
+#define FXSYS_mbstowcs mbstowcs
+#define FXSYS_wcstombs wcstombs
+#define FXSYS_memcmp memcmp
+#define FXSYS_memcpy memcpy
+#define FXSYS_memmove memmove
+#define FXSYS_memset memset
+#define FXSYS_memchr memchr
+#define FXSYS_qsort qsort
+#define FXSYS_bsearch bsearch
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#define FXSYS_GetACP GetACP
@@ -184,8 +187,10 @@ extern "C" {
#define FXSYS_stricmp _stricmp
#ifdef _NATIVE_WCHAR_T_DEFINED
#define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2))
-#define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8)
-#define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6)
+#define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) \
+ WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8)
+#define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) \
+ MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6)
#define FXSYS_wcslwr(str) _wcslwr((wchar_t*)(str))
#define FXSYS_wcsupr(str) _wcsupr((wchar_t*)(str))
#else
@@ -198,58 +203,77 @@ extern "C" {
#define FXSYS_GetFullPathName GetFullPathName
#define FXSYS_GetModuleFileName GetModuleFileName
#else
-int FXSYS_GetACP(void);
-char* FXSYS_itoa(int value, char* string, int radix);
-int FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dwFlags, const wchar_t* wstr, int wlen,
- char* buf, int buflen, const char* default_str, int* pUseDefault);
-int FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dwFlags, const char* bstr, int blen,
- wchar_t* buf, int buflen);
-FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart);
-FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
-char* FXSYS_strlwr(char* str);
-char* FXSYS_strupr(char* str);
-int FXSYS_stricmp(const char*, const char*);
-int FXSYS_wcsicmp(const wchar_t *string1, const wchar_t *string2);
-wchar_t* FXSYS_wcslwr(wchar_t* str);
-wchar_t* FXSYS_wcsupr(wchar_t* str);
+int FXSYS_GetACP(void);
+char* FXSYS_itoa(int value, char* string, int radix);
+int FXSYS_WideCharToMultiByte(FX_DWORD codepage,
+ FX_DWORD dwFlags,
+ const wchar_t* wstr,
+ int wlen,
+ char* buf,
+ int buflen,
+ const char* default_str,
+ int* pUseDefault);
+int FXSYS_MultiByteToWideChar(FX_DWORD codepage,
+ FX_DWORD dwFlags,
+ const char* bstr,
+ int blen,
+ wchar_t* buf,
+ int buflen);
+FX_DWORD FXSYS_GetFullPathName(const char* filename,
+ FX_DWORD buflen,
+ char* buf,
+ char** filepart);
+FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
+char* FXSYS_strlwr(char* str);
+char* FXSYS_strupr(char* str);
+int FXSYS_stricmp(const char*, const char*);
+int FXSYS_wcsicmp(const wchar_t* string1, const wchar_t* string2);
+wchar_t* FXSYS_wcslwr(wchar_t* str);
+wchar_t* FXSYS_wcsupr(wchar_t* str);
#endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#define FXSYS_pow(a, b) (FX_FLOAT)powf(a, b)
+#define FXSYS_pow(a, b) (FX_FLOAT) powf(a, b)
#else
-#define FXSYS_pow(a, b) (FX_FLOAT)pow(a, b)
+#define FXSYS_pow(a, b) (FX_FLOAT) pow(a, b)
#endif
-#define FXSYS_sqrt(a) (FX_FLOAT)sqrt(a)
-#define FXSYS_fabs(a) (FX_FLOAT)fabs(a)
-#define FXSYS_atan2(a, b) (FX_FLOAT)atan2(a, b)
-#define FXSYS_ceil(a) (FX_FLOAT)ceil(a)
-#define FXSYS_floor(a) (FX_FLOAT)floor(a)
-#define FXSYS_cos(a) (FX_FLOAT)cos(a)
-#define FXSYS_acos(a) (FX_FLOAT)acos(a)
-#define FXSYS_sin(a) (FX_FLOAT)sin(a)
-#define FXSYS_log(a) (FX_FLOAT)log(a)
-#define FXSYS_log10(a) (FX_FLOAT)log10(a)
-#define FXSYS_fmod(a, b) (FX_FLOAT)fmod(a, b)
-#define FXSYS_abs abs
-#define FXDWORD_FROM_LSBFIRST(i) (i)
-#define FXDWORD_FROM_MSBFIRST(i) (((uint8_t)(i) << 24) | ((uint8_t)((i) >> 8) << 16) | ((uint8_t)((i) >> 16) << 8) | (uint8_t)((i) >> 24))
-#define FXDWORD_GET_LSBFIRST(p) ((((uint8_t*)(p))[3] << 24) | (((uint8_t*)(p))[2] << 16) | (((uint8_t*)(p))[1] << 8) | (((uint8_t*)(p))[0]))
-#define FXDWORD_GET_MSBFIRST(p) ((((uint8_t*)(p))[0] << 24) | (((uint8_t*)(p))[1] << 16) | (((uint8_t*)(p))[2] << 8) | (((uint8_t*)(p))[3]))
-#define FXSYS_HIBYTE(word) ((uint8_t)((word) >> 8))
-#define FXSYS_LOBYTE(word) ((uint8_t)(word))
-#define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16))
-#define FXSYS_LOWORD(dword) ((FX_WORD)(dword))
-int32_t FXSYS_atoi(const FX_CHAR* str);
-int32_t FXSYS_wtoi(const FX_WCHAR* str);
-int64_t FXSYS_atoi64(const FX_CHAR* str);
-int64_t FXSYS_wtoi64(const FX_WCHAR* str);
-const FX_CHAR* FXSYS_i64toa(int64_t value, FX_CHAR* str, int radix);
-const FX_WCHAR* FXSYS_i64tow(int64_t value, FX_WCHAR* str, int radix);
-int FXSYS_round(FX_FLOAT f);
-#define FXSYS_Mul(a, b) ((a) * (b))
-#define FXSYS_Div(a, b) ((a) / (b))
-#define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c))
-#define FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b))
+#define FXSYS_sqrt(a) (FX_FLOAT) sqrt(a)
+#define FXSYS_fabs(a) (FX_FLOAT) fabs(a)
+#define FXSYS_atan2(a, b) (FX_FLOAT) atan2(a, b)
+#define FXSYS_ceil(a) (FX_FLOAT) ceil(a)
+#define FXSYS_floor(a) (FX_FLOAT) floor(a)
+#define FXSYS_cos(a) (FX_FLOAT) cos(a)
+#define FXSYS_acos(a) (FX_FLOAT) acos(a)
+#define FXSYS_sin(a) (FX_FLOAT) sin(a)
+#define FXSYS_log(a) (FX_FLOAT) log(a)
+#define FXSYS_log10(a) (FX_FLOAT) log10(a)
+#define FXSYS_fmod(a, b) (FX_FLOAT) fmod(a, b)
+#define FXSYS_abs abs
+#define FXDWORD_FROM_LSBFIRST(i) (i)
+#define FXDWORD_FROM_MSBFIRST(i) \
+ (((uint8_t)(i) << 24) | ((uint8_t)((i) >> 8) << 16) | \
+ ((uint8_t)((i) >> 16) << 8) | (uint8_t)((i) >> 24))
+#define FXDWORD_GET_LSBFIRST(p) \
+ ((((uint8_t*)(p))[3] << 24) | (((uint8_t*)(p))[2] << 16) | \
+ (((uint8_t*)(p))[1] << 8) | (((uint8_t*)(p))[0]))
+#define FXDWORD_GET_MSBFIRST(p) \
+ ((((uint8_t*)(p))[0] << 24) | (((uint8_t*)(p))[1] << 16) | \
+ (((uint8_t*)(p))[2] << 8) | (((uint8_t*)(p))[3]))
+#define FXSYS_HIBYTE(word) ((uint8_t)((word) >> 8))
+#define FXSYS_LOBYTE(word) ((uint8_t)(word))
+#define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16))
+#define FXSYS_LOWORD(dword) ((FX_WORD)(dword))
+int32_t FXSYS_atoi(const FX_CHAR* str);
+int32_t FXSYS_wtoi(const FX_WCHAR* str);
+int64_t FXSYS_atoi64(const FX_CHAR* str);
+int64_t FXSYS_wtoi64(const FX_WCHAR* str);
+const FX_CHAR* FXSYS_i64toa(int64_t value, FX_CHAR* str, int radix);
+const FX_WCHAR* FXSYS_i64tow(int64_t value, FX_WCHAR* str, int radix);
+int FXSYS_round(FX_FLOAT f);
+#define FXSYS_Mul(a, b) ((a) * (b))
+#define FXSYS_Div(a, b) ((a) / (b))
+#define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c))
+#define FXSYS_sqrt2(a, b) (FX_FLOAT) FXSYS_sqrt((a) * (a) + (b) * (b))
#ifdef __cplusplus
};
#endif
@@ -286,7 +310,7 @@ int FXSYS_round(FX_FLOAT f);
// Prevent a function from ever being inlined, typically because we'd
// like it to appear in stack traces.
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#define NEVER_INLINE __declspec(noinline)
#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#define NEVER_INLINE __attribute__((__noinline__))
diff --git a/core/include/fxcrt/fx_ucd.h b/core/include/fxcrt/fx_ucd.h
index 84f6169d7e..fb417189a1 100644
--- a/core/include/fxcrt/fx_ucd.h
+++ b/core/include/fxcrt/fx_ucd.h
@@ -10,192 +10,184 @@
#include "fx_basic.h"
enum FX_CHARBREAKPROP {
- FX_CBP_OP = 0,
- FX_CBP_CL = 1,
- FX_CBP_QU = 2,
- FX_CBP_GL = 3,
- FX_CBP_NS = 4,
- FX_CBP_EX = 5,
- FX_CBP_SY = 6,
- FX_CBP_IS = 7,
- FX_CBP_PR = 8,
- FX_CBP_PO = 9,
- FX_CBP_NU = 10,
- FX_CBP_AL = 11,
- FX_CBP_ID = 12,
- FX_CBP_IN = 13,
- FX_CBP_HY = 14,
- FX_CBP_BA = 15,
- FX_CBP_BB = 16,
- FX_CBP_B2 = 17,
- FX_CBP_ZW = 18,
- FX_CBP_CM = 19,
- FX_CBP_WJ = 20,
- FX_CBP_H2 = 21,
- FX_CBP_H3 = 22,
- FX_CBP_JL = 23,
- FX_CBP_JV = 24,
- FX_CBP_JT = 25,
+ FX_CBP_OP = 0,
+ FX_CBP_CL = 1,
+ FX_CBP_QU = 2,
+ FX_CBP_GL = 3,
+ FX_CBP_NS = 4,
+ FX_CBP_EX = 5,
+ FX_CBP_SY = 6,
+ FX_CBP_IS = 7,
+ FX_CBP_PR = 8,
+ FX_CBP_PO = 9,
+ FX_CBP_NU = 10,
+ FX_CBP_AL = 11,
+ FX_CBP_ID = 12,
+ FX_CBP_IN = 13,
+ FX_CBP_HY = 14,
+ FX_CBP_BA = 15,
+ FX_CBP_BB = 16,
+ FX_CBP_B2 = 17,
+ FX_CBP_ZW = 18,
+ FX_CBP_CM = 19,
+ FX_CBP_WJ = 20,
+ FX_CBP_H2 = 21,
+ FX_CBP_H3 = 22,
+ FX_CBP_JL = 23,
+ FX_CBP_JV = 24,
+ FX_CBP_JT = 25,
- FX_CBP_BK = 26,
- FX_CBP_CR = 27,
- FX_CBP_LF = 28,
- FX_CBP_NL = 29,
- FX_CBP_SA = 30,
- FX_CBP_SG = 31,
- FX_CBP_CB = 32,
- FX_CBP_XX = 33,
- FX_CBP_AI = 34,
- FX_CBP_SP = 35,
- FX_CBP_TB = 37,
- FX_CBP_NONE = 36,
+ FX_CBP_BK = 26,
+ FX_CBP_CR = 27,
+ FX_CBP_LF = 28,
+ FX_CBP_NL = 29,
+ FX_CBP_SA = 30,
+ FX_CBP_SG = 31,
+ FX_CBP_CB = 32,
+ FX_CBP_XX = 33,
+ FX_CBP_AI = 34,
+ FX_CBP_SP = 35,
+ FX_CBP_TB = 37,
+ FX_CBP_NONE = 36,
};
-#define FX_BIDICLASSBITS 6
-#define FX_BIDICLASSBITSMASK (31 << FX_BIDICLASSBITS)
+#define FX_BIDICLASSBITS 6
+#define FX_BIDICLASSBITSMASK (31 << FX_BIDICLASSBITS)
enum FX_BIDICLASS {
- FX_BIDICLASS_ON = 0,
- FX_BIDICLASS_L = 1,
- FX_BIDICLASS_R = 2,
- FX_BIDICLASS_AN = 3,
- FX_BIDICLASS_EN = 4,
- FX_BIDICLASS_AL = 5,
- FX_BIDICLASS_NSM = 6,
- FX_BIDICLASS_CS = 7,
- FX_BIDICLASS_ES = 8,
- FX_BIDICLASS_ET = 9,
- FX_BIDICLASS_BN = 10,
- FX_BIDICLASS_S = 11,
- FX_BIDICLASS_WS = 12,
- FX_BIDICLASS_B = 13,
- FX_BIDICLASS_RLO = 14,
- FX_BIDICLASS_RLE = 15,
- FX_BIDICLASS_LRO = 16,
- FX_BIDICLASS_LRE = 17,
- FX_BIDICLASS_PDF = 18,
- FX_BIDICLASS_N = FX_BIDICLASS_ON,
+ FX_BIDICLASS_ON = 0,
+ FX_BIDICLASS_L = 1,
+ FX_BIDICLASS_R = 2,
+ FX_BIDICLASS_AN = 3,
+ FX_BIDICLASS_EN = 4,
+ FX_BIDICLASS_AL = 5,
+ FX_BIDICLASS_NSM = 6,
+ FX_BIDICLASS_CS = 7,
+ FX_BIDICLASS_ES = 8,
+ FX_BIDICLASS_ET = 9,
+ FX_BIDICLASS_BN = 10,
+ FX_BIDICLASS_S = 11,
+ FX_BIDICLASS_WS = 12,
+ FX_BIDICLASS_B = 13,
+ FX_BIDICLASS_RLO = 14,
+ FX_BIDICLASS_RLE = 15,
+ FX_BIDICLASS_LRO = 16,
+ FX_BIDICLASS_LRE = 17,
+ FX_BIDICLASS_PDF = 18,
+ FX_BIDICLASS_N = FX_BIDICLASS_ON,
};
-#define FX_CHARTYPEBITS 11
-#define FX_CHARTYPEBITSMASK (15 << FX_CHARTYPEBITS)
+#define FX_CHARTYPEBITS 11
+#define FX_CHARTYPEBITSMASK (15 << FX_CHARTYPEBITS)
enum FX_CHARTYPE {
- FX_CHARTYPE_Unknown = 0,
- FX_CHARTYPE_Tab = (1 << FX_CHARTYPEBITS),
- FX_CHARTYPE_Space = (2 << FX_CHARTYPEBITS),
- FX_CHARTYPE_Control = (3 << FX_CHARTYPEBITS),
- FX_CHARTYPE_Combination = (4 << FX_CHARTYPEBITS),
- FX_CHARTYPE_Numeric = (5 << FX_CHARTYPEBITS),
- FX_CHARTYPE_Normal = (6 << FX_CHARTYPEBITS),
- FX_CHARTYPE_ArabicAlef = (7 << FX_CHARTYPEBITS),
- FX_CHARTYPE_ArabicSpecial = (8 << FX_CHARTYPEBITS),
- FX_CHARTYPE_ArabicDistortion = (9 << FX_CHARTYPEBITS),
- FX_CHARTYPE_ArabicNormal = (10 << FX_CHARTYPEBITS),
- FX_CHARTYPE_ArabicForm = (11 << FX_CHARTYPEBITS),
- FX_CHARTYPE_Arabic = (12 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_Unknown = 0,
+ FX_CHARTYPE_Tab = (1 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_Space = (2 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_Control = (3 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_Combination = (4 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_Numeric = (5 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_Normal = (6 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_ArabicAlef = (7 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_ArabicSpecial = (8 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_ArabicDistortion = (9 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_ArabicNormal = (10 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_ArabicForm = (11 << FX_CHARTYPEBITS),
+ FX_CHARTYPE_Arabic = (12 << FX_CHARTYPEBITS),
};
-typedef struct _FX_CHARPROPERTIES {
- union FX_CHARPROPERTIES_UNION{
- struct FX_CHARPROPERTIES_BIT{
- FX_DWORD dwBreakType : 6;
- FX_DWORD dwBidiClass : 5;
- FX_DWORD dwCharType : 4;
- FX_DWORD dwRotation : 1;
- FX_DWORD dwCJKSpecial : 1;
- FX_DWORD dwVertIndex : 6;
- FX_DWORD dwBidiIndex : 9;
- };
- FX_DWORD dwCharProps;
- };
-} FX_CHARPROPERTIES;
+typedef struct _FX_CHARPROPERTIES {
+ union FX_CHARPROPERTIES_UNION {
+ struct FX_CHARPROPERTIES_BIT {
+ FX_DWORD dwBreakType : 6;
+ FX_DWORD dwBidiClass : 5;
+ FX_DWORD dwCharType : 4;
+ FX_DWORD dwRotation : 1;
+ FX_DWORD dwCJKSpecial : 1;
+ FX_DWORD dwVertIndex : 6;
+ FX_DWORD dwBidiIndex : 9;
+ };
+ FX_DWORD dwCharProps;
+ };
+} FX_CHARPROPERTIES;
FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch);
-FX_BOOL FX_IsCtrlCode(FX_WCHAR ch);
-FX_BOOL FX_IsRotationCode(FX_WCHAR ch);
+FX_BOOL FX_IsCtrlCode(FX_WCHAR ch);
+FX_BOOL FX_IsRotationCode(FX_WCHAR ch);
FX_BOOL FX_IsCombinationChar(FX_WCHAR wch);
-FX_BOOL FX_IsBidiChar(FX_WCHAR wch);
+FX_BOOL FX_IsBidiChar(FX_WCHAR wch);
FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical);
-FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_DWORD dwProps, FX_BOOL bRTL, FX_BOOL bVertical);
-class CFX_Char
-{
-public:
- CFX_Char() : m_wCharCode(0)
- , m_nBreakType(0)
- , m_nRotation(0)
- , m_dwCharProps(0)
- , m_dwCharStyles(0)
- , m_iCharWidth(0)
- , m_iHorizontalScale(100)
- , m_iVertialScale(100)
- {
- }
- CFX_Char(FX_WORD wCharCode, FX_DWORD dwCharProps)
- : m_wCharCode(wCharCode)
- , m_nBreakType(0)
- , m_nRotation(0)
- , m_dwCharProps(dwCharProps)
- , m_dwCharStyles(0)
- , m_iCharWidth(0)
- , m_iHorizontalScale(100)
- , m_iVertialScale(100)
- {
- }
- FX_DWORD GetCharType() const
- {
- return m_dwCharProps & FX_CHARTYPEBITSMASK;
- }
- FX_WORD m_wCharCode;
- uint8_t m_nBreakType;
- int8_t m_nRotation;
- FX_DWORD m_dwCharProps;
- FX_DWORD m_dwCharStyles;
- int32_t m_iCharWidth;
- int32_t m_iHorizontalScale;
- int32_t m_iVertialScale;
-};
-typedef CFX_ArrayTemplate<CFX_Char> CFX_CharArray;
-class CFX_TxtChar : public CFX_Char
-{
-public:
- CFX_TxtChar() : CFX_Char()
- , m_dwStatus(0)
- , m_iBidiClass(0)
- , m_iBidiLevel(0)
- , m_iBidiPos(0)
- , m_iBidiOrder(0)
- , m_pUserData(NULL)
- {
- }
- FX_DWORD m_dwStatus;
- int16_t m_iBidiClass;
- int16_t m_iBidiLevel;
- int16_t m_iBidiPos;
- int16_t m_iBidiOrder;
- void* m_pUserData;
-};
-typedef CFX_ArrayTemplate<CFX_TxtChar> CFX_TxtCharArray;
-class CFX_RTFChar : public CFX_Char
-{
-public:
- CFX_RTFChar() : CFX_Char()
- , m_dwStatus(0)
- , m_iFontSize(0)
- , m_iFontHeight(0)
- , m_iBidiClass(0)
- , m_iBidiLevel(0)
- , m_iBidiPos(0)
- , m_dwLayoutStyles(0)
- , m_dwIdentity(0)
- , m_pUserData(NULL)
- {
- }
- FX_DWORD m_dwStatus;
- int32_t m_iFontSize;
- int32_t m_iFontHeight;
- int16_t m_iBidiClass;
- int16_t m_iBidiLevel;
- int16_t m_iBidiPos;
- int16_t m_iBidiOrder;
- FX_DWORD m_dwLayoutStyles;
- FX_DWORD m_dwIdentity;
- IFX_Unknown *m_pUserData;
-};
-typedef CFX_ArrayTemplate<CFX_RTFChar> CFX_RTFCharArray;
+FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch,
+ FX_DWORD dwProps,
+ FX_BOOL bRTL,
+ FX_BOOL bVertical);
+class CFX_Char {
+ public:
+ CFX_Char()
+ : m_wCharCode(0),
+ m_nBreakType(0),
+ m_nRotation(0),
+ m_dwCharProps(0),
+ m_dwCharStyles(0),
+ m_iCharWidth(0),
+ m_iHorizontalScale(100),
+ m_iVertialScale(100) {}
+ CFX_Char(FX_WORD wCharCode, FX_DWORD dwCharProps)
+ : m_wCharCode(wCharCode),
+ m_nBreakType(0),
+ m_nRotation(0),
+ m_dwCharProps(dwCharProps),
+ m_dwCharStyles(0),
+ m_iCharWidth(0),
+ m_iHorizontalScale(100),
+ m_iVertialScale(100) {}
+ FX_DWORD GetCharType() const { return m_dwCharProps & FX_CHARTYPEBITSMASK; }
+ FX_WORD m_wCharCode;
+ uint8_t m_nBreakType;
+ int8_t m_nRotation;
+ FX_DWORD m_dwCharProps;
+ FX_DWORD m_dwCharStyles;
+ int32_t m_iCharWidth;
+ int32_t m_iHorizontalScale;
+ int32_t m_iVertialScale;
+};
+typedef CFX_ArrayTemplate<CFX_Char> CFX_CharArray;
+class CFX_TxtChar : public CFX_Char {
+ public:
+ CFX_TxtChar()
+ : CFX_Char(),
+ m_dwStatus(0),
+ m_iBidiClass(0),
+ m_iBidiLevel(0),
+ m_iBidiPos(0),
+ m_iBidiOrder(0),
+ m_pUserData(NULL) {}
+ FX_DWORD m_dwStatus;
+ int16_t m_iBidiClass;
+ int16_t m_iBidiLevel;
+ int16_t m_iBidiPos;
+ int16_t m_iBidiOrder;
+ void* m_pUserData;
+};
+typedef CFX_ArrayTemplate<CFX_TxtChar> CFX_TxtCharArray;
+class CFX_RTFChar : public CFX_Char {
+ public:
+ CFX_RTFChar()
+ : CFX_Char(),
+ m_dwStatus(0),
+ m_iFontSize(0),
+ m_iFontHeight(0),
+ m_iBidiClass(0),
+ m_iBidiLevel(0),
+ m_iBidiPos(0),
+ m_dwLayoutStyles(0),
+ m_dwIdentity(0),
+ m_pUserData(NULL) {}
+ FX_DWORD m_dwStatus;
+ int32_t m_iFontSize;
+ int32_t m_iFontHeight;
+ int16_t m_iBidiClass;
+ int16_t m_iBidiLevel;
+ int16_t m_iBidiPos;
+ int16_t m_iBidiOrder;
+ FX_DWORD m_dwLayoutStyles;
+ FX_DWORD m_dwIdentity;
+ IFX_Unknown* m_pUserData;
+};
+typedef CFX_ArrayTemplate<CFX_RTFChar> CFX_RTFCharArray;
#endif // CORE_INCLUDE_FXCRT_FX_UCD_H_
diff --git a/core/include/fxcrt/fx_xml.h b/core/include/fxcrt/fx_xml.h
index ba33b2083a..eaf872c164 100644
--- a/core/include/fxcrt/fx_xml.h
+++ b/core/include/fxcrt/fx_xml.h
@@ -9,172 +9,168 @@
#include "fx_basic.h"
-class CXML_AttrItem
-{
-public:
- CFX_ByteString m_QSpaceName;
- CFX_ByteString m_AttrName;
- CFX_WideString m_Value;
+class CXML_AttrItem {
+ public:
+ CFX_ByteString m_QSpaceName;
+ CFX_ByteString m_AttrName;
+ CFX_WideString m_Value;
};
-class CXML_AttrMap
-{
-public:
- CXML_AttrMap()
- {
- m_pMap = NULL;
- }
- ~CXML_AttrMap()
- {
- RemoveAll();
- }
- const CFX_WideString* Lookup(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const;
- void SetAt(const CFX_ByteStringC& space, const CFX_ByteStringC& name, const CFX_WideStringC& value);
- void RemoveAt(const CFX_ByteStringC& space, const CFX_ByteStringC& name);
- void RemoveAll();
- int GetSize() const;
- CXML_AttrItem& GetAt(int index) const;
- CFX_ObjectArray<CXML_AttrItem>* m_pMap;
+class CXML_AttrMap {
+ public:
+ CXML_AttrMap() { m_pMap = NULL; }
+ ~CXML_AttrMap() { RemoveAll(); }
+ const CFX_WideString* Lookup(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& name) const;
+ void SetAt(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& name,
+ const CFX_WideStringC& value);
+ void RemoveAt(const CFX_ByteStringC& space, const CFX_ByteStringC& name);
+ void RemoveAll();
+ int GetSize() const;
+ CXML_AttrItem& GetAt(int index) const;
+ CFX_ObjectArray<CXML_AttrItem>* m_pMap;
};
-class CXML_Content
-{
-public:
- CXML_Content() : m_bCDATA(FALSE), m_Content() {}
- void Set(FX_BOOL bCDATA, const CFX_WideStringC& content)
- {
- m_bCDATA = bCDATA;
- m_Content = content;
- }
- FX_BOOL m_bCDATA;
- CFX_WideString m_Content;
+class CXML_Content {
+ public:
+ CXML_Content() : m_bCDATA(FALSE), m_Content() {}
+ void Set(FX_BOOL bCDATA, const CFX_WideStringC& content) {
+ m_bCDATA = bCDATA;
+ m_Content = content;
+ }
+ FX_BOOL m_bCDATA;
+ CFX_WideString m_Content;
};
-class CXML_Element
-{
-public:
- static CXML_Element* Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
- static CXML_Element* Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
- static CXML_Element* Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
- CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName);
- CXML_Element(const CFX_ByteStringC& qTagName);
- CXML_Element();
+class CXML_Element {
+ public:
+ static CXML_Element* Parse(const void* pBuffer,
+ size_t size,
+ FX_BOOL bSaveSpaceChars = FALSE,
+ FX_FILESIZE* pParsedSize = NULL);
+ static CXML_Element* Parse(IFX_FileRead* pFile,
+ FX_BOOL bSaveSpaceChars = FALSE,
+ FX_FILESIZE* pParsedSize = NULL);
+ static CXML_Element* Parse(IFX_BufferRead* pBuffer,
+ FX_BOOL bSaveSpaceChars = FALSE,
+ FX_FILESIZE* pParsedSize = NULL);
+ CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName);
+ CXML_Element(const CFX_ByteStringC& qTagName);
+ CXML_Element();
+
+ ~CXML_Element();
+
+ void Empty();
+
+ CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const;
+
+ CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const;
+
+ CFX_ByteString GetNamespaceURI(const CFX_ByteStringC& qName) const;
+
+ CXML_Element* GetParent() const { return m_pParent; }
+
+ FX_DWORD CountAttrs() const { return m_AttrMap.GetSize(); }
+
+ void GetAttrByIndex(int index,
+ CFX_ByteString& space,
+ CFX_ByteString& name,
+ CFX_WideString& value) const;
+
+ FX_BOOL HasAttr(const CFX_ByteStringC& qName) const;
+
+ FX_BOOL GetAttrValue(const CFX_ByteStringC& name,
+ CFX_WideString& attribute) const;
+ CFX_WideString GetAttrValue(const CFX_ByteStringC& name) const {
+ CFX_WideString attr;
+ GetAttrValue(name, attr);
+ return attr;
+ }
+
+ FX_BOOL GetAttrValue(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& name,
+ CFX_WideString& attribute) const;
+ CFX_WideString GetAttrValue(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& name) const {
+ CFX_WideString attr;
+ GetAttrValue(space, name, attr);
+ return attr;
+ }
+
+ FX_BOOL GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const;
+ int GetAttrInteger(const CFX_ByteStringC& name) const {
+ int attr = 0;
+ GetAttrInteger(name, attr);
+ return attr;
+ }
+
+ FX_BOOL GetAttrInteger(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& name,
+ int& attribute) const;
+ int GetAttrInteger(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& name) const {
+ int attr = 0;
+ GetAttrInteger(space, name, attr);
+ return attr;
+ }
+
+ FX_BOOL GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const;
+ FX_FLOAT GetAttrFloat(const CFX_ByteStringC& name) const {
+ FX_FLOAT attr = 0;
+ GetAttrFloat(name, attr);
+ return attr;
+ }
+
+ FX_BOOL GetAttrFloat(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& name,
+ FX_FLOAT& attribute) const;
+ FX_FLOAT GetAttrFloat(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& name) const {
+ FX_FLOAT attr = 0;
+ GetAttrFloat(space, name, attr);
+ return attr;
+ }
+
+ FX_DWORD CountChildren() const;
+
+ enum ChildType { Invalid, Element, Content };
+
+ ChildType GetChildType(FX_DWORD index) const;
+
+ CFX_WideString GetContent(FX_DWORD index) const;
+
+ CXML_Element* GetElement(FX_DWORD index) const;
+
+ CXML_Element* GetElement(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& tag) const {
+ return GetElement(space, tag, 0);
+ }
+
+ FX_DWORD CountElements(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& tag) const;
- ~CXML_Element();
+ CXML_Element* GetElement(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& tag,
+ int index) const;
- void Empty();
+ FX_DWORD FindElement(CXML_Element* pChild) const;
+ void SetTag(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagname);
+ void SetTag(const CFX_ByteStringC& qTagName);
- CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const;
+ void RemoveChildren();
- CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const;
+ void RemoveChild(FX_DWORD index);
- CFX_ByteString GetNamespaceURI(const CFX_ByteStringC& qName) const;
+ protected:
+ CXML_Element* m_pParent;
+ CFX_ByteString m_QSpaceName;
+ CFX_ByteString m_TagName;
- CXML_Element* GetParent() const
- {
- return m_pParent;
- }
-
- FX_DWORD CountAttrs() const
- {
- return m_AttrMap.GetSize();
- }
-
- void GetAttrByIndex(int index, CFX_ByteString &space, CFX_ByteString &name, CFX_WideString &value) const;
-
- FX_BOOL HasAttr(const CFX_ByteStringC& qName) const;
-
- FX_BOOL GetAttrValue(const CFX_ByteStringC& name, CFX_WideString& attribute) const;
- CFX_WideString GetAttrValue(const CFX_ByteStringC& name) const
- {
- CFX_WideString attr;
- GetAttrValue(name, attr);
- return attr;
- }
-
- FX_BOOL GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name, CFX_WideString& attribute) const;
- CFX_WideString GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const
- {
- CFX_WideString attr;
- GetAttrValue(space, name, attr);
- return attr;
- }
-
- FX_BOOL GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const;
- int GetAttrInteger(const CFX_ByteStringC& name) const
- {
- int attr = 0;
- GetAttrInteger(name, attr);
- return attr;
- }
-
- FX_BOOL GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name, int& attribute) const;
- int GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const
- {
- int attr = 0;
- GetAttrInteger(space, name, attr);
- return attr;
- }
-
- FX_BOOL GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const;
- FX_FLOAT GetAttrFloat(const CFX_ByteStringC& name) const
- {
- FX_FLOAT attr = 0;
- GetAttrFloat(name, attr);
- return attr;
- }
-
- FX_BOOL GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name, FX_FLOAT& attribute) const;
- FX_FLOAT GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const
- {
- FX_FLOAT attr = 0;
- GetAttrFloat(space, name, attr);
- return attr;
- }
-
- FX_DWORD CountChildren() const;
-
- enum ChildType { Invalid, Element, Content};
-
- ChildType GetChildType(FX_DWORD index) const;
-
- CFX_WideString GetContent(FX_DWORD index) const;
-
- CXML_Element* GetElement(FX_DWORD index) const;
-
- CXML_Element* GetElement(const CFX_ByteStringC& space, const CFX_ByteStringC& tag) const
- {
- return GetElement(space, tag, 0);
- }
-
- FX_DWORD CountElements(const CFX_ByteStringC& space, const CFX_ByteStringC& tag) const;
-
- CXML_Element* GetElement(const CFX_ByteStringC& space, const CFX_ByteStringC& tag, int index) const;
-
- FX_DWORD FindElement(CXML_Element *pChild) const;
-
-
-
-
- void SetTag(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagname);
-
- void SetTag(const CFX_ByteStringC& qTagName);
-
- void RemoveChildren();
-
- void RemoveChild(FX_DWORD index);
-
-
-protected:
-
- CXML_Element* m_pParent;
- CFX_ByteString m_QSpaceName;
- CFX_ByteString m_TagName;
-
- CXML_AttrMap m_AttrMap;
-
- CFX_PtrArray m_Children;
- friend class CXML_Parser;
- friend class CXML_Composer;
+ CXML_AttrMap m_AttrMap;
+
+ CFX_PtrArray m_Children;
+ friend class CXML_Parser;
+ friend class CXML_Composer;
};
#endif // CORE_INCLUDE_FXCRT_FX_XML_H_