From a52ab741019342fbca0468e43a01deb44fa5f1bd Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 29 Sep 2016 13:59:29 -0700 Subject: Move core/fxcrt/include to core/fxcrt BUG=pdfium:611 Review-Url: https://codereview.chromium.org/2382723003 --- core/fxcrt/cfx_string_pool_template.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 core/fxcrt/cfx_string_pool_template.h (limited to 'core/fxcrt/cfx_string_pool_template.h') diff --git a/core/fxcrt/cfx_string_pool_template.h b/core/fxcrt/cfx_string_pool_template.h new file mode 100644 index 0000000000..bfc1ce4bfb --- /dev/null +++ b/core/fxcrt/cfx_string_pool_template.h @@ -0,0 +1,30 @@ +// 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 + +#include "core/fxcrt/fx_string.h" + +template +class CFX_StringPoolTemplate { + public: + StringType Intern(const StringType& str) { return *m_Pool.insert(str).first; } + void Clear() { m_Pool.clear(); } + + private: + std::unordered_set m_Pool; +}; + +using CFX_ByteStringPool = CFX_StringPoolTemplate; +using CFX_WideStringPool = CFX_StringPoolTemplate; + +extern template class CFX_StringPoolTemplate; +extern template class CFX_StringPoolTemplate; + +#endif // CORE_FXCRT_CFX_STRING_POOL_TEMPLATE_H_ -- cgit v1.2.3