OpenTTD Source 20260218-master-g2123fca5ea
LanguageScanner Class Reference

Scanner to find language files in a GameScript directory. More...

Inheritance diagram for LanguageScanner:
FileScanner

Public Member Functions

 LanguageScanner (std::weak_ptr< GameStrings > gs, const std::string &exclude)
 Initialise the scanner.
void Scan (const std::string &directory)
 Actually run the scan.
bool AddFile (const std::string &filename, size_t, const std::string &) override
 Add a file with the given filename.

Private Attributes

std::weak_ptr< GameStringsgs
 The (already) loaded game strings.
std::string exclude
 The file name to exclude during scanning.

Additional Inherited Members

Protected Member Functions inherited from FileScanner
virtual ~FileScanner ()=default
 Destruct the proper one...
uint Scan (std::string_view extension, Subdirectory sd, bool tars=true, bool recursive=true)
 Scan for files with the given extension in the given search path.
uint Scan (std::string_view extension, const std::string &directory, bool recursive=true)
 Scan for files with the given extension in the given search path.
Protected Attributes inherited from FileScanner
Subdirectory subdir {}
 The current sub directory we are searching through.

Detailed Description

Scanner to find language files in a GameScript directory.

Definition at line 163 of file game_text.cpp.

Constructor & Destructor Documentation

◆ LanguageScanner()

LanguageScanner::LanguageScanner ( std::weak_ptr< GameStrings > gs,
const std::string & exclude )
inline

Initialise the scanner.

Parameters
gsThe (already) loaded game strings to add to.
excludeThe file name to exclude during sanning.

Definition at line 174 of file game_text.cpp.

References exclude, and gs.

Member Function Documentation

◆ AddFile()

bool LanguageScanner::AddFile ( const std::string & filename,
size_t basepath_length,
const std::string & tar_filename )
inlineoverridevirtual

Add a file with the given filename.

Parameters
filenamethe full path to the file to read
basepath_lengthamount of characters to chop of before to get a filename relative to the search path.
tar_filenamethe name of the tar file the file is read from.
Returns
true if the file is added.

Implements FileScanner.

Definition at line 185 of file game_text.cpp.

References exclude, and ReadRawLanguageStrings().

Referenced by LoadTranslations().

◆ Scan()

void LanguageScanner::Scan ( const std::string & directory)
inline

Actually run the scan.

Parameters
directoryThe directory to scan in.

Definition at line 180 of file game_text.cpp.

References FileScanner::Scan().

Referenced by LoadTranslations().

Field Documentation

◆ exclude

std::string LanguageScanner::exclude
private

The file name to exclude during scanning.

Definition at line 166 of file game_text.cpp.

Referenced by AddFile(), and LanguageScanner().

◆ gs

std::weak_ptr<GameStrings> LanguageScanner::gs
private

The (already) loaded game strings.

Definition at line 165 of file game_text.cpp.

Referenced by LanguageScanner().


The documentation for this class was generated from the following file: