OpenTTD Source 20260311-master-g511d3794ce
StringData Struct Reference

Information about the currently known strings. More...

#include <strgen.h>

Public Member Functions

 StringData (size_t tabs)
 Create a new string data container.
void FreeTranslation ()
 Free all data related to the translation.
void Add (std::shared_ptr< LangString > ls)
 Add a newly created LangString.
LangStringFind (std::string_view s)
 Find a LangString based on the string name.
uint32_t Version () const
 Make a hash of the file to get a unique "version number".
size_t CountInUse (size_t tab) const
 Count the number of tab elements that are in use.

Data Fields

std::vector< std::shared_ptr< LangString > > strings
 List of all known strings.
std::unordered_map< std::string, std::shared_ptr< LangString >, StringHash, std::equal_to<> > 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.

Detailed Description

Information about the currently known strings.

Definition at line 43 of file strgen.h.

Constructor & Destructor Documentation

◆ StringData()

StringData::StringData ( size_t tabs)

Create a new string data container.

Parameters
tabsThe maximum number of strings.

Definition at line 72 of file strgen_base.cpp.

References max_strings, next_string_id, strings, TAB_SIZE, and tabs.

Member Function Documentation

◆ Add()

void StringData::Add ( std::shared_ptr< LangString > ls)

Add a newly created LangString.

Parameters
lsThe string to add.

Definition at line 91 of file strgen_base.cpp.

References name_to_string, and strings.

◆ CountInUse()

size_t StringData::CountInUse ( size_t tab) const

Count the number of tab elements that are in use.

Parameters
tabThe tab to count the elements of.
Returns
The number of elements in this tab.

Definition at line 160 of file strgen_base.cpp.

References strings, and TAB_SIZE.

Referenced by LanguageWriter::WriteLang().

◆ Find()

LangString * StringData::Find ( std::string_view s)

Find a LangString based on the string name.

Parameters
sThe string name to search on.
Returns
The LangString or nullptr if it is not known.

Definition at line 102 of file strgen_base.cpp.

References name_to_string.

◆ FreeTranslation()

void StringData::FreeTranslation ( )

Free all data related to the translation.

Definition at line 79 of file strgen_base.cpp.

References LangString::FreeTranslation(), max_strings, and strings.

Referenced by GameStrings::Compile().

◆ Version()

uint32_t StringData::Version ( ) const

Make a hash of the file to get a unique "version number".

Returns
The version number.

Definition at line 129 of file strgen_base.cpp.

References DontCount, LangString::english, max_strings, LangString::name, strings, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and VersionHashStr().

Referenced by GameStrings::Compile(), HeaderFileWriter::Finalise(), and LanguageWriter::WriteLang().

Field Documentation

◆ max_strings

size_t StringData::max_strings

The maximum number of strings.

Definition at line 47 of file strgen.h.

Referenced by FreeTranslation(), StringData(), Version(), and HeaderWriter::WriteHeader().

◆ name_to_string

std::unordered_map<std::string, std::shared_ptr<LangString>, StringHash, std::equal_to<> > StringData::name_to_string

Lookup table for the strings.

Definition at line 45 of file strgen.h.

Referenced by Add(), and Find().

◆ next_string_id

size_t StringData::next_string_id

The next string ID to allocate.

Definition at line 48 of file strgen.h.

Referenced by StringData().

◆ strings

std::vector<std::shared_ptr<LangString> > StringData::strings

List of all known strings.

Definition at line 44 of file strgen.h.

Referenced by Add(), CountInUse(), FreeTranslation(), StringData(), Version(), HeaderWriter::WriteHeader(), and LanguageWriter::WriteLang().

◆ tabs

size_t StringData::tabs

The number of 'tabs' of strings.

Definition at line 46 of file strgen.h.

Referenced by StringData(), and LanguageWriter::WriteLang().


The documentation for this struct was generated from the following files: