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

OpenTTD Source 15.0-beta1

Data Structures | Functions | Variables
strgen_base.cpp File Reference

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

`#include "../stdafx.h"`
`#include "../core/alloc_func.hpp"`
`#include "../core/endian_func.hpp"`
`#include "../core/mem_func.hpp"`
`#include "../error_func.h"`
`#include "../string_func.h"`
`#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 | Buffer
| The buffer for writing a single string. More...

## Functions
static const CmdStruct * | ParseCommandString (const char **str, std::string &param, int *argno, int *casei)
size_t | Utf8Validate (const char *s)
void | EmitSingleChar (Buffer *buffer, char *buf, int value)
bool | ParseRelNum (char **buf, int *value, int *offset)
char * | ParseWord (char **buf)
static int | TranslateArgumentIdx (int arg, int offset=0)
static void | EmitWordList (Buffer *buffer, const std::vector< const char * > &words, uint nw)
void | EmitPlural (Buffer *buffer, char *buf, int)
void | EmitGender (Buffer *buffer, char *buf, int)
static const CmdStruct * | FindCmd (const char *s, int len)
static uint | ResolveCaseName (const char *str, size_t len)
ParsedCommandStruct | ExtractCommandString (const char *s, bool)
const CmdStruct * | TranslateCmdForCompare (const CmdStruct *a)
static bool | CheckCommandsMatch (const char *a, const char *b, const char *name)
static void | StripTrailingWhitespace (std::string &str)
static void | PutArgidxCommand (Buffer *buffer)
static void | PutCommandString (Buffer *buffer, const char *str)

## Variables
static bool | _translated
| Whether the current language is not the master language.
static bool | _translation
| Is the current file actually a translation or not.
const char * | _file = "(unknown file)"
| The filename of the input, so we can refer to it in errors/warnings.
int | _cur_line
| The current line we're parsing in the input file.
int | _errors
int | _warnings
int | _show_todo
LanguagePackHeader | _lang
| Header information about a language.
static const char * | _cur_ident
static ParsedCommandStruct | _cur_pcs
static int | _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 | ( | const char * | a,
|  | const char * | b,
|  | const char * | name
| ) |  |
| static

Definition at line 589 of file strgen_base.cpp.

## ◆ EmitGender()

void EmitGender | ( | Buffer * | buffer,
|  | char * | buf,
|  | int | value
| ) |  |

Definition at line 386 of file strgen_base.cpp.

## ◆ EmitPlural()

void EmitPlural | ( | Buffer * | buffer,
|  | char * | buf,
|  | int | value
| ) |  |

Definition at line 334 of file strgen_base.cpp.

## ◆ EmitSingleChar()

void EmitSingleChar | ( | Buffer * | buffer,
|  | char * | buf,
|  | int | value
| ) |  |

Definition at line 238 of file strgen_base.cpp.

## ◆ EmitWordList()

static void EmitWordList | ( | Buffer * | buffer,
|  | const std::vector< const char * > & | words,
|  | uint | nw
| ) |  |
| static

Definition at line 317 of file strgen_base.cpp.

## ◆ ExtractCommandString()

ParsedCommandStruct ExtractCommandString | ( | const char * | s,
|  | bool | warnings
| ) |  |

Definition at line 537 of file strgen_base.cpp.

## ◆ FindCmd()

static const CmdStruct * FindCmd | ( | const char * | s,
|  | int | len
| ) |  |
| static

Definition at line 427 of file strgen_base.cpp.

## ◆ ParseCommandString()

static const CmdStruct * ParseCommandString | ( | const char ** | str,
|  | std::string & | param,
|  | int * | argno,
|  | int * | casei
| ) |  |
| static

Definition at line 451 of file strgen_base.cpp.

## ◆ ParseRelNum()

bool ParseRelNum | ( | char ** | buf,
|  | int * | value,
|  | int * | offset
| ) |  |

Definition at line 251 of file strgen_base.cpp.

## ◆ ParseWord()

char * ParseWord | ( | char ** | buf | ) |

Definition at line 280 of file strgen_base.cpp.

## ◆ PutArgidxCommand()

static void PutArgidxCommand | ( | Buffer * | buffer | ) |
| static

Definition at line 824 of file strgen_base.cpp.

## ◆ PutCommandString()

static void PutCommandString | ( | Buffer * | buffer,
|  | const char * | str
| ) |  |
| static

Definition at line 831 of file strgen_base.cpp.

## ◆ ResolveCaseName()

static uint ResolveCaseName | ( | const char * | str,
|  | size_t | len
| ) |  |
| static

Definition at line 435 of file strgen_base.cpp.

## ◆ StripTrailingWhitespace()

static void StripTrailingWhitespace | ( | std::string & | str | ) |
| static

Definition at line 745 of file strgen_base.cpp.

## ◆ TranslateArgumentIdx()

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

Definition at line 799 of file strgen_base.cpp.

## ◆ TranslateCmdForCompare()

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

Definition at line 570 of file strgen_base.cpp.

## ◆ Utf8Validate()

size_t Utf8Validate | ( | const char * | s | ) |

Definition at line 213 of file strgen_base.cpp.

## Variable Documentation

## ◆ _cur_argidx

int _cur_argidx
| static

Definition at line 174 of file strgen_base.cpp.

## ◆ _cur_ident

const char* _cur_ident
| static

Definition at line 170 of file strgen_base.cpp.

## ◆ _cur_line

int _cur_line

The current line we're parsing in the input file.

Definition at line 30 of file strgen_base.cpp.

Referenced by FatalErrorI(), StringReader::ParseFile(), and LanguageWriter::WriteLang().

## ◆ _cur_pcs

ParsedCommandStruct _cur_pcs
| static

Definition at line 173 of file strgen_base.cpp.

## ◆ _errors

int _errors

Definition at line 31 of file strgen_base.cpp.

## ◆ _file

const char* _file = "(unknown file)"

The filename of the input, so we can refer to it in errors/warnings.

Definition at line 29 of file strgen_base.cpp.

Referenced by FatalErrorI(), and StringReader::ParseFile().

## ◆ _lang

LanguagePackHeader _lang

Header information about a language.

Definition at line 32 of file strgen_base.cpp.

Referenced by StringReader::HandlePragma(), FileStringReader::HandlePragma(), StringReader::ParseFile(), FileStringReader::ParseFile(), and LanguageWriter::WriteLang().

## ◆ _show_todo

int _show_todo

Definition at line 31 of file strgen_base.cpp.

## ◆ _translated

bool _translated
| static

Whether the current language is not the master language.

Definition at line 27 of file strgen_base.cpp.

Referenced by LanguageWriter::WriteLang().

## ◆ _translation

bool _translation
| static

Is the current file actually a translation or not.

Definition at line 28 of file strgen_base.cpp.

Referenced by StringReader::ParseFile().

## ◆ _warnings

int _warnings

Definition at line 31 of file strgen_base.cpp.