The Battle for Wesnoth  1.15.3+dev
Functions
lua_stringx Namespace Reference

Functions

static int intf_format (lua_State *L)
 Formats a message by interpolating WML variable syntax Arg 1: (optional) Logger Arg 2: Message. More...
 
template<bool conjunct>
static int intf_format_list (lua_State *L)
 Formats a list into human-readable format Arg 1: default value, used if the list is empty Arg 2: list of strings. More...
 
static int impl_str_index (lua_State *L)
 Enables indexing a string by an integer, while also treating the stringx module as its metatable.__index. More...
 
static int intf_str_split (lua_State *L)
 Splits a string into parts according to options Arg 1: String to split Arg 2: Separator Arg 3: Options table. More...
 
static int intf_str_paren_split (lua_State *L)
 Splits a string into parenthesized portions and portions between parenthesized portions Arg 1: String to split Arg 2: Possible left parentheses Arg 3: Matching right parentheses. More...
 
static int intf_str_map_split (lua_State *L)
 Splits a string into a map Arg 1: string to split Arg 2: Separator for items Arg 3: Separator for key and value. More...
 
static int intf_str_join (lua_State *L)
 Joins a list into a string; calls __tostring and __index metamethods Arg 1: list to join Arg 2: separator (arguments can be swapped) More...
 
static int intf_str_join_map (lua_State *L)
 Joins a map into a string; calls __tostring metamethods (on both key and value) but not __index Arg 1: list to join Arg 2: separator for items Arg 3: separator for key and value (list argument can be swapped to any position) More...
 
static int intf_str_trim (lua_State *L)
 Trims whitespace from the beginning and end of a string. More...
 
static int intf_str_format (lua_State *L)
 
static int intf_parse_range (lua_State *L)
 Parses a range string of the form a-b into an interval pair Accepts the string "infinity" as representing a Very Large Number. More...
 
int luaW_open (lua_State *L)
 

Function Documentation

◆ impl_str_index()

static int lua_stringx::impl_str_index ( lua_State L)
static

Enables indexing a string by an integer, while also treating the stringx module as its metatable.__index.

Definition at line 66 of file lua_stringx.cpp.

References lua_call, lua_getglobal(), lua_gettable(), lua_pushvalue(), LUA_TNUMBER, LUA_TSTRING, lua_type(), and luaW_getglobal().

Referenced by luaW_open().

◆ intf_format()

static int lua_stringx::intf_format ( lua_State L)
static

Formats a message by interpolating WML variable syntax Arg 1: (optional) Logger Arg 2: Message.

Definition at line 35 of file lua_stringx.cpp.

References utils::interpolate_variables_into_string(), utils::interpolate_variables_into_tstring(), lua_isstring(), lua_push(), lua_tostring, luaW_checkconfig(), luaW_checktstring(), str, and mariadb::value::string.

Referenced by luaW_open().

◆ intf_format_list()

template<bool conjunct>
static int lua_stringx::intf_format_list ( lua_State L)
static

Formats a list into human-readable format Arg 1: default value, used if the list is empty Arg 2: list of strings.

Definition at line 55 of file lua_stringx.cpp.

References utils::format_conjunct_list(), utils::format_disjunct_list(), lua_push(), and luaW_checktstring().

◆ intf_parse_range()

static int lua_stringx::intf_parse_range ( lua_State L)
static

Parses a range string of the form a-b into an interval pair Accepts the string "infinity" as representing a Very Large Number.

Definition at line 323 of file lua_stringx.cpp.

References lua_pushnumber(), luaL_checkstring, utils::parse_range(), str, and mariadb::value::string.

Referenced by luaW_open().

◆ intf_str_format()

static int lua_stringx::intf_str_format ( lua_State L)
static

◆ intf_str_join()

static int lua_stringx::intf_str_join ( lua_State L)
static

Joins a list into a string; calls __tostring and __index metamethods Arg 1: list to join Arg 2: separator (arguments can be swapped)

Definition at line 221 of file lua_stringx.cpp.

References i, utils::join(), lua_call, lua_getglobal(), lua_geti(), lua_istable, lua_push(), luaL_checkstring, luaL_error(), luaL_len(), luaL_optstring, and mariadb::value::string.

Referenced by luaW_open().

◆ intf_str_join_map()

static int lua_stringx::intf_str_join_map ( lua_State L)
static

Joins a map into a string; calls __tostring metamethods (on both key and value) but not __index Arg 1: list to join Arg 2: separator for items Arg 3: separator for key and value (list argument can be swapped to any position)

Definition at line 251 of file lua_stringx.cpp.

References utils::join_map(), lua_absindex(), lua_call, lua_getglobal(), lua_istable, lua_next(), lua_push(), lua_pushnil(), lua_pushvalue(), lua_settop(), luaL_checkstring, luaL_error(), luaL_optstring, and mariadb::value::string.

Referenced by luaW_open().

◆ intf_str_map_split()

static int lua_stringx::intf_str_map_split ( lua_State L)
static

Splits a string into a map Arg 1: string to split Arg 2: Separator for items Arg 3: Separator for key and value.

Definition at line 186 of file lua_stringx.cpp.

References lua_istable, lua_push(), luaL_checkstring, luaL_error(), luaL_optstring, luaW_table_get_def(), luaW_tableget(), utils::map_split(), utils::REMOVE_EMPTY, str, mariadb::value::string, and utils::STRIP_SPACES.

Referenced by luaW_open().

◆ intf_str_paren_split()

static int lua_stringx::intf_str_paren_split ( lua_State L)
static

Splits a string into parenthesized portions and portions between parenthesized portions Arg 1: String to split Arg 2: Possible left parentheses Arg 3: Matching right parentheses.

Definition at line 167 of file lua_stringx.cpp.

References left, lua_push(), luaL_checkstring, luaL_error(), luaL_opt, luaL_optstring, luaW_toboolean(), utils::parenthetical_split(), right, str, mariadb::value::string, and utils::STRIP_SPACES.

Referenced by luaW_open().

◆ intf_str_split()

static int lua_stringx::intf_str_split ( lua_State L)
static

Splits a string into parts according to options Arg 1: String to split Arg 2: Separator Arg 3: Options table.

Definition at line 92 of file lua_stringx.cpp.

References left, lua_istable, lua_push(), luaL_checkstring, luaL_error(), luaL_optstring, luaW_table_get_def(), luaW_tableget(), utils::parenthetical_split(), utils::quoted_split(), utils::REMOVE_EMPTY, right, utils::split(), utils::square_parenthetical_split(), str, mariadb::value::string, and utils::STRIP_SPACES.

Referenced by luaW_open().

◆ intf_str_trim()

static int lua_stringx::intf_str_trim ( lua_State L)
static

Trims whitespace from the beginning and end of a string.

Definition at line 290 of file lua_stringx.cpp.

References lua_pushlstring(), luaL_checkstring, str, mariadb::value::string, and utils::trim().

Referenced by luaW_open().

◆ luaW_open()

int lua_stringx::luaW_open ( lua_State L)