OpenTTD Source 15.0-beta2
strgen_base.cpp File Reference

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

Go to the source code of this file.

Data Structures

struct  ParsedCommandString
 

Functions

static ParsedCommandString ParseCommandString (const char **str)
 
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.
 
static size_t Utf8Validate (const char *s)
 
void EmitSingleChar (StringBuilder &builder, const char *buf, char32_t value)
 
static std::pair< std::optional< size_t >, std::optional< size_t > > ParseRelNum (const char **buf)
 
std::optional< std::string_view > ParseWord (const char **buf)
 
static void EmitWordList (StringBuilder &builder, const std::vector< std::string > &words)
 
void EmitPlural (StringBuilder &builder, const char *buf, char32_t)
 
void EmitGender (StringBuilder &builder, const char *buf, char32_t)
 
static const CmdStruct * FindCmd (std::string_view s)
 
static uint8_t ResolveCaseName (std::string_view str)
 
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 (StringBuilder &builder)
 
static std::string PutCommandString (const char *str)
 

Variables

StrgenState _strgen
 
static bool _translated
 Whether the current language is not the master language.
 
static const char * _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 ( const char *  a,
const char *  b,
const char *  name 
)
static

Definition at line 502 of file strgen_base.cpp.

◆ EmitGender()

void EmitGender ( StringBuilder &  builder,
const char *  buf,
char32_t  value 
)

Definition at line 318 of file strgen_base.cpp.

◆ EmitPlural()

void EmitPlural ( StringBuilder &  builder,
const char *  buf,
char32_t  value 
)

Definition at line 265 of file strgen_base.cpp.

◆ EmitSingleChar()

void EmitSingleChar ( StringBuilder &  builder,
const char *  buf,
char32_t  value 
)

Definition at line 191 of file strgen_base.cpp.

◆ EmitWordList()

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

Definition at line 252 of file strgen_base.cpp.

◆ ExtractCommandString()

ParsedCommandStruct ExtractCommandString ( const char *  s,
bool  warnings 
)

Definition at line 456 of file strgen_base.cpp.

◆ FindCmd()

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

Definition at line 357 of file strgen_base.cpp.

◆ ParseCommandString()

static ParsedCommandString ParseCommandString ( const char **  str)
static

Definition at line 373 of file strgen_base.cpp.

◆ ParseRelNum()

static std::pair< std::optional< size_t >, std::optional< size_t > > ParseRelNum ( const char **  buf)
static

Definition at line 199 of file strgen_base.cpp.

◆ ParseWord()

std::optional< std::string_view > ParseWord ( const char **  buf)

Definition at line 219 of file strgen_base.cpp.

◆ PutArgidxCommand()

static void PutArgidxCommand ( StringBuilder &  builder)
static

Definition at line 732 of file strgen_base.cpp.

◆ PutCommandString()

static std::string PutCommandString ( const char *  str)
static

Definition at line 738 of file strgen_base.cpp.

◆ ResolveCaseName()

static uint8_t ResolveCaseName ( std::string_view  str)
static

Definition at line 365 of file strgen_base.cpp.

◆ StripTrailingWhitespace()

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

Definition at line 658 of file strgen_base.cpp.

◆ TranslateArgumentIdx()

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

Definition at line 708 of file strgen_base.cpp.

◆ TranslateCmdForCompare()

const CmdStruct * TranslateCmdForCompare ( const CmdStruct *  a)

Definition at line 484 of file strgen_base.cpp.

◆ Utf8Validate()

static size_t Utf8Validate ( const char *  s)
static

Definition at line 167 of file strgen_base.cpp.

◆ VersionHashStr()

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

Create a compound hash.

Parameters
hashThe hash to add the string hash to.
sThe 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

const char* _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().