Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Visual Studio complaints in LLTrans #2575

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions indra/newview/tests/lldateutil_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) ];
}
Expand Down
Loading