Move CFX_StringPoolTemplate to StringPoolTemplate
This CL moves CFX_StringPoolTemplate to StringPoolTemplate and places in
the fxcrt namespace.
Bug: pdfium:898
Change-Id: I41c8f23d6ad814d65cd154092143efaa630a96d1
Reviewed-on: https://pdfium-review.googlesource.com/14619
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index a823fe4..7b9664c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -821,7 +821,6 @@
"core/fxcrt/cfx_fixedbufgrow.h",
"core/fxcrt/cfx_memorystream.cpp",
"core/fxcrt/cfx_memorystream.h",
- "core/fxcrt/cfx_string_pool_template.h",
"core/fxcrt/cfx_unowned_ptr.h",
"core/fxcrt/cfx_utf8decoder.cpp",
"core/fxcrt/cfx_utf8decoder.h",
@@ -857,6 +856,7 @@
"core/fxcrt/retain_ptr.h",
"core/fxcrt/shared_copy_on_write.h",
"core/fxcrt/string_data_template.h",
+ "core/fxcrt/string_pool_template.h",
"core/fxcrt/string_view_template.h",
"core/fxcrt/widestring.cpp",
"core/fxcrt/widestring.h",
@@ -1920,7 +1920,6 @@
"core/fxcodec/jbig2/JBig2_BitStream_unittest.cpp",
"core/fxcodec/jbig2/JBig2_Image_unittest.cpp",
"core/fxcrt/bytestring_unittest.cpp",
- "core/fxcrt/cfx_string_pool_template_unittest.cpp",
"core/fxcrt/cfx_unowned_ptr_unittest.cpp",
"core/fxcrt/cfx_weak_ptr_unittest.cpp",
"core/fxcrt/fx_bidi_unittest.cpp",
@@ -1934,6 +1933,7 @@
"core/fxcrt/observable_unittest.cpp",
"core/fxcrt/retain_ptr_unittest.cpp",
"core/fxcrt/shared_copy_on_write_unittest.cpp",
+ "core/fxcrt/string_pool_template_unittest.cpp",
"core/fxcrt/widestring_unittest.cpp",
"core/fxge/dib/cstretchengine_unittest.cpp",
"fpdfsdk/fpdfdoc_unittest.cpp",
diff --git a/core/fpdfapi/font/cpdf_fontencoding.h b/core/fpdfapi/font/cpdf_fontencoding.h
index 075cc04..d96f787 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.h
+++ b/core/fpdfapi/font/cpdf_fontencoding.h
@@ -9,9 +9,9 @@
#include <memory>
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_weak_ptr.h"
#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/string_pool_template.h"
#define PDFFONT_ENCODING_BUILTIN 0
#define PDFFONT_ENCODING_WINANSI 1
diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h
index 32001a8..53d5dfd 100644
--- a/core/fpdfapi/page/cpdf_streamparser.h
+++ b/core/fpdfapi/page/cpdf_streamparser.h
@@ -14,8 +14,8 @@
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_weak_ptr.h"
+#include "core/fxcrt/string_pool_template.h"
class CPDF_StreamParser {
public:
diff --git a/core/fpdfapi/parser/cpdf_dictionary.h b/core/fpdfapi/parser/cpdf_dictionary.h
index 93c00c8..a9ff353 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.h
+++ b/core/fpdfapi/parser/cpdf_dictionary.h
@@ -13,10 +13,10 @@
#include <utility>
#include "core/fpdfapi/parser/cpdf_object.h"
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_weak_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/string_pool_template.h"
#include "third_party/base/ptr_util.h"
class CPDF_IndirectObjectHolder;
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.h b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
index ab99dd5..ea70c4a 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.h
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
@@ -14,9 +14,9 @@
#include <vector>
#include "core/fpdfapi/parser/cpdf_object.h"
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_weak_ptr.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/string_pool_template.h"
#include "third_party/base/ptr_util.h"
class CPDF_IndirectObjectHolder {
diff --git a/core/fpdfapi/parser/cpdf_name.h b/core/fpdfapi/parser/cpdf_name.h
index 72a72a3..8a1cf2b 100644
--- a/core/fpdfapi/parser/cpdf_name.h
+++ b/core/fpdfapi/parser/cpdf_name.h
@@ -10,8 +10,8 @@
#include <memory>
#include "core/fpdfapi/parser/cpdf_object.h"
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_weak_ptr.h"
+#include "core/fxcrt/string_pool_template.h"
class CPDF_Name : public CPDF_Object {
public:
diff --git a/core/fpdfapi/parser/cpdf_string.h b/core/fpdfapi/parser/cpdf_string.h
index 9fd3e6a..6f762ae 100644
--- a/core/fpdfapi/parser/cpdf_string.h
+++ b/core/fpdfapi/parser/cpdf_string.h
@@ -10,10 +10,10 @@
#include <memory>
#include "core/fpdfapi/parser/cpdf_object.h"
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_weak_ptr.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/string_pool_template.h"
class CPDF_String : public CPDF_Object {
public:
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h
index 78d5345..cb26683 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.h
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.h
@@ -10,8 +10,8 @@
#include <algorithm>
#include <memory>
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_weak_ptr.h"
+#include "core/fxcrt/string_pool_template.h"
class CPDF_CryptoHandler;
class CPDF_Dictionary;
diff --git a/core/fpdfdoc/cpdf_filespec.h b/core/fpdfdoc/cpdf_filespec.h
index 2cbbc15..131dfbe 100644
--- a/core/fpdfdoc/cpdf_filespec.h
+++ b/core/fpdfdoc/cpdf_filespec.h
@@ -7,10 +7,10 @@
#ifndef CORE_FPDFDOC_CPDF_FILESPEC_H_
#define CORE_FPDFDOC_CPDF_FILESPEC_H_
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/cfx_weak_ptr.h"
#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/string_pool_template.h"
class CPDF_Dictionary;
class CPDF_Object;
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index a78020b..aa1fb57 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -12,17 +12,17 @@
#include <cctype>
#include <string>
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_utf8decoder.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "core/fxcrt/string_pool_template.h"
#include "third_party/base/numerics/safe_math.h"
#include "third_party/base/stl_util.h"
template class fxcrt::StringDataTemplate<char>;
template class fxcrt::StringViewTemplate<char>;
-template class CFX_StringPoolTemplate<ByteString>;
+template class fxcrt::StringPoolTemplate<ByteString>;
template struct std::hash<ByteString>;
namespace {
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index c2c41e8..eba9744 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -18,11 +18,10 @@
#include "core/fxcrt/string_view_template.h"
#include "third_party/base/optional.h"
-class ByteString_Concat_Test;
-class fxcrt_ByteStringPool_Test;
-
namespace fxcrt {
+class ByteString_Concat_Test;
+class StringPool_ByteString_Test;
class WideString;
// A mutable string with shared buffers using copy-on-write semantics that
@@ -198,7 +197,7 @@
RetainPtr<StringData> m_pData;
friend ByteString_Concat_Test;
- friend fxcrt_ByteStringPool_Test;
+ friend class StringPool_ByteString_Test;
};
inline bool operator==(const char* lhs, const ByteString& rhs) {
diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp
index 06ba1f4..e1c832e 100644
--- a/core/fxcrt/bytestring_unittest.cpp
+++ b/core/fxcrt/bytestring_unittest.cpp
@@ -11,6 +11,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/base/stl_util.h"
+namespace fxcrt {
+
TEST(ByteString, ElementAccess) {
const ByteString abc("abc");
EXPECT_EQ('a', abc[0]);
@@ -1640,3 +1642,5 @@
EXPECT_EQ("2147483647", ByteString::FormatInteger(INT_MAX));
EXPECT_EQ("-2147483648", ByteString::FormatInteger(INT_MIN));
}
+
+} // namespace fxcrt
diff --git a/core/fxcrt/cfx_string_pool_template.h b/core/fxcrt/cfx_string_pool_template.h
deleted file mode 100644
index b170a84..0000000
--- a/core/fxcrt/cfx_string_pool_template.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FXCRT_CFX_STRING_POOL_TEMPLATE_H_
-#define CORE_FXCRT_CFX_STRING_POOL_TEMPLATE_H_
-
-#include <unordered_set>
-
-#include "core/fxcrt/fx_string.h"
-
-template <typename StringType>
-class CFX_StringPoolTemplate {
- public:
- StringType Intern(const StringType& str) { return *m_Pool.insert(str).first; }
- void Clear() { m_Pool.clear(); }
-
- private:
- std::unordered_set<StringType> m_Pool;
-};
-
-using ByteStringPool = CFX_StringPoolTemplate<ByteString>;
-using WideStringPool = CFX_StringPoolTemplate<WideString>;
-
-extern template class CFX_StringPoolTemplate<ByteString>;
-extern template class CFX_StringPoolTemplate<WideString>;
-
-#endif // CORE_FXCRT_CFX_STRING_POOL_TEMPLATE_H_
diff --git a/core/fxcrt/maybe_owned_unittest.cpp b/core/fxcrt/maybe_owned_unittest.cpp
index 686fa6f..7182647 100644
--- a/core/fxcrt/maybe_owned_unittest.cpp
+++ b/core/fxcrt/maybe_owned_unittest.cpp
@@ -12,7 +12,6 @@
#include "third_party/base/ptr_util.h"
namespace fxcrt {
-
namespace {
class PseudoDeletable {
diff --git a/core/fxcrt/observable_unittest.cpp b/core/fxcrt/observable_unittest.cpp
index 8edc58f..5e64743 100644
--- a/core/fxcrt/observable_unittest.cpp
+++ b/core/fxcrt/observable_unittest.cpp
@@ -9,6 +9,7 @@
#include "testing/gtest/include/gtest/gtest.h"
+namespace fxcrt {
namespace {
class PseudoObservable : public Observable<PseudoObservable> {
@@ -183,3 +184,5 @@
EXPECT_FALSE(null_bool);
EXPECT_TRUE(obj1_bool);
}
+
+} // namespace fxcrt
diff --git a/core/fxcrt/retain_ptr_unittest.cpp b/core/fxcrt/retain_ptr_unittest.cpp
index 3e14478..f4b2994 100644
--- a/core/fxcrt/retain_ptr_unittest.cpp
+++ b/core/fxcrt/retain_ptr_unittest.cpp
@@ -9,6 +9,7 @@
#include "testing/gtest/include/gtest/gtest.h"
+namespace fxcrt {
namespace {
class PseudoRetainable {
@@ -298,3 +299,5 @@
EXPECT_EQ(1, obj.retain_count());
EXPECT_EQ(1, obj.release_count());
}
+
+} // namespace fxcrt
diff --git a/core/fxcrt/shared_copy_on_write_unittest.cpp b/core/fxcrt/shared_copy_on_write_unittest.cpp
index a683767..01cc094 100644
--- a/core/fxcrt/shared_copy_on_write_unittest.cpp
+++ b/core/fxcrt/shared_copy_on_write_unittest.cpp
@@ -9,6 +9,7 @@
#include "testing/gtest/include/gtest/gtest.h"
+namespace fxcrt {
namespace {
class Observer {
@@ -126,3 +127,5 @@
}
EXPECT_EQ(2, observer.GetDestructionCount("one"));
}
+
+} // namespace fxcrt
diff --git a/core/fxcrt/string_pool_template.h b/core/fxcrt/string_pool_template.h
new file mode 100644
index 0000000..2f9fb09
--- /dev/null
+++ b/core/fxcrt/string_pool_template.h
@@ -0,0 +1,36 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCRT_STRING_POOL_TEMPLATE_H_
+#define CORE_FXCRT_STRING_POOL_TEMPLATE_H_
+
+#include <unordered_set>
+
+#include "core/fxcrt/fx_string.h"
+
+namespace fxcrt {
+
+template <typename StringType>
+class StringPoolTemplate {
+ public:
+ StringType Intern(const StringType& str) { return *m_Pool.insert(str).first; }
+ void Clear() { m_Pool.clear(); }
+
+ private:
+ std::unordered_set<StringType> m_Pool;
+};
+
+extern template class StringPoolTemplate<ByteString>;
+extern template class StringPoolTemplate<WideString>;
+
+} // namespace fxcrt
+
+using fxcrt::StringPoolTemplate;
+
+using ByteStringPool = StringPoolTemplate<ByteString>;
+using WideStringPool = StringPoolTemplate<WideString>;
+
+#endif // CORE_FXCRT_STRING_POOL_TEMPLATE_H_
diff --git a/core/fxcrt/cfx_string_pool_template_unittest.cpp b/core/fxcrt/string_pool_template_unittest.cpp
similarity index 95%
rename from core/fxcrt/cfx_string_pool_template_unittest.cpp
rename to core/fxcrt/string_pool_template_unittest.cpp
index 9a5ac5d..717e33d 100644
--- a/core/fxcrt/cfx_string_pool_template_unittest.cpp
+++ b/core/fxcrt/string_pool_template_unittest.cpp
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/fxcrt/cfx_string_pool_template.h"
+#include "core/fxcrt/string_pool_template.h"
#include "core/fxcrt/fx_string.h"
#include "testing/gtest/include/gtest/gtest.h"
-TEST(fxcrt, ByteStringPool) {
+namespace fxcrt {
+
+TEST(StringPool, ByteString) {
ByteStringPool pool;
ByteString null1;
@@ -49,7 +51,7 @@
EXPECT_EQ(goats2.m_pData, reinterned_goats2.m_pData);
}
-TEST(fxcrt, WideStringPool) {
+TEST(StringPool, WideString) {
WideStringPool pool;
WideString null1;
@@ -91,3 +93,5 @@
EXPECT_EQ(goats2.m_pData, reinterned_goats1.m_pData);
EXPECT_EQ(goats2.m_pData, reinterned_goats2.m_pData);
}
+
+} // namespace fxcrt
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index e592584..5fe7ee4 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -12,17 +12,17 @@
#include <cctype>
#include <cwctype>
-#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_utf8decoder.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "core/fxcrt/string_pool_template.h"
#include "third_party/base/numerics/safe_math.h"
#include "third_party/base/stl_util.h"
template class fxcrt::StringDataTemplate<wchar_t>;
template class fxcrt::StringViewTemplate<wchar_t>;
-template class CFX_StringPoolTemplate<WideString>;
+template class fxcrt::StringPoolTemplate<WideString>;
template struct std::hash<WideString>;
#define FORCE_ANSI 0x10000
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index df7d95f..f56703f 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -18,12 +18,12 @@
#include "core/fxcrt/string_view_template.h"
#include "third_party/base/optional.h"
-class WideString_ConcatInPlace_Test;
-class fxcrt_WideStringPool_Test;
namespace fxcrt {
class ByteString;
+class StringPool_WideString_Test;
+class WideString_ConcatInPlace_Test;
// A mutable string with shared buffers using copy-on-write semantics that
// avoids the cost of std::string's iterator stability guarantees.
@@ -195,7 +195,7 @@
RetainPtr<StringData> m_pData;
friend WideString_ConcatInPlace_Test;
- friend fxcrt_WideStringPool_Test;
+ friend StringPool_WideString_Test;
};
inline WideString operator+(const WideStringView& str1,
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 949827f..5eba72e 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -10,6 +10,8 @@
#include "core/fxcrt/fx_string.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace fxcrt {
+
TEST(WideString, ElementAccess) {
const WideString abc(L"abc");
EXPECT_EQ(L'a', abc[0]);
@@ -1603,3 +1605,5 @@
EXPECT_EQ(L"abcdef", stream.str());
}
}
+
+} // namespace fxcrt