OpenTTD Source
20241121-master-g67a0fccfad
|
Information about the currently known strings. More...
#include <strgen.h>
Public Member Functions | |
StringData (size_t tabs) | |
Create a new string data container. More... | |
void | FreeTranslation () |
Free all data related to the translation. | |
void | Add (std::unique_ptr< LangString > ls) |
Add a newly created LangString. More... | |
LangString * | Find (const std::string_view s) |
Find a LangString based on the string name. More... | |
uint | VersionHashStr (uint hash, const char *s) const |
Create a compound hash. More... | |
uint | Version () const |
Make a hash of the file to get a unique "version number". More... | |
uint | CountInUse (uint tab) const |
Count the number of tab elements that are in use. More... | |
Data Fields | |
std::vector< std::unique_ptr< LangString > > | strings |
List of all known strings. | |
std::unordered_map< std::string_view, LangString * > | name_to_string |
Lookup table for the strings. | |
size_t | tabs |
The number of 'tabs' of strings. | |
size_t | max_strings |
The maximum number of strings. | |
size_t | next_string_id |
The next string ID to allocate. | |
StringData::StringData | ( | size_t | tabs | ) |
Create a new string data container.
tabs | The maximum number of strings. |
Definition at line 69 of file strgen_base.cpp.
References max_strings, next_string_id, and strings.
void StringData::Add | ( | std::unique_ptr< LangString > | ls | ) |
Add a newly created LangString.
s | The name of the string. |
ls | The string to add. |
Definition at line 89 of file strgen_base.cpp.
References name_to_string, and strings.
uint StringData::CountInUse | ( | uint | tab | ) | const |
Count the number of tab elements that are in use.
tab | The tab to count the elements of. |
Definition at line 163 of file strgen_base.cpp.
References strings, and TAB_SIZE.
Referenced by LanguageWriter::WriteLang().
LangString * StringData::Find | ( | const std::string_view | s | ) |
Find a LangString based on the string name.
s | The string name to search on. |
Definition at line 100 of file strgen_base.cpp.
References name_to_string.
uint StringData::Version | ( | ) | const |
Make a hash of the file to get a unique "version number".
Definition at line 127 of file strgen_base.cpp.
References LangString::english, max_strings, LangString::name, strings, and VersionHashStr().
Referenced by HeaderFileWriter::Finalise().
uint StringData::VersionHashStr | ( | uint | hash, |
const char * | s | ||
) | const |
Create a compound hash.
hash | The hash to add the string hash to. |
s | The string hash. |
Definition at line 114 of file strgen_base.cpp.
Referenced by Version().