Skip to content

Commit

Permalink
Fix Visual Studio complaints in LLTrans
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansariel committed Sep 16, 2024
1 parent 2f38f06 commit 2c34a61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
20 changes: 6 additions & 14 deletions indra/llui/lltrans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"))
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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 = "";
Expand Down Expand Up @@ -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);
}

Expand Down
18 changes: 8 additions & 10 deletions indra/llui/lltrans.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
#include <map>
#include <set>

#include "llpointer.h"
#include "llstring.h"

class LLXMLNode;
#include "llxmlnode.h"

class LLSD;

Expand All @@ -58,17 +56,17 @@ class LLTransTemplate
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
Expand All @@ -80,14 +78,14 @@ class LLTrans
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
Expand Down

0 comments on commit 2c34a61

Please sign in to comment.