1 // stringpool.h -- a string pool for gold -*- C++ -*-
7 // Manage a pool of unique strings.
9 #ifndef GOLD_STRINGPOOL_H
10 #define GOLD_STRINGPOOL_H
22 // Add a string to the pool. This returns a canonical permanent
23 // pointer to the string.
24 const char* add(const char*);
26 const char* add(const std::string
& s
)
27 { return this->add(s
.c_str()); }
29 // Add the prefix of a string to the pool.
30 const char* add(const char *, size_t);
33 Stringpool(const Stringpool
&);
34 Stringpool
& operator=(const Stringpool
&);
38 // Length of data in buffer.
40 // Allocated size of buffer.
46 const char* add_string(const char*);
48 struct Stringpool_hash
51 operator()(const char*) const;
57 operator()(const char* p1
, const char* p2
) const
58 { return strcmp(p1
, p2
) == 0; }
61 typedef Unordered_set
<const char*, Stringpool_hash
, Stringpool_eq
,
62 std::allocator
<const char*>,
63 true> String_set_type
;
64 String_set_type string_set_
;
65 std::list
<stringdata
*> strings_
;
68 } // End namespace gold.
70 #endif // !defined(GOLD_STRINGPOOL_H)