OpenTTD Source: StringReader Struct Reference

OpenTTD Source 12.0-beta1

Public Member Functions | Data Fields
StringReader Struct Referenceabstract

Helper for reading strings. More...

`#include <strgen.h>`

Inheritance diagram for StringReader:

## Public Member Functions
| StringReader (StringData &data, const char *file, bool master, bool translation)
| Prepare reading. More...
virtual | ~StringReader ()
| Make sure the right reader gets freed.
void | HandleString (char *str)
virtual char * | ReadLine (char *buffer, const char *last)=0
| Read a single line from the source of strings. More...
virtual void | HandlePragma (char *str)
| Handle the pragma of the file. More...
virtual void | ParseFile ()
| Start parsing the file.

## Data Fields
StringData & | data
| The data to fill during reading.
const char * | 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

Helper for reading strings.

Definition at line 60 of file strgen.h.

## Constructor & Destructor Documentation

## ◆ StringReader()

StringReader::StringReader | ( | StringData & | data,
|  | const char * | file,
|  | bool | master,
|  | bool | translation
| ) |  |

Prepare reading.

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 586 of file strgen_base.cpp.

## Member Function Documentation

## ◆ HandlePragma()

void StringReader::HandlePragma | ( | char * | str | ) |
| virtual

Handle the pragma of the file.

Parameters

  str | The pragma string to parse.

Reimplemented in FileStringReader.

Definition at line 797 of file strgen_base.cpp.

References _lang, _plural_forms, lengthof, and LanguagePackHeader::plural_form.

## ◆ ReadLine()

virtual char* StringReader::ReadLine | ( | char * | buffer,
|  | const char * | last
| ) |  |
| pure virtual

Read a single line from the source of strings.

Parameters

  buffer | The buffer to read the data in to.
  last | The last element in the buffer.

Returns
  The buffer, or nullptr if at the end of the file.

Implemented in StringListReader, and FileStringReader.

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

- src/strgen/strgen.h
- src/strgen/strgen_base.cpp