summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fxcrt/bytestring.cpp2
-rw-r--r--core/fxcrt/bytestring.h4
-rw-r--r--core/fxcrt/string_data_template.h (renamed from core/fxcrt/cfx_string_data_template.h)41
-rw-r--r--core/fxcrt/widestring.cpp2
-rw-r--r--core/fxcrt/widestring.h4
5 files changed, 29 insertions, 24 deletions
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 2d343ffd11..a78020bae4 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -20,7 +20,7 @@
#include "third_party/base/numerics/safe_math.h"
#include "third_party/base/stl_util.h"
-template class CFX_StringDataTemplate<char>;
+template class fxcrt::StringDataTemplate<char>;
template class fxcrt::StringViewTemplate<char>;
template class CFX_StringPoolTemplate<ByteString>;
template struct std::hash<ByteString>;
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index 7342fdbea7..c2c41e8c47 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -12,9 +12,9 @@
#include <sstream>
#include <utility>
-#include "core/fxcrt/cfx_string_data_template.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
+#include "core/fxcrt/string_data_template.h"
#include "core/fxcrt/string_view_template.h"
#include "third_party/base/optional.h"
@@ -185,7 +185,7 @@ class ByteString {
static ByteString FormatFloat(float f, int precision = 0);
protected:
- using StringData = CFX_StringDataTemplate<char>;
+ using StringData = StringDataTemplate<char>;
void ReallocBeforeWrite(FX_STRSIZE nNewLen);
void AllocBeforeWrite(FX_STRSIZE nNewLen);
diff --git a/core/fxcrt/cfx_string_data_template.h b/core/fxcrt/string_data_template.h
index eabb608818..afec50fe01 100644
--- a/core/fxcrt/cfx_string_data_template.h
+++ b/core/fxcrt/string_data_template.h
@@ -4,23 +4,24 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_
-#define CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_
+#ifndef CORE_FXCRT_STRING_DATA_TEMPLATE_H_
+#define CORE_FXCRT_STRING_DATA_TEMPLATE_H_
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_system.h"
#include "third_party/base/numerics/safe_math.h"
+namespace fxcrt {
+
template <typename CharType>
-class CFX_StringDataTemplate {
+class StringDataTemplate {
public:
- static CFX_StringDataTemplate* Create(FX_STRSIZE nLen) {
+ static StringDataTemplate* Create(FX_STRSIZE nLen) {
ASSERT(nLen > 0);
// Calculate space needed for the fixed portion of the struct plus the
// NUL char that is not included in |m_nAllocLength|.
- int overhead =
- offsetof(CFX_StringDataTemplate, m_String) + sizeof(CharType);
+ int overhead = offsetof(StringDataTemplate, m_String) + sizeof(CharType);
pdfium::base::CheckedNumeric<FX_STRSIZE> nSize = nLen;
nSize *= sizeof(CharType);
nSize += overhead;
@@ -36,18 +37,18 @@ class CFX_StringDataTemplate {
ASSERT(usableLen >= nLen);
void* pData = pdfium::base::PartitionAllocGeneric(
- gStringPartitionAllocator.root(), totalSize, "CFX_StringDataTemplate");
- return new (pData) CFX_StringDataTemplate(nLen, usableLen);
+ gStringPartitionAllocator.root(), totalSize, "StringDataTemplate");
+ return new (pData) StringDataTemplate(nLen, usableLen);
}
- static CFX_StringDataTemplate* Create(const CFX_StringDataTemplate& other) {
- CFX_StringDataTemplate* result = Create(other.m_nDataLength);
+ static StringDataTemplate* Create(const StringDataTemplate& other) {
+ StringDataTemplate* result = Create(other.m_nDataLength);
result->CopyContents(other);
return result;
}
- static CFX_StringDataTemplate* Create(const CharType* pStr, FX_STRSIZE nLen) {
- CFX_StringDataTemplate* result = Create(nLen);
+ static StringDataTemplate* Create(const CharType* pStr, FX_STRSIZE nLen) {
+ StringDataTemplate* result = Create(nLen);
result->CopyContents(pStr, nLen);
return result;
}
@@ -63,7 +64,7 @@ class CFX_StringDataTemplate {
return m_nRefs <= 1 && nTotalLen <= m_nAllocLength;
}
- void CopyContents(const CFX_StringDataTemplate& other) {
+ void CopyContents(const StringDataTemplate& other) {
ASSERT(other.m_nDataLength <= m_nAllocLength);
memcpy(m_String, other.m_String,
(other.m_nDataLength + 1) * sizeof(CharType));
@@ -102,17 +103,21 @@ class CFX_StringDataTemplate {
CharType m_String[1];
private:
- CFX_StringDataTemplate(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
+ StringDataTemplate(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
: m_nRefs(0), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
ASSERT(dataLen >= 0);
ASSERT(dataLen <= allocLen);
m_String[dataLen] = 0;
}
- ~CFX_StringDataTemplate() = delete;
+ ~StringDataTemplate() = delete;
};
-extern template class CFX_StringDataTemplate<char>;
-extern template class CFX_StringDataTemplate<wchar_t>;
+extern template class StringDataTemplate<char>;
+extern template class StringDataTemplate<wchar_t>;
+
+} // namespace fxcrt
+
+using fxcrt::StringDataTemplate;
-#endif // CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_
+#endif // CORE_FXCRT_STRING_DATA_TEMPLATE_H_
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index e90d8ced85..e5925845be 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -20,7 +20,7 @@
#include "third_party/base/numerics/safe_math.h"
#include "third_party/base/stl_util.h"
-template class CFX_StringDataTemplate<wchar_t>;
+template class fxcrt::StringDataTemplate<wchar_t>;
template class fxcrt::StringViewTemplate<wchar_t>;
template class CFX_StringPoolTemplate<WideString>;
template struct std::hash<WideString>;
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index 4dc0abbc99..df7d95fc6f 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -11,10 +11,10 @@
#include <iterator>
#include <utility>
-#include "core/fxcrt/cfx_string_data_template.h"
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
+#include "core/fxcrt/string_data_template.h"
#include "core/fxcrt/string_view_template.h"
#include "third_party/base/optional.h"
@@ -179,7 +179,7 @@ class WideString {
ByteString UTF16LE_Encode() const;
protected:
- using StringData = CFX_StringDataTemplate<wchar_t>;
+ using StringData = StringDataTemplate<wchar_t>;
void ReallocBeforeWrite(FX_STRSIZE nLen);
void AllocBeforeWrite(FX_STRSIZE nLen);