ATLAS Offline Software
Loading...
Searching...
No Matches
StringPool.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2/*
3 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4*/
22
23#ifndef SGTOOLS_STRINGPOOL_H
24#define SGTOOLS_STRINGPOOL_H
25
26#include <stdint.h>
27#include <string>
28#include <memory>
29
30namespace SG {
31
32class StringPoolImpl;
33
35{
36public:
38 typedef uint32_t sgkey_t;
39
41 typedef unsigned int sgaux_t;
42
45 static const int sgkey_t_nbits = 30;
46 static const sgkey_t sgkey_t_max =
47 (static_cast<sgkey_t>(1) << sgkey_t_nbits) - 1;
48
50 StringPool();
51
54
56 StringPool (const StringPool& other);
57 StringPool (StringPool&& other);
58
60 StringPool& operator= (const StringPool& other);
62
72 sgkey_t stringToKey (const std::string& str, sgaux_t aux = 0);
73
81 const std::string* keyToString (sgkey_t key) const;
82
91 const std::string* keyToString (sgkey_t key, sgaux_t& aux) const;
92
104 bool registerKey (sgkey_t key,
105 const std::string& str,
106 sgaux_t aux = 0);
107
108
112 size_t size() const;
113
117 void dump() const;
118
119
123 void clear();
124
125
133 bool merge (const StringPool& other);
134
135
136private:
137 std::unique_ptr<StringPoolImpl> m_impl;
138};
139
140
141} // namespace SG
142
143
144#endif // not SGTOOLS_STRINGPOOL_H
unsigned int sgaux_t
Type of auxiliary data.
Definition StringPool.h:41
bool registerKey(sgkey_t key, const std::string &str, sgaux_t aux=0)
Remember an additional mapping from key to string.
std::unique_ptr< StringPoolImpl > m_impl
Definition StringPool.h:137
void dump() const
Debugging dump.
const std::string * keyToString(sgkey_t key) const
Find the string corresponding to a given key.
StringPool()
Constructor.
static const sgkey_t sgkey_t_max
Definition StringPool.h:46
static const int sgkey_t_nbits
Number of bits we'll use in the keys.
Definition StringPool.h:45
~StringPool()
Destructor.
size_t size() const
Number of registered mappings.
sgkey_t stringToKey(const std::string &str, sgaux_t aux=0)
Find the key for a string.
uint32_t sgkey_t
Type of the integer keys.
Definition StringPool.h:38
StringPool & operator=(const StringPool &other)
Assignment/move operators.
void clear()
Empty the pool.
Forward declaration.
Definition merge.py:1