summaryrefslogtreecommitdiff
path: root/indra/llcommon/llstring.h
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2024-05-08 23:32:58 +0200
committerAndrew Meadows <andrew.l.meadows@gmail.com>2024-10-03 09:02:09 -0700
commit2daf175650cdda7cc8f820b6cb17b1475496e7ac (patch)
tree0ece9bb592a922fbcb3f4532aee10941e307f44f /indra/llcommon/llstring.h
parentec39ac89e8529da206dafd519d75ad5944888076 (diff)
Add GameControl UI for per device settings
Diffstat (limited to 'indra/llcommon/llstring.h')
-rw-r--r--indra/llcommon/llstring.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index d65fb16f5b..7d0806b22e 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -214,6 +214,9 @@ public:
static std::string getDatetimeCode (std::string key);
+ static void splitString(const std::string& text, char delimiter,
+ std::function<void(const std::string&)> handler);
+
// Express a value like 1234567 as "1.23M"
static std::string getReadableNumber(F64 num);
};
@@ -443,6 +446,65 @@ public:
static bool isPartOfWord(T c) { return (c == (T)'_') || LLStringOps::isAlnum(c); }
+ // Join non-empty strings from values using value itself and delimiter
+ template<class C>
+ static std::string join(const C& values, T delimiter = ',')
+ {
+ std::string result;
+ for (const std::string& value : values)
+ {
+ if (!value.empty())
+ {
+ if (!result.empty())
+ {
+ result += delimiter;
+ }
+ result += value;
+ }
+ }
+ return result;
+ }
+
+ // Join non-empty strings from values using stringify(value) and delimiter
+ template<class C, class V>
+ static std::string join(const C& values, std::function<std::string(const V&)> stringify, T delimiter = ',')
+ {
+ std::string result;
+ for (const V& value : values)
+ {
+ std::string string = stringify(value);
+ if (!string.empty())
+ {
+ if (!result.empty())
+ {
+ result += delimiter;
+ }
+ result += string;
+ }
+ }
+ return result;
+ }
+
+ // Join non-empty strings from values using stringify(index, value) and delimiter
+ template<class C, class V>
+ static std::string join(const C& values, std::function<std::string(size_t index, const V&)> stringify, T delimiter = ',')
+ {
+ std::string result;
+ for (size_t i = 0; i < values.size(); ++i)
+ {
+ std::string string = stringify(i, values[i]);
+ if (!string.empty())
+ {
+ if (!result.empty())
+ {
+ result += delimiter;
+ }
+ result += string;
+ }
+ }
+ return result;
+ }
+
#ifdef _DEBUG
LL_COMMON_API static void testHarness();
#endif