summaryrefslogtreecommitdiff
path: root/indra/llui/lltrans.h
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-10-17 16:56:21 +0300
committerGitHub <noreply@github.com>2024-10-17 16:56:21 +0300
commit0ef7a9b39cf72da1211039ab22bdf8f9f6a2c984 (patch)
tree6f51ef179497265b5bff2a355471ae5dc9643ad2 /indra/llui/lltrans.h
parent9e24b300d02e5627ea0d304d412cb683ec2de3a4 (diff)
parentd3d349ae0f17a72481f30b9354b9367b1cd3b639 (diff)
Merge pull request #2856 from secondlife/marchcat/c-develop
Develop → Maint C sync
Diffstat (limited to 'indra/llui/lltrans.h')
-rw-r--r--indra/llui/lltrans.h37
1 files changed, 17 insertions, 20 deletions
diff --git a/indra/llui/lltrans.h b/indra/llui/lltrans.h
index 4f38ef9067..c5d01e6f8d 100644
--- a/indra/llui/lltrans.h
+++ b/indra/llui/lltrans.h
@@ -30,10 +30,8 @@
#include <map>
#include <set>
-#include "llpointer.h"
#include "llstring.h"
-
-class LLXMLNode;
+#include "llxmlnode.h"
class LLSD;
@@ -58,17 +56,17 @@ public:
class LLTrans
{
public:
- LLTrans();
+ LLTrans() = default;
/**
* @brief Parses the xml root that holds the strings. Used once on startup
-// *FIXME * @param xml_filename Filename to parse
+ * @param root xml root node to parse
* @param default_args Set of strings (expected to be in the file) to use as default replacement args, e.g. "SECOND_LIFE"
* @returns true if the file was parsed successfully, true if something went wrong
*/
- static bool parseStrings(LLPointer<LLXMLNode> & root, const std::set<std::string>& default_args);
+ static bool parseStrings(LLXMLNodePtr& root, const std::set<std::string>& default_args);
- static bool parseLanguageStrings(LLPointer<LLXMLNode> & root);
+ static bool parseLanguageStrings(LLXMLNodePtr& root);
/**
* @brief Returns a translated string
@@ -76,41 +74,40 @@ public:
* @param args A list of substrings to replace in the string
* @returns Translated string
*/
- static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false);
- static std::string getDefString(const std::string &xml_desc, const LLStringUtil::format_map_t& args);
- static std::string getString(const std::string &xml_desc, const LLSD& args, bool def_string = false);
- static std::string getDefString(const std::string &xml_desc, const LLSD& args);
- static bool findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& args);
- static bool findString(std::string &result, const std::string &xml_desc, const LLSD& args);
+ static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false);
+ static std::string getDefString(std::string_view xml_desc, const LLStringUtil::format_map_t& args);
+ static std::string getString(std::string_view xml_desc, const LLSD& args, bool def_string = false);
+ static std::string getDefString(std::string_view xml_desc, const LLSD& args);
+ static bool findString(std::string& result, std::string_view xml_desc, const LLStringUtil::format_map_t& args);
+ static bool findString(std::string& result, std::string_view xml_desc, const LLSD& args);
// Returns translated string with [COUNT] replaced with a number, following
// special per-language logic for plural nouns. For example, some languages
// may have different plurals for 0, 1, 2 and > 2.
// See "AgeWeeksA", "AgeWeeksB", etc. in strings.xml for examples.
- static std::string getCountString(const std::string& language, const std::string& xml_desc, S32 count);
+ static std::string getCountString(std::string_view language, std::string_view xml_desc, S32 count);
/**
* @brief Returns a translated string
* @param xml_desc String's description
* @returns Translated string
*/
- static std::string getString(const std::string &xml_desc, bool def_string = false)
+ static std::string getString(std::string_view xml_desc, bool def_string = false)
{
LLStringUtil::format_map_t empty;
return getString(xml_desc, empty);
}
- static bool findString(std::string &result, const std::string &xml_desc)
+ static bool findString(std::string &result, std::string_view xml_desc)
{
LLStringUtil::format_map_t empty;
return findString(result, xml_desc, empty);
}
- static std::string getKeyboardString(const char* keystring)
+ static std::string getKeyboardString(const std::string_view keystring)
{
- std::string key_str(keystring);
std::string trans_str;
- return findString(trans_str, key_str) ? trans_str : key_str;
+ return findString(trans_str, keystring) ? trans_str : std::string(keystring);
}
// get the default args
@@ -128,7 +125,7 @@ public:
}
private:
- typedef std::map<std::string, LLTransTemplate > template_map_t;
+ typedef std::map<std::string, LLTransTemplate, std::less<>> template_map_t;
static template_map_t sStringTemplates;
static template_map_t sDefaultStringTemplates;
static LLStringUtil::format_map_t sDefaultArgs;