string_pool

Defined in header: <orcus/string_pool.hpp>

class string_pool

This class implements a shared string pool with the ability to merge with other pools.

Note

This class is not copy-constructible, but is move-constructible.

Public Functions

string_pool(const string_pool&) = delete
string_pool &operator=(const string_pool&) = delete
string_pool()
string_pool(string_pool &&other)
~string_pool()
std::pair<std::string_view, bool> intern(std::string_view str)

Intern a string.

Parameters:

str – string to intern.

Returns:

pair whose first value is the interned string, and the second value specifies whether it is a newly created instance (true) or a reuse of an existing instance (false).

std::vector<std::string_view> get_interned_strings() const

Return all interned strings.

Returns:

sequence of all interned strings. The sequence will be sorted.

void dump() const

Dump pool’s content to stdout.

Todo:

This needs to be reworked to make it more generally usable.

void clear()

Clear pool’s content.

size_t size() const

Query the total number of strings stored in the pool.

Returns:

size_t total number of strings in the pool.

void swap(string_pool &other)

Swap the content with another string-pool instance.

Parameters:

other – string-pool instance to swap contents with.

void merge(string_pool &other)

Merge another string pool instance in. This will not invalidate any string references to the other pool.

The other string pool instance will become empty when this call returns.

Parameters:

other – string pool instance to merge in.