OpenTTD Source: LanguageWriter Struct Reference

OpenTTD Source 15.0-RC2

Public Member Functions
LanguageWriter Struct Referenceabstract

Base class for all language writers. More...

`#include <strgen.h>`

Inheritance diagram for LanguageWriter:

## Public Member Functions
virtual void | WriteHeader (const LanguagePackHeader *header)=0
| Write the header metadata.
virtual void | Write (std::string_view buffer)=0
| Write a number of bytes.
virtual void | Finalise ()=0
| Finalise writing the file.
virtual | ~LanguageWriter ()=default
| Especially destroy the subclasses.
virtual void | WriteLength (size_t length)
| Write the length as a simple gamma.
virtual void | WriteLang (const StringData &data)
| Actually write the language.

## Detailed Description

Base class for all language writers.

Definition at line 109 of file strgen.h.

## Member Function Documentation

## ◆ Finalise()

virtual void LanguageWriter::Finalise | ( |  | ) |
| pure virtual

Finalise writing the file.

Implemented in TranslationWriter, and LanguageFileWriter.

## ◆ Write()

virtual void LanguageWriter::Write | ( | std::string_view | buffer | ) |
| pure virtual

Write a number of bytes.

Parameters

  buffer | The buffer to write.

Implemented in TranslationWriter, and LanguageFileWriter.

Referenced by WriteLang(), and WriteLength().

## ◆ WriteHeader()

virtual void LanguageWriter::WriteHeader | ( | const LanguagePackHeader * | header | ) |
| pure virtual

Write the header metadata.

The multi-byte integers are already converted to the little endian format.

Parameters

  header | The header to write.

Implemented in TranslationWriter, and LanguageFileWriter.

Referenced by WriteLang().

## ◆ WriteLang()

void LanguageWriter::WriteLang | ( | const StringData & | data | ) |
| virtual

Actually write the language.

Parameters

  data | The data about the string.

Definition at line 713 of file strgen_base.cpp.

References _translated, StringData::CountInUse(), StrgenState::cur_line, LangString::english, LanguagePackHeader::IDENT, LanguagePackHeader::ident, StrgenState::lang, LangString::line, LanguagePackHeader::missing, LangString::name, LanguagePackHeader::offsets, BaseStringBuilder::Put(), BaseStringBuilder::PutUint16LE(), BaseStringBuilder::PutUint8(), BaseStringBuilder::PutUtf8(), StringData::strings, TAB_SIZE, StringData::tabs, LangString::translated, LangString::translated_cases, LanguagePackHeader::version, StringData::Version(), LanguagePackHeader::winlangid, Write(), WriteHeader(), and WriteLength().

Referenced by GameStrings::Compile().

## ◆ WriteLength()

void LanguageWriter::WriteLength | ( | size_t | length | ) |
| virtual

Write the length as a simple gamma.

Parameters

  length | The number to write.

Reimplemented in TranslationWriter.

Definition at line 694 of file strgen_base.cpp.

References Write().

Referenced by WriteLang().

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

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