chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
10 / 10
100.0%
Branches:
5 / 7
71.4%
Functions:
1 / 1, 3 excl
100.0%

stage/structure/tokens.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #pragma once
3
4 #include <cstdint>
5 #include <deque>
6 #include <string>
7 #include <string_view>
8 #include <unordered_map>
9
10 namespace chrono::batch_render {
11
12 41411 struct Token {
13 uint32_t id = 0;
14
15 261 bool operator==(const Token& other) const {
16
4/6
<unknown function 12>:
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
<unknown function 15>:
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 21 times.
261 return id == other.id;
17 }
18
19 bool operator!=(const Token& other) const {
20 return !(*this == other);
21 }
22 };
23
24 10 class Tokens {
25 public:
26 Tokens();
27 Tokens(const Tokens&) = delete;
28 Tokens& operator=(const Tokens&) = delete;
29 1 Tokens(Tokens&&) = default;
30 Tokens& operator=(Tokens&&) = default;
31
32 Token Intern(std::string_view text);
33 Token Find(std::string_view text) const;
34 std::string_view Text(Token token) const;
35
36 1 uint32_t Size() const {
37
1/1
✓ Branch 1 taken 1 time.
1 return uint32_t(m_texts.size());
38 }
39
40 private:
41 std::deque<std::string> m_texts;
42 std::unordered_map<std::string_view, uint32_t> m_ids;
43 };
44
45 }
46