TPDE
Loading...
Searching...
No Matches
StringTable.hpp
1// SPDX-FileCopyrightText: 2025 Contributors to TPDE <https://tpde.org>
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3#pragma once
4
5#include "tpde/util/SmallVector.hpp"
6
7#include <cstddef>
8#include <string_view>
9
10namespace tpde {
11
12class StringTable {
13 util::SmallVector<char, 24> strtab;
14
15public:
16 StringTable() noexcept { strtab.resize(1); }
17
18 size_t size() const noexcept { return strtab.size(); }
19 const char *data() const noexcept { return strtab.data(); }
20
21 size_t add(std::string_view str) noexcept;
22 size_t add_prefix(std::string_view prefix, std::string_view str) noexcept;
23};
24
25} // namespace tpde