Orcus
string_pool.hpp
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  */
7 
8 #ifndef INCLUDED_ORCUS_STRING_POOL_HPP
9 #define INCLUDED_ORCUS_STRING_POOL_HPP
10 
11 #include "env.hpp"
12 #include "pstring.hpp"
13 
14 #include <string>
15 #include <memory>
16 #include <vector>
17 
18 namespace orcus {
19 
23 class ORCUS_PSR_DLLPUBLIC string_pool
24 {
25 public:
26  string_pool(const string_pool&) = delete;
27  string_pool& operator=(const string_pool&) = delete;
28 
29  string_pool();
30  ~string_pool();
31 
41  std::pair<pstring, bool> intern(const char* str);
42 
52  std::pair<pstring, bool> intern(const char* str, size_t n);
53 
61  std::pair<pstring, bool> intern(const pstring& str);
62 
68  std::vector<pstring> get_interned_strings() const;
69 
70  void dump() const;
71 
72  void clear();
73 
74  size_t size() const;
75 
76  void swap(string_pool& other);
77 
87  void merge(string_pool& other);
88 
89 private:
90  struct impl;
91  std::unique_ptr<impl> mp_impl;
92 };
93 
94 }
95 
96 #endif
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: pstring.hpp:28
Definition: string_pool.hpp:24
std::pair< pstring, bool > intern(const char *str)
std::vector< pstring > get_interned_strings() const
std::pair< pstring, bool > intern(const pstring &str)
std::pair< pstring, bool > intern(const char *str, size_t n)
void merge(string_pool &other)