summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-21 16:35:56 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-21 21:08:06 +0000
commit20a1755a887c652d2f7057ab614b7a06ec492b97 (patch)
treef3a5900ae26081a88ed48d2cf4218c95dd5f55cf
parent9317f8f5336f989aade75ceb925391262b1ccdca (diff)
downloadpdfium-20a1755a887c652d2f7057ab614b7a06ec492b97.tar.xz
Move CFX_StringDataTemplate to StringDataTemplate
This CL renames CFX_StringDataTemplate to StringDataTemplate and moves into the fxcrt namespace. Bug: pdfium:898 Change-Id: I1c1e5ae674c3cca34fd595272e9eebc9346ed6ac Reviewed-on: https://pdfium-review.googlesource.com/14618 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--BUILD.gn2
-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
6 files changed, 30 insertions, 25 deletions
diff --git a/BUILD.gn b/BUILD.gn
index eb67898cd4..a823fe41f6 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -821,7 +821,6 @@ static_library("fxcrt") {
"core/fxcrt/cfx_fixedbufgrow.h",
"core/fxcrt/cfx_memorystream.cpp",
"core/fxcrt/cfx_memorystream.h",
- "core/fxcrt/cfx_string_data_template.h",
"core/fxcrt/cfx_string_pool_template.h",
"core/fxcrt/cfx_unowned_ptr.h",
"core/fxcrt/cfx_utf8decoder.cpp",
@@ -857,6 +856,7 @@ static_library("fxcrt") {
"core/fxcrt/observable.h",
"core/fxcrt/retain_ptr.h",
"core/fxcrt/shared_copy_on_write.h",
+ "core/fxcrt/string_data_template.h",
"core/fxcrt/string_view_template.h",
"core/fxcrt/widestring.cpp",
"core/fxcrt/widestring.h",
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);