Interned string type.
More...
#include <framework/uid.h>
|
static bool | no_quote (const char *) |
| Checks whether the name will need quotes. More...
|
|
static bool | is_empty (const char *) |
| Checks whether a string consists of only whitespace. More...
|
|
static bool | is_valid (const UID &) |
| Checks whether the name is valid. More...
|
|
Interned string type.
Should intern strings in O(1) as long as the total number of interned strings is lower than UID_LIMIT. In either case, interned string comparison will always be O(1). If you are converting a lot of strings, it is best to do so early, because the internment process, altough nearly constant time, does, in fact, take some time.
- See also
- https://racenis.github.io/tram-sdk/documentation/framework/uid.html
◆ UID() [1/4]
◆ UID() [2/4]
tram::UID::UID |
( |
const UID & |
value | ) |
|
|
inline |
◆ ~UID()
◆ UID() [3/4]
tram::UID::UID |
( |
const std::string & |
value | ) |
|
◆ UID() [4/4]
tram::UID::UID |
( |
const char * |
value | ) |
|
Interns a string.
This will intern the string and return a little UID that you can put in your little pockets and take away with you. For best results I recommend using the no_quotes() and is_empty() functions to first check whether a given string will also be a good name. A string that isn't empty and doesn't need quotes is a good name.
- Parameters
-
value | The string which will be interned. |
- Note
- Empty strings and
◆ is_empty()
bool tram::UID::is_empty |
( |
const char * |
str | ) |
|
|
static |
Checks whether a string consists of only whitespace.
- Returns
- True, if string contains at least a single non-whitespace character.
◆ is_valid()
bool tram::UID::is_valid |
( |
const UID & |
value | ) |
|
|
static |
Checks whether the name is valid.
Due to bad memory handling practices, it is possible to create a name with such a key, that when this name's string is looked up from the string table and dereferenced, a segfault occurs. This function checks whether a segfault is likely to occur when given a name to check. This is done by a simple bounds check on the string table.
- Returns
- True, if using a name is safe.
◆ no_quote()
bool tram::UID::no_quote |
( |
const char * |
str | ) |
|
|
static |
Checks whether the name will need quotes.
When parsing a name from a text file, if a name has spaces in it, then it will require quotes around it to be parsed in correctly. This function checks whether a certain string will be able to be parsed as a name correctly, without quotes.
- Returns
- True, if the string won't need quotes.
◆ operator bool()
tram::UID::operator bool |
( |
| ) |
|
|
inlineexplicit |
◆ operator char const *()
tram::UID::operator char const * |
( |
| ) |
const |
◆ operator std::string()
tram::UID::operator std::string |
( |
| ) |
const |
◆ operator=()
UID & tram::UID::operator= |
( |
const UID & |
value | ) |
|
|
inline |
◆ operator==() [1/2]
bool tram::UID::operator== |
( |
const char * |
other | ) |
const |
|
inline |
◆ operator==() [2/2]
bool tram::UID::operator== |
( |
const UID & |
other | ) |
const |
|
inline |
◆ key
uint32_t tram::UID::key = 0 |
The documentation for this struct was generated from the following files:
- C:/Users/Poga/Desktop/painis/tram-sdk/src/framework/uid.h
- C:/Users/Poga/Desktop/painis/tram-sdk/src/framework/uid.cpp