• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FXCRT_STRING_POOL_TEMPLATE_H_
8 #define CORE_FXCRT_STRING_POOL_TEMPLATE_H_
9 
10 #include <unordered_set>
11 
12 #include "core/fxcrt/fx_string.h"
13 
14 namespace fxcrt {
15 
16 template <typename StringType>
17 class StringPoolTemplate {
18  public:
Intern(const StringType & str)19   StringType Intern(const StringType& str) { return *m_Pool.insert(str).first; }
Clear()20   void Clear() { m_Pool.clear(); }
21 
22  private:
23   std::unordered_set<StringType> m_Pool;
24 };
25 
26 extern template class StringPoolTemplate<ByteString>;
27 extern template class StringPoolTemplate<WideString>;
28 
29 }  // namespace fxcrt
30 
31 using fxcrt::StringPoolTemplate;
32 
33 using ByteStringPool = StringPoolTemplate<ByteString>;
34 using WideStringPool = StringPoolTemplate<WideString>;
35 
36 #endif  // CORE_FXCRT_STRING_POOL_TEMPLATE_H_
37