Fix Visual Studio complaints in LLTrans (#2575)

master
Ansariel Hiller 2024-09-17 02:10:24 +02:00 committed by GitHub
parent 486613e79b
commit f378d2f95a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 26 deletions

View File

@ -28,12 +28,8 @@
#include "lltrans.h"
#include "llfasttimer.h" // for call count statistics
#include "llxuiparser.h"
#include "llsd.h"
#include "llxmlnode.h"
#include <map>
LLTrans::template_map_t LLTrans::sStringTemplates;
LLTrans::template_map_t LLTrans::sDefaultStringTemplates;
@ -59,7 +55,7 @@ struct StringTable : public LLInitParam::Block<StringTable>
};
//static
bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& default_args)
bool LLTrans::parseStrings(LLXMLNodePtr& root, const std::set<std::string>& default_args)
{
std::string xml_filename = "(strings file)";
if (!root->hasName("strings"))
@ -107,7 +103,7 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa
//static
bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root)
bool LLTrans::parseLanguageStrings(LLXMLNodePtr& root)
{
std::string xml_filename = "(language strings file)";
if (!root->hasName("strings"))
@ -138,10 +134,6 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root)
return true;
}
static LLTrace::BlockTimerStatHandle FTM_GET_TRANS("Translate string");
//static
std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string)
{
@ -235,7 +227,7 @@ std::string LLTrans::getDefString(std::string_view xml_desc, const LLSD& msg_arg
}
//static
bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args)
bool LLTrans::findString(std::string& result, std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
@ -257,7 +249,7 @@ bool LLTrans::findString(std::string &result, std::string_view xml_desc, const L
}
//static
bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLSD& msg_args)
bool LLTrans::findString(std::string& result, std::string_view xml_desc, const LLSD& msg_args)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
@ -277,7 +269,7 @@ bool LLTrans::findString(std::string &result, std::string_view xml_desc, const L
}
//static
std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count)
std::string LLTrans::getCountString(std::string_view language, std::string_view xml_desc, S32 count)
{
// Compute which string identifier to use
const char* form = "";
@ -337,7 +329,7 @@ std::string LLTrans::getCountString(const std::string& language, const std::stri
args["[COUNT]"] = llformat("%d", count);
// Look up "AgeYearsB" or "AgeWeeksC" including the "form"
std::string key = llformat("%s%s", xml_desc.c_str(), form);
std::string key = llformat("%s%s", xml_desc.data(), form);
return getString(key, args);
}

View File

@ -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
@ -80,14 +78,14 @@ public:
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);
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

View File

@ -57,12 +57,12 @@ std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUt
return {};
}
std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count)
std::string LLTrans::getCountString(std::string_view language, std::string_view xml_desc, S32 count)
{
count_string_t key(xml_desc, count);
if (gCountString.find(key) == gCountString.end())
{
return std::string("Couldn't find ") + xml_desc;
return std::string("Couldn't find ") + static_cast<std::string>(xml_desc);
}
return gCountString[ count_string_t(xml_desc, count) ];
}