|
Pyrogenesis
13997
|
Interned 8-bit strings. More...
#include <CStrIntern.h>
Public Member Functions | |
| CStrIntern () | |
| CStrIntern (const char *str) | |
| CStrIntern (const std::string &str) | |
| u32 | GetHash () const |
| Returns cached FNV1-A hash of the string. More... | |
| const char * | c_str () const |
| Returns null-terminated string. More... | |
| size_t | length () const |
| Returns length of string in bytes. More... | |
| const std::string & | string () const |
| Returns as std::string. More... | |
| bool | operator== (const CStrIntern &b) const |
| String equality. More... | |
| bool | operator< (const CStrIntern &b) const |
| Compare with some arbitrary total order. More... | |
Private Attributes | |
| CStrInternInternals * | m |
Interned 8-bit strings.
Each instance with the same string content is a pointer to the same piece of memory, allowing very fast string comparisons.
Since a CStrIntern is just a dumb pointer, copying is very fast, and pass-by-value should be preferred over pass-by-reference.
Memory allocated for strings will never be freed, so don't use this for unbounded numbers of strings (e.g. text rendered by gameplay scripts) - it's intended for a small number of short frequently-used strings.
Not thread-safe - only allocate these strings from the main thread.
Definition at line 37 of file CStrIntern.h.
| CStrIntern::CStrIntern | ( | ) |
Definition at line 120 of file CStrIntern.cpp.
|
explicit |
Definition at line 125 of file CStrIntern.cpp.
|
explicit |
Definition at line 130 of file CStrIntern.cpp.
| const char * CStrIntern::c_str | ( | ) | const |
Returns null-terminated string.
Definition at line 140 of file CStrIntern.cpp.
| u32 CStrIntern::GetHash | ( | ) | const |
Returns cached FNV1-A hash of the string.
Definition at line 135 of file CStrIntern.cpp.
| size_t CStrIntern::length | ( | ) | const |
Returns length of string in bytes.
Definition at line 145 of file CStrIntern.cpp.
|
inline |
Compare with some arbitrary total order.
(In particular, this is not alphabetic order, and is not consistent between runs of the game.)
Definition at line 77 of file CStrIntern.h.
|
inline |
String equality.
Definition at line 67 of file CStrIntern.h.
| const std::string & CStrIntern::string | ( | ) | const |
Returns as std::string.
Definition at line 150 of file CStrIntern.cpp.
|
private |
Definition at line 83 of file CStrIntern.h.
1.8.5