#include "irrlichttypes_bloated.h"
#include "config.h"
#include <cstdlib>
#include <string>
#include <string_view>
#include <cstring>
#include <vector>
#include <limits>
#include <sstream>
#include <iomanip>
#include <cctype>
#include <cwctype>
#include <unordered_map>
Go to the source code of this file.
Classes | |
struct | FlagDesc |
Macros | |
#define | STRINGIFY(x) #x |
#define | TOSTRING(x) STRINGIFY(x) |
#define | IS_ASCII_PRINTABLE_CHAR(x) |
#define | IS_PRIVATE_USE_CHAR16(x) |
#define | IS_PRIVATE_USE_CHAR32(x) |
#define | IS_PRIVATE_USE_CHAR(x) IS_PRIVATE_USE_CHAR16(x) |
#define | IS_UTF8_MULTB_INNER(x) |
#define | IS_UTF8_MULTB_START(x) |
#define | UTF8_MULTB_START_LEN(x) |
#define | MAKE_VARIANT(_name, _t0, _t1) |
#define | stoi mystoi |
#define | stof mystof |
Typedefs | |
typedef std::unordered_map< std::string, std::string > | StringMap |
Functions | |
std::wstring | utf8_to_wide (std::string_view input) |
std::string | wide_to_utf8 (std::wstring_view input) |
void | wide_add_codepoint (std::wstring &result, char32_t codepoint) |
std::string | urlencode (std::string_view str) |
std::string | urldecode (std::string_view str) |
u32 | readFlagString (std::string str, const FlagDesc *flagdesc, u32 *flagmask) |
std::string | writeFlagString (u32 flags, const FlagDesc *flagdesc, u32 flagmask) |
size_t | mystrlcpy (char *dst, const char *src, size_t size) noexcept |
char * | mystrtok_r (char *s, const char *sep, char **lasts) noexcept |
u64 | read_seed (const char *str) |
bool | parseColorString (const std::string &value, video::SColor &color, bool quiet, unsigned char default_alpha=0xff) |
std::string | encodeHexColorString (video::SColor color) |
char | my_tolower (char c) |
Converts a letter to lowercase, with safe handling of the char type and non-ASCII. | |
std::string | padStringRight (std::string str, size_t len) |
Returns a copy of str with spaces inserted at the right hand side to ensure that the string is len characters in length. | |
std::string_view | removeStringEnd (std::string_view str, const char *ends[]) |
Returns a version of str with the first occurrence of a string contained within ends[] removed from the end of the string. | |
template<typename T > | |
bool | str_equal (std::basic_string_view< T > s1, std::basic_string_view< T > s2, bool case_insensitive=false) |
Check two strings for equivalence. | |
template<typename T > | |
bool | str_starts_with (std::basic_string_view< T > str, std::basic_string_view< T > prefix, bool case_insensitive=false) |
Check whether str begins with the string prefix. | |
template<typename T > | |
bool | str_ends_with (std::basic_string_view< T > str, std::basic_string_view< T > suffix, bool case_insensitive=false) |
Check whether str ends with the string suffix. | |
template<typename T > | |
std::vector< std::basic_string< T > > | str_split (const std::basic_string< T > &str, T delimiter) |
Splits a string into its component parts separated by the character delimiter . | |
std::string | lowercase (std::string_view str) |
bool | my_isspace (const char c) |
bool | my_isspace (const wchar_t c) |
template<typename T > | |
std::basic_string_view< T > | trim (const std::basic_string_view< T > &str) |
template<typename T > | |
std::basic_string< T > | trim (std::basic_string< T > &&str) |
template<typename T > | |
std::basic_string_view< T > | trim (const std::basic_string< T > &str) |
template<typename T > | |
std::basic_string_view< T > | trim (const T *str) |
bool | is_yes (std::string_view str) |
Returns whether str should be regarded as (bool) true. | |
s32 | mystoi (const std::string &str, s32 min, s32 max) |
Converts the string str to a signed 32-bit integer. | |
s32 | mystoi (const std::string &str) |
Returns a 32-bit value reprensented by the string str (decimal). | |
float | mystof (const std::string &str) |
Returns a float reprensented by the string str (decimal). | |
template<typename T > | |
T | from_string (const std::string &str) |
Returns a value represented by the string val . | |
s64 | stoi64 (const std::string &str) |
Returns a 64-bit signed value represented by the string str (decimal). | |
std::string | itos (s32 i) |
Returns a string representing the decimal value of the 32-bit value i . | |
std::string | i64tos (s64 i) |
Returns a string representing the decimal value of the 64-bit value i . | |
std::string | ftos (float f) |
Returns a string representing the exact decimal value of the float value f . | |
void | str_replace (std::string &str, std::string_view pattern, std::string_view replacement) |
Replace all occurrences of pattern in str with replacement . | |
void | str_formspec_escape (std::string &str) |
Escapes characters that cannot be used in formspecs. | |
void | str_replace (std::string &str, char from, char to) |
Replace all occurrences of the character from in str with to . | |
bool | string_allowed (std::string_view str, std::string_view allowed_chars) |
Check that a string only contains whitelisted characters. | |
bool | string_allowed_blacklist (std::string_view str, std::string_view blacklisted_chars) |
Check that a string contains no blacklisted characters. | |
std::string | wrap_rows (std::string_view from, unsigned row_len, bool has_color_codes=false) |
Create a string based on from where a newline is forcefully inserted every row_len characters. | |
template<typename T > | |
std::basic_string< T > | unescape_string (const std::basic_string< T > &s) |
Removes backslashes from an escaped string (FormSpec strings) | |
template<typename T > | |
std::basic_string< T > | unescape_enriched (const std::basic_string< T > &s) |
Remove all escape sequences in s . | |
template<typename T > | |
std::vector< std::basic_string< T > > | split (const std::basic_string< T > &s, T delim) |
std::wstring | translate_string (std::wstring_view s, Translations *translations) |
std::wstring | translate_string (std::wstring_view s) |
std::wstring | unescape_translate (std::wstring_view s) |
bool | is_number (std::string_view to_check) |
Checks that all characters in to_check are a decimal digits. | |
const char * | bool_to_cstr (bool val) |
Returns a C-string, either "true" or "false", corresponding to val . | |
const std::string | duration_to_string (int sec) |
Converts a duration in seconds to a pretty-printed duration in days, hours, minutes and seconds. | |
std::string | str_join (const std::vector< std::string > &list, std::string_view delimiter) |
Joins a vector of strings by the string delimiter . | |
std::string | sanitizeDirName (std::string_view str, std::string_view optional_prefix) |
Sanitize the name of a new directory. | |
std::string | sanitize_untrusted (std::string_view str, bool keep_escapes=true) |
Sanitize an untrusted string (e.g. | |
void | safe_print_string (std::ostream &os, std::string_view str) |
Prints a sanitized version of a string without control characters. | |
v3f | str_to_v3f (std::string_view str) |
Parses a string of form (1, 2, 3) to a v3f. | |
#define IS_ASCII_PRINTABLE_CHAR | ( | x | ) |
Referenced by safe_print_string(), and TestUtilities::testAsciiPrintableHelper().
#define IS_PRIVATE_USE_CHAR | ( | x | ) | IS_PRIVATE_USE_CHAR16(x) |
Referenced by GUIChatConsole::OnEvent().
#define IS_PRIVATE_USE_CHAR16 | ( | x | ) |
#define IS_PRIVATE_USE_CHAR32 | ( | x | ) |
#define IS_UTF8_MULTB_INNER | ( | x | ) |
Referenced by safe_print_string(), and wrap_rows().
#define IS_UTF8_MULTB_START | ( | x | ) |
Referenced by safe_print_string().
#define MAKE_VARIANT | ( | _name, | |
_t0, | |||
_t1 ) |
#define stof mystof |
Referenced by WearBarParams::deserializeJson(), GUIFormSpecMenu::getElementBasePos(), Settings::getFloat(), Settings::getFloat(), StyleSpec::getFont(), Settings::getNoiseParamsFromValue(), GUIFormSpecMenu::getRealCoordinateBasePos(), GUIFormSpecMenu::getRealCoordinateGeometry(), getToolRange(), Settings::getV2F(), GUIFormSpecMenu::parseAnchor(), GUIFormSpecMenu::parseAnimatedImage(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBox(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseContainer(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseImage(), GUIFormSpecMenu::parseImageButton(), GUIFormSpecMenu::parseItemImage(), GUIFormSpecMenu::parseItemImageButton(), GUIFormSpecMenu::parseLabel(), GUIFormSpecMenu::parseModel(), GUIFormSpecMenu::parsePadding(), GUIFormSpecMenu::parsePosition(), GUIFormSpecMenu::parsePwdField(), GUIFormSpecMenu::parseScrollBar(), GUIFormSpecMenu::parseScrollContainer(), GUIFormSpecMenu::parseSize(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextArea(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::parseTooltip(), StyleSpec::parseVector2f(), GUITable::setTable(), and str_to_v3f().
#define stoi mystoi |
Referenced by ICraftAction::ICraftAction(), IDropAction::IDropAction(), IMoveAction::IMoveAction(), TextureOverrideSource::TextureOverrideSource(), InventoryLocation::deSerialize(), ItemStack::deSerialize(), drawItemStack(), ImageSource::generateImagePart(), Settings::getFlagStr(), StyleSpec::getFont(), StyleSpec::getIntArray(), Settings::getNoiseParamsFromValue(), Settings::getS16(), Settings::getS32(), Settings::getU16(), Settings::getU32(), ParsedText::globalTag(), MetaDataRef::l_get_int(), ModApiMapgen::l_get_mapgen_edges(), ModApiMapgen::l_get_mapgen_params(), ClientLauncher::launch_game(), GUIFormSpecMenu::parseAnimatedImage(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseList(), GUIFormSpecMenu::parseMiddleRect(), GUIFormSpecMenu::parseModel(), StyleSpec::parseRect(), GUIFormSpecMenu::parseScrollBar(), GUIFormSpecMenu::parseScrollBarOptions(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextList(), and GUITable::setTable().
#define STRINGIFY | ( | x | ) | #x |
#define TOSTRING | ( | x | ) | STRINGIFY(x) |
#define UTF8_MULTB_START_LEN | ( | x | ) |
typedef std::unordered_map<std::string, std::string> StringMap |
|
inline |
Returns a C-string, either "true" or "false", corresponding to val
.
val
is true, then "true" is returned, otherwise "false". Referenced by set_default_settings(), Game::toggleAutoforward(), Game::toggleCinematic(), Game::toggleFast(), Game::toggleFreeMove(), Game::toggleNoClip(), and Game::togglePitchMove().
|
inline |
Converts a duration in seconds to a pretty-printed duration in days, hours, minutes and seconds.
sec | duration in seconds |
Referenced by Server::ShutdownState::getShutdownTimerMessage(), Server::getStatusString(), and Server::requestShutdown().
std::string encodeHexColorString | ( | video::SColor | color | ) |
References hex_encode().
Referenced by WearBarParams::serializeJson().
|
inline |
Returns a value represented by the string val
.
Referenced by Settings::getU64(), ModApiMapgen::l_get_mapgen_params(), LBMManager::loadIntroductionTimes(), and stoi64().
|
inline |
Returns a string representing the exact decimal value of the float value f
.
Referenced by content_nodemeta_deserialize_legacy_body(), QuicktuneValue::getString(), WearBarParams::serializeJson(), and Settings::setFloat().
|
inline |
Returns a string representing the decimal value of the 64-bit value i
.
Referenced by Database_LevelDB::deleteBlock(), Database_Redis::deleteBlock(), Database_LevelDB::loadBlock(), Database_Redis::loadBlock(), Database_LevelDB::saveBlock(), and Database_Redis::saveBlock().
|
inline |
Checks that all characters in to_check
are a decimal digits.
to_check |
Referenced by ImageSource::generateImagePart(), GUIFormSpecMenu::parseVersionDirect(), and TestUtilities::testIsNumber().
|
inline |
Returns whether str
should be regarded as (bool) true.
Case and leading and trailing whitespace are ignored. Values that will return true are "y", "yes", "true" and any number that is not 0.
str |
References lowercase(), and trim().
Referenced by ModConfiguration::addModsFromConfig(), Settings::getBool(), StyleSpec::getBool(), ModApiUtil::Initialize(), ModApiUtil::InitializeAsync(), ModApiUtil::InitializeClient(), ModApiUtil::l_is_yes(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBackgroundColor(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseFieldCloseOnEnter(), GUIFormSpecMenu::parseFieldEnterAfterEdit(), ParsedText::parseGenericStyleAttr(), GUIFormSpecMenu::parseModel(), GUIFormSpecMenu::parseRealCoordinates(), GUIFormSpecMenu::parseSetFocus(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::regenerateGui(), ParsedText::Element::setStyle(), GUITable::setTable(), Game::shouldShowTouchControls(), and TestUtilities::testIsYes().
|
inline |
Returns a string representing the decimal value of the 32-bit value i
.
Referenced by EmergeThread::EmergeThread(), GUIFormSpecMenu::acceptInput(), RollbackManager::actionRowsFromSelect(), AsyncEngine::addWorkerThread(), analyze_block(), MapBlockMesh::animate(), Game::decreaseViewRange(), NodeMetadataList::deSerialize(), deSerializeString32(), drawItemStack(), con::Connection::getDesc(), GenerateNotifier::getEvents(), Server::getPlayerName(), Game::increaseViewRange(), con::UDPPeer::isTimedOut(), ModApiItem::l_register_item_raw(), MetaDataRef::l_set_int(), ClientLauncher::launch_game(), PlayerDatabaseFiles::loadPlayer(), Client::makeScreenshot(), SettingsHierarchy::onLayerCreated(), Database_SQLite3::openDatabase(), Settings::parseCommandLine(), con::ConnectionReceiveThread::processPacket(), PlayerDatabaseFiles::removePlayer(), fs::safeWriteToFile(), PlayerDatabaseFiles::savePlayer(), script_error(), Settings::setS16(), Settings::setS32(), Settings::setU16(), RollbackAction::toString(), GameUI::update(), and ShadowRenderer::updateSMTextures().
|
inline |
str |
str
converted to all lowercase characters. References my_tolower().
Referenced by ScriptApiSecurity::checkPathWithGamedef(), gen_srp_v(), init_gettext(), is_yes(), main(), parseImageTransform(), parseNamedColorString(), JoystickController::setLayoutFromControllerName(), Client::startAuth(), and TestUtilities::testLowercase().
|
inline |
|
inline |
|
inline |
Converts a letter to lowercase, with safe handling of the char type and non-ASCII.
c | input letter |
Referenced by lowercase(), fs::PathStartsWith(), str_ends_with(), str_equal(), and str_starts_with().
|
inline |
Returns a float reprensented by the string str
(decimal).
|
inline |
Returns a 32-bit value reprensented by the string str
(decimal).
|
inline |
Converts the string str
to a signed 32-bit integer.
The converted value is constrained so that min <= value <= max.
str | |
min | Range minimum |
max | Range maximum |
Referenced by ImageSource::generateImagePart(), Game::nodePlacement(), GUIFormSpecMenu::parseVersionDirect(), and TestUtilities::testStrToIntConversion().
|
noexcept |
References MYMIN.
|
noexcept |
|
inline |
Returns a copy of str
with spaces inserted at the right hand side to ensure that the string is len
characters in length.
If str
is <= len
then the returned string will be identical to str.
Referenced by print_allowed_options(), and TestUtilities::testPadString().
bool parseColorString | ( | const std::string & | value, |
video::SColor & | color, | ||
bool | quiet, | ||
unsigned char | default_alpha = 0xff ) |
References errorstream, parseHexColorString(), and parseNamedColorString().
Referenced by ChatBuffer::ChatBuffer(), EnrichedString::addAtEnd(), check_color(), WearBarParams::deserializeJson(), ImageSource::generateImagePart(), StyleSpec::getColor(), StyleSpec::getColor(), StyleSpec::getColorArray(), ParsedText::globalTag(), GUIFormSpecMenu::parseBackgroundColor(), GUIFormSpecMenu::parseBox(), GUIFormSpecMenu::parseListColors(), GUIFormSpecMenu::parseTooltip(), read_color(), ParsedText::Element::setStyle(), GUITable::setTable(), and GUITable::setTextList().
u64 read_seed | ( | const char * | str | ) |
References murmur_hash_64_ua().
Referenced by MapgenParams::readParams().
u32 readFlagString | ( | std::string | str, |
const FlagDesc * | flagdesc, | ||
u32 * | flagmask ) |
References FlagDesc::flag, and FlagDesc::name.
Referenced by Settings::getFlagStr(), read_flags(), and TestSettings::testFlagDesc().
|
inline |
Returns a version of str
with the first occurrence of a string contained within ends[] removed from the end of the string.
str | |
ends | A NULL- or ""- terminated array of strings to remove from s in the copy produced. Note that once one of these strings is removed that no further postfixes contained within this array are removed. |
References p().
Referenced by Server::addMediaFile(), porting::detectMSVCBuildDir(), getAvailableGameIds(), Translations::getFileLanguage(), getImagePath(), Client::loadMedia(), Translations::loadTranslation(), and TestUtilities::testRemoveStringEnd().
void safe_print_string | ( | std::ostream & | os, |
std::string_view | str ) |
Prints a sanitized version of a string without control characters.
'\t' and '
' are allowed, as are UTF-8 control characters (e.g. RTL). ASCII control characters are replaced with their hex encoding in angle brackets (e.g. "a\x1eb" -> "a<1e>b").
References IS_ASCII_PRINTABLE_CHAR, IS_UTF8_MULTB_INNER, and IS_UTF8_MULTB_START.
Referenced by HTTPFetchOngoing::complete(), and IMetadata::resolveString().
|
nodiscard |
Sanitize an untrusted string (e.g.
from the network). This will get strip control characters and (optionally) any MT-style escape sequences too. Note that they won't be removed cleanly but rather just broken, unlike with unescape_enriched. Line breaks and UTF-8 is permitted.
References remove_indexed().
Referenced by pkt_read_formspec_fields(), and TestUtilities::testSanitizeUntrusted().
std::string sanitizeDirName | ( | std::string_view | str, |
std::string_view | optional_prefix ) |
Sanitize the name of a new directory.
This consists of two stages:
References disallowed_dir_names, disallowed_path_chars, str_equal(), utf8_to_wide(), and wide_to_utf8().
Referenced by ModApiMainMenu::l_create_world(), and TestUtilities::testSanitizeDirName().
std::vector< std::basic_string< T > > split | ( | const std::basic_string< T > & | s, |
T | delim ) |
Referenced by EnrichedString::addAtEnd(), StyleSpec::getFont(), GUIFormSpecMenu::parseAnchor(), GUIFormSpecMenu::parseAnchorDirect(), GUIFormSpecMenu::parseAnimatedImage(), StyleSpec::parseArray(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBox(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseContainer(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseImage(), GUIFormSpecMenu::parseImageButton(), GUIFormSpecMenu::parseItemImage(), GUIFormSpecMenu::parseItemImageButton(), GUIFormSpecMenu::parseLabel(), GUIFormSpecMenu::parseList(), GUIFormSpecMenu::parseListRing(), GUIFormSpecMenu::parseMiddleRect(), GUIFormSpecMenu::parseModel(), GUIFormSpecMenu::parsePadding(), GUIFormSpecMenu::parsePaddingDirect(), GUIFormSpecMenu::parsePosition(), GUIFormSpecMenu::parsePositionDirect(), GUIFormSpecMenu::parsePwdField(), StyleSpec::parseRect(), GUIFormSpecMenu::parseScrollBar(), GUIFormSpecMenu::parseScrollBarOptions(), GUIFormSpecMenu::parseScrollContainer(), GUIFormSpecMenu::parseSize(), GUIFormSpecMenu::parseSizeDirect(), GUIFormSpecMenu::parseStyle(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTableColumns(), GUIFormSpecMenu::parseTableOptions(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextArea(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::parseTooltip(), StyleSpec::parseVector2f(), GUIFormSpecMenu::parseVersionDirect(), GUIFormSpecMenu::parseVertLabel(), GUIFormSpecMenu::precheckElement(), GUIFormSpecMenu::regenerateGui(), translate_all(), and translate_string().
|
inline |
Returns a 64-bit signed value represented by the string str
(decimal).
References from_string().
Referenced by Database_LevelDB::listAllLoadableBlocks(), and Database_Redis::listAllLoadableBlocks().
|
inline |
Check whether str
ends with the string suffix.
If case_insensitive
is true then the check is case insensitve (default is false; i.e. case is significant).
str | |
suffix | |
case_insensitive |
References my_tolower().
Referenced by ImageSource::generateImagePart(), GettextPluralForm::parseHeaderLine(), Server::sendMediaAnnouncement(), and TestUtilities::testSanitizeUntrusted().
|
inline |
Check two strings for equivalence.
If case_insensitive
is true then the case of the strings is ignored (default is false).
s1 | |
s2 | |
case_insensitive |
References my_tolower().
Referenced by ChatPrompt::nickCompletion(), sanitizeDirName(), and TestUtilities::testStrEqual().
|
inline |
Escapes characters that cannot be used in formspecs.
References str_replace().
Referenced by Game::showPauseMenu().
|
inline |
Joins a vector of strings by the string delimiter
.
Referenced by TestAuthDatabase::testListNames(), TestAuthDatabase::testRecall(), TestAuthDatabase::testRecallChanged(), TestAuthDatabase::testRecallChangedPrivileges(), TestUtilities::testStringJoin(), and AuthDatabaseFiles::writeAuthFile().
void str_replace | ( | std::string & | str, |
char | from, | ||
char | to ) |
Replace all occurrences of the character from
in str
with to
.
str | The string to (potentially) modify. |
from | The character in str to replace. |
to | The replacement character. |
Referenced by ImageSource::generateImagePart(), Client::initLocalMapSaving(), and TestUtilities::testStringReplace().
|
inline |
Replace all occurrences of pattern
in str
with replacement
.
str | String to replace pattern with replacement within. |
pattern | The pattern to replace. |
replacement | What to replace the pattern with. |
Referenced by str_formspec_escape().
|
inline |
Splits a string into its component parts separated by the character delimiter
.
Referenced by sound::ALExtensions::ALExtensions(), TextureOverrideSource::TextureOverrideSource(), checkModNameWhitelisted(), decode_srp_verifier_and_salt(), Server::handleCommand_Init(), LBMManager::loadIntroductionTimes(), Translations::loadMoEntry(), Translations::loadMoTranslation(), Translations::loadPoTranslation(), Translations::loadTranslation(), Translations::loadTrTranslation(), parseModContents(), and AuthDatabaseFiles::readAuthFile().
|
inline |
Check whether str
begins with the string prefix.
If case_insensitive
is true then the check is case insensitve (default is false; i.e. case is significant).
str | |
prefix | |
case_insensitive |
References my_tolower().
Referenced by checkModNameWhitelisted(), ImageSource::generateImagePart(), NodeDefManager::getIds(), NodeResolver::getIdsFromNrBacklog(), isGroupRecipeStr(), Translations::loadMoTranslation(), Translations::loadPoTranslation(), Translations::loadTrTranslation(), main(), ChatPrompt::nickCompletion(), porting::open_url(), GettextPluralForm::parseHeaderLine(), read_pointabilities(), reduce_ltr(), IMetadata::resolveString(), TileDef::serialize(), RemoteClient::setEncryptedPassword(), TestUtilities::testSanitizeUntrusted(), and TestUtilities::testStartsWith().
v3f str_to_v3f | ( | std::string_view | str | ) |
Parses a string of form (1, 2, 3)
to a v3f.
str | string |
References BasicStrfnd< T >::next(), and stof.
Referenced by Settings::getV3F(), and ItemStack::getWieldScale().
|
inline |
Check that a string only contains whitelisted characters.
This is the opposite of string_allowed_blacklist().
str | The string to be checked. |
allowed_chars | A string containing permitted characters. |
Referenced by ClientMediaDownloader::addFile(), LBMManager::addLBMDef(), Server::addMediaFile(), ModSpec::checkAndLog(), Server::handleCommand_Init(), Client::handleCommand_MediaPush(), is_valid_player_name(), parseDependsString(), GUITable::setTable(), and TestUtilities::testStringAllowed().
|
inline |
Check that a string contains no blacklisted characters.
This is the opposite of string_allowed().
str | The string to be checked. |
blacklisted_chars | A string containing prohibited characters. |
Referenced by TestUtilities::testStringAllowed().
std::wstring translate_string | ( | std::wstring_view | s | ) |
std::wstring translate_string | ( | std::wstring_view | s, |
Translations * | translations ) |
References translate_all().
Referenced by unescape_translate().
|
inline |
|
inline |
str |
str
with leading and trailing whitespace removed. References my_isspace().
Referenced by sound::ALExtensions::ALExtensions(), TextureOverrideSource::TextureOverrideSource(), ItemStack::deSerialize(), Server::handleChat(), Client::handleCommand_AnnounceMedia(), is_yes(), BanManager::load(), Translations::loadTrTranslation(), parse_atomic(), parse_expr(), parse_ltr(), parse_negation(), parse_parenthesized(), parse_ternary(), GUIFormSpecMenu::parseAnchorDirect(), Settings::parseConfigObject(), parseDependsString(), GUIFormSpecMenu::parseElement(), GUIFormSpecMenu::parsePaddingDirect(), Translations::parsePoLine(), GUIFormSpecMenu::parsePositionDirect(), GUIFormSpecMenu::parseScrollBarOptions(), GUIFormSpecMenu::parseSizeDirect(), GUIFormSpecMenu::parseStyle(), GUIFormSpecMenu::parseVersionDirect(), fs::RecursiveDeleteContent(), reduce_ltr(), GUIFormSpecMenu::regenerateGui(), TestUtilities::testTrim(), trim(), trim(), and trim().
|
inline |
|
inline |
str |
str
with leading and trailing whitespace removed. References trim().
std::basic_string< T > unescape_enriched | ( | const std::basic_string< T > & | s | ) |
Remove all escape sequences in s
.
s | The string in which to remove escape sequences. |
s
, with escape sequences removed. Referenced by drawItemStack(), Server::handleChat(), TestUtilities::testRemoveEscapes(), and unescape_translate().
|
inline |
Removes backslashes from an escaped string (FormSpec strings)
|
inline |
References translate_string(), and unescape_enriched().
Referenced by Hud::drawLuaElements(), Camera::drawNametags(), Game::handlePointingAtNode(), Game::handlePointingAtObject(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextList(), and GUIFormSpecMenu::parseVertLabel().
std::string urldecode | ( | std::string_view | str | ) |
References hex_digit_decode().
Referenced by TestUtilities::testUrlDecode().
std::string urlencode | ( | std::string_view | str | ) |
Referenced by HTTPFetchOngoing::HTTPFetchOngoing(), ModApiUtil::Initialize(), ModApiUtil::InitializeAsync(), ModApiUtil::InitializeClient(), ModApiUtil::l_urlencode(), and TestUtilities::testUrlEncode().
std::wstring utf8_to_wide | ( | std::string_view | input | ) |
References convert(), DEFAULT_ENCODING, hex_encode(), and infostream.
Referenced by GUITable::allocString(), Game::createClient(), ProfilerGraph::draw(), drawItemStack(), Hud::drawLuaElements(), GUIFormSpecMenu::drawMenu(), Camera::drawNametags(), Game::getServerContent(), FontEngine::getTextWidth(), FontEngine::getTextWidth(), Server::handleChat(), Game::handlePointingAtNode(), Game::handlePointingAtObject(), GameUI::init(), ModApiServer::l_chat_send_all(), ModApiServer::l_chat_send_player(), ModApiClient::l_display_chat_message(), ModApiMainMenu::l_get_content_translation(), ModApiEnv::l_get_translated_string(), ModApiClient::l_send_chat_message(), Translations::loadMoEntry(), Translations::loadMoTranslation(), Translations::loadPoTranslation(), Translations::loadTrTranslation(), Client::makeScreenshot(), ChatPrompt::nickCompletion(), GUIChatConsole::OnEvent(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseImageButton(), GUIFormSpecMenu::parseItemImageButton(), GUIFormSpecMenu::parseLabel(), Translations::parsePoLine(), GUIFormSpecMenu::parsePwdField(), GUIFormSpecMenu::parseSimpleField(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextArea(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::parseTooltip(), GUIFormSpecMenu::parseVertLabel(), Server::printToConsoleOnly(), Game::processKeyInput(), GUIOpenURLMenu::regenerateGui(), Server::requestShutdown(), ClientLauncher::run(), sanitizeDirName(), GUIEngine::setTopleftText(), TestUtilities::testStrEqual(), TestUtilities::testUTF8(), TestUtilities::testWrapRows(), Game::toggleMinimap(), GameUI::update(), Game::updateChat(), GameUI::updateProfiler(), GUIChatConsole::weblinkClick(), and wstrgettext().
void wide_add_codepoint | ( | std::wstring & | result, |
char32_t | codepoint ) |
std::string wide_to_utf8 | ( | std::wstring_view | input | ) |
References convert(), DEFAULT_ENCODING, hex_encode(), and infostream.
Referenced by GUIFileSelectMenu::acceptInput(), GUIFormSpecMenu::acceptInput(), EnrichedString::addAtEnd(), ChatBuffer::formatChatLine(), TextDestGuiEngine::gotText(), TextDestNodeMetadata::gotText(), Server::handleChat(), Client::handleCommand_AccessDenied(), Client::handleCommand_ChatMessage(), ModApiMainMenu::l_get_content_translation(), ModApiEnv::l_get_translated_string(), Translations::loadPoEntry(), Translations::loadPoTranslation(), GUIChatConsole::OnEvent(), GUIFormSpecMenu::parseTable(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextList(), GUIModalMenu::preprocessEvent(), GUIPasswordChange::processInput(), sanitizeDirName(), TestUtilities::testUTF8(), Server::ShutdownState::tick(), translate_string(), Client::typeChatMessage(), Translations::unescapeC(), and GUIChatConsole::updatePrimarySelection().
std::string wrap_rows | ( | std::string_view | from, |
unsigned | row_len, | ||
bool | has_color_codes = false ) |
Create a string based on from
where a newline is forcefully inserted every row_len
characters.
row_len
characters whether it breaks a word or not. It is intended to be used for, for example, showing paths in the GUI.from | The (utf-8) string to be wrapped into rows. |
row_len | The row length (in characters). |
has_color_codes | Whether the source string has colorize codes. |
References IS_UTF8_MULTB_INNER.
Referenced by GUIOpenURLMenu::regenerateGui(), and TestUtilities::testWrapRows().
std::string writeFlagString | ( | u32 | flags, |
const FlagDesc * | flagdesc, | ||
u32 | flagmask ) |
References FlagDesc::name.
Referenced by push_flags_string(), Settings::setDefault(), and Settings::setFlagStr().