|
ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
|
Immutable string with automatic deduplication via global pool. More...
#include <InternedString.h>
Public Types | |
| using | value_type = std::string::value_type |
| using | const_iterator = std::string::const_iterator |
Public Member Functions | |
| InternedString (const std::string &v) | |
| Construct from std::string. | |
| InternedString (std::string &&v) | |
| Construct from std::string (move). | |
| InternedString (const char *v) | |
| Construct from C-string literal. | |
| InternedString (std::string_view v) | |
| Construct from string_view. | |
| InternedString (std::size_t n, char c) | |
| Construct string of n copies of character c. | |
| InternedString (const InternedString &other) | |
| InternedString & | operator= (const InternedString &other) |
| InternedString (InternedString &&other) noexcept | |
| InternedString & | operator= (InternedString &&other) noexcept |
| const std::string & | str () const |
| Get the underlying string value. | |
| bool | empty () const noexcept |
| Check if the string is empty. | |
| std::size_t | size () const noexcept |
| Get string length. | |
| const_iterator | begin () const noexcept |
| const_iterator | end () const noexcept |
| const char & | operator[] (std::size_t pos) const |
| char & | operator[] (std::size_t pos) |
| const char & | back () const |
| const char * | c_str () const |
| const char * | data () const |
| void | clear () |
| Clear the string (sets to empty interned string). | |
| void | push_back (char c) |
| InternedString & | append (const char *s, std::size_t n) |
| InternedString & | operator+= (const InternedString &other) |
| void | resize (std::size_t n, char c='\0') |
| bool | operator== (const InternedString &other) const noexcept |
| bool | operator!= (const InternedString &other) const noexcept |
| std::size_t | refCount () const noexcept |
| Get reference count for this string. | |
Static Public Member Functions | |
| static std::size_t | poolSize () |
| Get current pool size (for debugging). | |
| static void | displayPool () |
| Display all strings in pool (for debugging). | |
Friends | |
| bool | operator< (const InternedString &lhs, const InternedString &rhs) |
Immutable string with automatic deduplication via global pool.
Provides memory-efficient string storage by sharing identical string values. Multiple instances with the same content point to the same underlying memory. Thread-safe, reference counted, and compatible with nlohmann::json.
Definition at line 55 of file InternedString.h.
| using acav::InternedString::const_iterator = std::string::const_iterator |
Definition at line 84 of file InternedString.h.
| using acav::InternedString::value_type = std::string::value_type |
Definition at line 57 of file InternedString.h.
|
explicit |
Construct from std::string.
Definition at line 85 of file InternedString.cpp.
|
explicit |
Construct from std::string (move).
Definition at line 89 of file InternedString.cpp.
| acav::InternedString::InternedString | ( | const char * | v | ) |
Construct from C-string literal.
Definition at line 93 of file InternedString.cpp.
|
explicit |
Construct from string_view.
Definition at line 96 of file InternedString.cpp.
| acav::InternedString::InternedString | ( | std::size_t | n, |
| char | c ) |
Construct string of n copies of character c.
Definition at line 98 of file InternedString.cpp.
| acav::InternedString::InternedString | ( | const InternedString & | other | ) |
Definition at line 101 of file InternedString.cpp.
|
noexcept |
Definition at line 121 of file InternedString.cpp.
| acav::InternedString::~InternedString | ( | ) |
Definition at line 135 of file InternedString.cpp.
| InternedString & acav::InternedString::append | ( | const char * | s, |
| std::size_t | n ) |
Definition at line 188 of file InternedString.cpp.
| const char & acav::InternedString::back | ( | ) | const |
Definition at line 173 of file InternedString.cpp.
|
noexcept |
Definition at line 149 of file InternedString.cpp.
| const char * acav::InternedString::c_str | ( | ) | const |
Definition at line 175 of file InternedString.cpp.
| void acav::InternedString::clear | ( | ) |
Clear the string (sets to empty interned string).
Definition at line 179 of file InternedString.cpp.
| const char * acav::InternedString::data | ( | ) | const |
Definition at line 177 of file InternedString.cpp.
|
static |
Display all strings in pool (for debugging).
Definition at line 244 of file InternedString.cpp.
|
noexcept |
Check if the string is empty.
Definition at line 143 of file InternedString.cpp.
Referenced by str().
|
noexcept |
Definition at line 153 of file InternedString.cpp.
|
noexcept |
Definition at line 220 of file InternedString.cpp.
| InternedString & acav::InternedString::operator+= | ( | const InternedString & | other | ) |
Definition at line 195 of file InternedString.cpp.
| InternedString & acav::InternedString::operator= | ( | const InternedString & | other | ) |
Definition at line 109 of file InternedString.cpp.
|
noexcept |
Definition at line 126 of file InternedString.cpp.
|
noexcept |
Definition at line 215 of file InternedString.cpp.
| char & acav::InternedString::operator[] | ( | std::size_t | pos | ) |
Definition at line 161 of file InternedString.cpp.
| const char & acav::InternedString::operator[] | ( | std::size_t | pos | ) | const |
Definition at line 157 of file InternedString.cpp.
|
static |
Get current pool size (for debugging).
Definition at line 235 of file InternedString.cpp.
| void acav::InternedString::push_back | ( | char | c | ) |
Definition at line 182 of file InternedString.cpp.
|
noexcept |
Get reference count for this string.
Definition at line 240 of file InternedString.cpp.
| void acav::InternedString::resize | ( | std::size_t | n, |
| char | c = '\0' ) |
Definition at line 208 of file InternedString.cpp.
|
noexcept |
Get string length.
Definition at line 145 of file InternedString.cpp.
| const std::string & acav::InternedString::str | ( | ) | const |
Get the underlying string value.
Definition at line 138 of file InternedString.cpp.
References empty().
|
friend |
Definition at line 224 of file InternedString.cpp.