OpenTTD Source: src/strgen/strgen_base.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions | Variables
strgen_base.cpp File Reference

Tool to create computer readable (stand-alone) translation files. More...

`#include "../stdafx.h"`
`#include "../core/endian_func.hpp"`
`#include "../core/math_func.hpp"`
`#include "../error_func.h"`
`#include "../string_func.h"`
`#include "../core/string_builder.hpp"`
`#include "../table/control_codes.h"`
`#include "strgen.h"`
`#include "../table/strgen_tables.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | ParsedCommandString

## Functions
static ParsedCommandString | ParseCommandString (StringConsumer &consumer)
static size_t | TranslateArgumentIdx (size_t arg, size_t offset=0)
static uint32_t | VersionHashStr (uint32_t hash, std::string_view s)
| Create a compound hash.
void | EmitSingleChar (StringBuilder &builder, std::string_view param, char32_t value)
static std::pair< std::optional< size_t >, std::optional< size_t > > | ParseRelNum (StringConsumer &consumer)
std::optional< std::string_view > | ParseWord (StringConsumer &consumer)
static void | EmitWordList (StringBuilder &builder, const std::vector< std::string > &words)
void | EmitPlural (StringBuilder &builder, std::string_view param, char32_t)
void | EmitGender (StringBuilder &builder, std::string_view param, char32_t)
static const CmdStruct * | FindCmd (std::string_view s)
static uint8_t | ResolveCaseName (std::string_view str)
ParsedCommandStruct | ExtractCommandString (std::string_view s, bool)
const CmdStruct * | TranslateCmdForCompare (const CmdStruct *a)
static bool | CheckCommandsMatch (std::string_view a, std::string_view b, std::string_view name)
static void | PutArgidxCommand (StringBuilder &builder)
static std::string | PutCommandString (std::string_view str)

## Variables
StrgenState | _strgen
static bool | _translated
| Whether the current language is not the master language.
static std::string_view | _cur_ident
static ParsedCommandStruct | _cur_pcs
static size_t | _cur_argidx

## Detailed Description

Tool to create computer readable (stand-alone) translation files.

Definition in file strgen_base.cpp.

## Function Documentation

## ◆ CheckCommandsMatch()

static bool CheckCommandsMatch | ( | std::string_view | a,
|  | std::string_view | b,
|  | std::string_view | name
| ) |  |
| static

Definition at line 430 of file strgen_base.cpp.

## ◆ EmitGender()

void EmitGender | ( | StringBuilder & | builder,
|  | std::string_view | param,
|  | char32_t | value
| ) |  |

Definition at line 275 of file strgen_base.cpp.

## ◆ EmitPlural()

void EmitPlural | ( | StringBuilder & | builder,
|  | std::string_view | param,
|  | char32_t | value
| ) |  |

Definition at line 220 of file strgen_base.cpp.

## ◆ EmitSingleChar()

void EmitSingleChar | ( | StringBuilder & | builder,
|  | std::string_view | param,
|  | char32_t | value
| ) |  |

Definition at line 167 of file strgen_base.cpp.

## ◆ EmitWordList()

static void EmitWordList | ( | StringBuilder & | builder,
|  | const std::vector< std::string > & | words
| ) |  |
| static

Definition at line 207 of file strgen_base.cpp.

## ◆ ExtractCommandString()

ParsedCommandStruct ExtractCommandString | ( | std::string_view | s,
|  | bool | warnings
| ) |  |

Definition at line 383 of file strgen_base.cpp.

## ◆ FindCmd()

static const CmdStruct * FindCmd | ( | std::string_view | s | ) |
| static

Definition at line 314 of file strgen_base.cpp.

## ◆ ParseCommandString()

static ParsedCommandString ParseCommandString | ( | StringConsumer & | consumer | ) |
| static

Definition at line 329 of file strgen_base.cpp.

## ◆ ParseRelNum()

static std::pair< std::optional< size_t >, std::optional< size_t > > ParseRelNum | ( | StringConsumer & | consumer | ) |
| static

Definition at line 175 of file strgen_base.cpp.

## ◆ ParseWord()

std::optional< std::string_view > ParseWord | ( | StringConsumer & | consumer | ) |

Definition at line 189 of file strgen_base.cpp.

## ◆ PutArgidxCommand()

static void PutArgidxCommand | ( | StringBuilder & | builder | ) |
| static

Definition at line 643 of file strgen_base.cpp.

## ◆ PutCommandString()

static std::string PutCommandString | ( | std::string_view | str | ) |
| static

Definition at line 649 of file strgen_base.cpp.

## ◆ ResolveCaseName()

static uint8_t ResolveCaseName | ( | std::string_view | str | ) |
| static

Definition at line 321 of file strgen_base.cpp.

## ◆ TranslateArgumentIdx()

static size_t TranslateArgumentIdx | ( | size_t | arg,
|  | size_t | offset = `0`
| ) |  |
| static

Definition at line 617 of file strgen_base.cpp.

## ◆ TranslateCmdForCompare()

const CmdStruct * TranslateCmdForCompare | ( | const CmdStruct * | a | ) |

Definition at line 412 of file strgen_base.cpp.

## ◆ VersionHashStr()

static uint32_t VersionHashStr | ( | uint32_t | hash,
|  | std::string_view | s
| ) |  |
| static

Create a compound hash.

Parameters

  hash | The hash to add the string hash to.
  s | The string hash.

Returns
  The new hash.

Definition at line 117 of file strgen_base.cpp.

Referenced by StringData::Version().

## Variable Documentation

## ◆ _cur_argidx

size_t _cur_argidx
| static

Definition at line 28 of file strgen_base.cpp.

## ◆ _cur_ident

std::string_view _cur_ident
| static

Definition at line 26 of file strgen_base.cpp.

## ◆ _cur_pcs

ParsedCommandStruct _cur_pcs
| static

Definition at line 27 of file strgen_base.cpp.

## ◆ _strgen

StrgenState _strgen

Definition at line 24 of file strgen_base.cpp.

## ◆ _translated

bool _translated
| static

Whether the current language is not the master language.

Definition at line 25 of file strgen_base.cpp.

Referenced by LanguageWriter::WriteLang().