OpenTTD Source: FileStringReader Struct Reference

OpenTTD Source 15.3

Public Member Functions | Data Fields
FileStringReader Struct Reference

A reader that simply reads using fopen. More...

Inheritance diagram for FileStringReader:

## Public Member Functions
| FileStringReader (StringData &data, const std::filesystem::path &file, bool master, bool translation)
| Create the reader.
std::optional< std::string > | ReadLine () override
| Read a single line from the source of strings.
void | HandlePragma (std::string_view str, LanguagePackHeader &lang) override
| Handle the pragma of the file.
void | ParseFile () override
| Start parsing the file.
Public Member Functions inherited from StringReader
| StringReader (StringData &data, const std::string &file, bool master, bool translation)
| Prepare reading.
void | HandleString (std::string_view str)

## Data Fields
std::ifstream | input_stream
Data Fields inherited from StringReader
StringData & | data
| The data to fill during reading.
const std::string | file
| The file we are reading.
bool | master
| Are we reading the master file?
bool | translation
| Are we reading a translation, implies !master. However, the base translation will have this false.

## Detailed Description

A reader that simply reads using fopen.

Definition at line 69 of file strgen.cpp.

## Constructor & Destructor Documentation

## ◆ FileStringReader()

FileStringReader::FileStringReader | ( | StringData & | data,
|  | const std::filesystem::path & | file,
|  | bool | master,
|  | bool | translation
| ) |  |
| inline

Create the reader.

Parameters

  data | The data to fill during reading.
  file | The file we are reading.
  master | Are we reading the master file?
  translation | Are we reading a translation?

Definition at line 79 of file strgen.cpp.

References StringReader::file.

## Member Function Documentation

## ◆ HandlePragma()

void FileStringReader::HandlePragma | ( | std::string_view | str,
|  | LanguagePackHeader & | lang
| ) |  |
| overridevirtual

Handle the pragma of the file.

Parameters

  str | The pragma string to parse.

Reimplemented from StringReader.

Definition at line 104 of file strgen.cpp.

References CASE_GENDER_LEN, LanguagePackHeader::cases, StringReader::data, LanguagePackHeader::digit_decimal_separator, LanguagePackHeader::digit_group_separator, LanguagePackHeader::digit_group_separator_currency, LanguagePackHeader::genders, StringReader::HandlePragma(), LanguagePackHeader::isocode, StringReader::master, MAX_NUM_CASES, MAX_NUM_GENDERS, LanguagePackHeader::name, NBSP, LanguagePackHeader::newgrflangid, StringData::next_string_id, StringConsumer::npos, LanguagePackHeader::num_cases, LanguagePackHeader::num_genders, LanguagePackHeader::own_name, StringConsumer::Read(), StringConsumer::ReadIntegerBase(), StringConsumer::ReadUntilChar(), StringConsumer::SKIP_ALL_SEPARATORS, strecpy(), TD_LTR, TD_RTL, LanguagePackHeader::text_dir, and LanguagePackHeader::winlangid.

## ◆ ParseFile()

void FileStringReader::ParseFile | ( |  | ) |
| inlineoverridevirtual

Start parsing the file.

Reimplemented from StringReader.

Definition at line 94 of file strgen.cpp.

References LanguagePackHeader::isocode, StrgenState::lang, LanguagePackHeader::name, LanguagePackHeader::own_name, and StringReader::ParseFile().

## ◆ ReadLine()

std::optional< std::string > FileStringReader::ReadLine | ( |  | ) |
| inlineoverridevirtual

Read a single line from the source of strings.

Returns
  The line, or std::nullopt if at the end of the file.

Implements StringReader.

Definition at line 85 of file strgen.cpp.

## Field Documentation

## ◆ input_stream

std::ifstream FileStringReader::input_stream

Definition at line 70 of file strgen.cpp.

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

- src/strgen/strgen.cpp