diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp index bae969a8474fb890edea6c010b101f282422a3a3..9faaddeef5c178a27a500ede6d788ad372f4f67b 100644 --- a/indra/llcharacter/llcharacter.cpp +++ b/indra/llcharacter/llcharacter.cpp @@ -265,15 +265,23 @@ void LLCharacter::dumpCharacter( LLJoint* joint ) //----------------------------------------------------------------------------- void LLCharacter::setAnimationData(const std::string& name, void *data) { - mAnimationData[name] = data; + mAnimationData.insert_or_assign(name, data); } //----------------------------------------------------------------------------- // getAnimationData() //----------------------------------------------------------------------------- -void* LLCharacter::getAnimationData(const std::string& name) +void* LLCharacter::getAnimationData(const std::string_view name) { - return get_if_there(mAnimationData, name, (void*)NULL); + auto iter = mAnimationData.find(name); + if (iter == mAnimationData.end()) + { + return nullptr; + } + else + { + return iter->second; + } } //----------------------------------------------------------------------------- diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index 680f1d9328009c38c75e53fcc9b4794f4d1dba36..1fe9c90665646b8ad235c390631ee3255c226f65 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -185,7 +185,7 @@ class LLCharacter void setAnimationData(const std::string& name, void *data); - void *getAnimationData(const std::string& name); + void *getAnimationData(const std::string_view name); void removeAnimationData(const std::string& name); diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp index 09578608c8f18ce51c2def35490a93e64da738dd..a8f586b734d86bd93db43894620fc9845bd4a514 100644 --- a/indra/llcommon/llassettype.cpp +++ b/indra/llcommon/llassettype.cpp @@ -104,11 +104,10 @@ LLAssetDictionary::LLAssetDictionary() const std::string LLAssetType::BADLOOKUP("llassettype_bad_lookup"); // static -LLAssetType::EType LLAssetType::getType(const std::string& desc_name) +LLAssetType::EType LLAssetType::getType(std::string desc_name) { - std::string s = desc_name; - LLStringUtil::toUpper(s); - return LLAssetDictionary::getInstance()->lookup(s); + LLStringUtil::toUpper(desc_name); + return LLAssetDictionary::getInstance()->lookup(desc_name); } // static @@ -143,21 +142,21 @@ const char *LLAssetType::lookup(LLAssetType::EType asset_type) // static LLAssetType::EType LLAssetType::lookup(const char* name) { - return lookup(ll_safe_string(name)); + return lookup(absl::NullSafeStringView(name)); } // static -LLAssetType::EType LLAssetType::lookup(const std::string& type_name) +LLAssetType::EType LLAssetType::lookup(const std::string_view type_name) { - const LLAssetDictionary *dict = LLAssetDictionary::getInstance(); - for (LLAssetDictionary::const_iterator iter = dict->begin(); - iter != dict->end(); - iter++) + if(type_name.empty()) return AT_UNKNOWN; + + const LLAssetDictionary& dict = LLAssetDictionary::instance(); + for (const auto& dict_pair : dict) { - const AssetEntry *entry = iter->second; + const AssetEntry *entry = dict_pair.second; if (type_name == entry->mTypeName) { - return iter->first; + return dict_pair.first; } } return AT_UNKNOWN; @@ -181,21 +180,19 @@ const char *LLAssetType::lookupHumanReadable(LLAssetType::EType asset_type) // static LLAssetType::EType LLAssetType::lookupHumanReadable(const char* name) { - return lookupHumanReadable(ll_safe_string(name)); + return lookupHumanReadable(absl::NullSafeStringView(name)); } // static -LLAssetType::EType LLAssetType::lookupHumanReadable(const std::string& readable_name) +LLAssetType::EType LLAssetType::lookupHumanReadable(const std::string_view readable_name) { - const LLAssetDictionary *dict = LLAssetDictionary::getInstance(); - for (LLAssetDictionary::const_iterator iter = dict->begin(); - iter != dict->end(); - iter++) + const LLAssetDictionary& dict = LLAssetDictionary::instance(); + for (const auto& dict_pair : dict) { - const AssetEntry *entry = iter->second; + const AssetEntry *entry = dict_pair.second; if (entry->mHumanName && (readable_name == entry->mHumanName)) { - return iter->first; + return dict_pair.first; } } return AT_NONE; diff --git a/indra/llcommon/llassettype.h b/indra/llcommon/llassettype.h index e1b524ce6870a6ed898c0431cc39053b5ac76c9c..13a454a9eb3ac91faf49e8c3c7ede3a0662524ca 100644 --- a/indra/llcommon/llassettype.h +++ b/indra/llcommon/llassettype.h @@ -145,15 +145,15 @@ class LL_COMMON_API LLAssetType // machine transation between type and strings static EType lookup(const char* name); // safe conversion to std::string, *TODO: deprecate - static EType lookup(const std::string& type_name); + static EType lookup(const std::string_view type_name); static const char* lookup(EType asset_type); // translation from a type to a human readable form. static EType lookupHumanReadable(const char* desc_name); // safe conversion to std::string, *TODO: deprecate - static EType lookupHumanReadable(const std::string& readable_name); + static EType lookupHumanReadable(const std::string_view readable_name); static const char* lookupHumanReadable(EType asset_type); - static EType getType(const std::string& desc_name); + static EType getType(std::string desc_name); static const std::string& getDesc(EType asset_type); static bool lookupCanLink(EType asset_type); diff --git a/indra/llcommon/llcallstack.h b/indra/llcommon/llcallstack.h index 63a3ea10a57cbb4d3aa3675f550b9ceab700b290..663b77eb991eb8ce4b1b4251ddba27a77e0e54a4 100644 --- a/indra/llcommon/llcallstack.h +++ b/indra/llcommon/llcallstack.h @@ -58,8 +58,8 @@ class LLContextStrings class LLScopedContextString { public: - LLScopedContextString(const std::string& str): - m_str(str) + LLScopedContextString(const std::string str): + m_str(std::move(str)) { LLContextStrings::addContextString(m_str); } diff --git a/indra/llcommon/lldictionary.h b/indra/llcommon/lldictionary.h index d56865ab077af73b33469899e4fdf7ff836ef24b..a4dbe43f41752bc9cf448f52b056bbce217fac02 100644 --- a/indra/llcommon/lldictionary.h +++ b/indra/llcommon/lldictionary.h @@ -61,7 +61,7 @@ class LLDictionary : public std::map<Index, Entry *> if (dictionary_iter == map_t::end()) return NULL; return dictionary_iter->second; } - const Index lookup(const std::string &name) const + const Index lookup(const std::string_view name) const { for (const_iterator_t dictionary_iter = map_t::begin(); dictionary_iter != map_t::end(); diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 0e318676329ed3072e15fe2558f5577136cecbf9..4244e102ae64b8b002cabce3cebfef08feb5eb29 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -44,6 +44,7 @@ # include <io.h> #endif // !LL_WINDOWS #include <vector> +#include <string_view> #include "string.h" #include <absl/container/flat_hash_map.h> @@ -316,7 +317,7 @@ namespace namespace LLError { - std::string Log::demangle(const char* mangled) + std::string Log::demangle(const std::string_view mangled) { #ifdef __GNUC__ // GCC: type_info::name() returns a mangled class name,st demangle @@ -329,21 +330,25 @@ namespace LLError return result; #elif LL_WINDOWS + using namespace std::literals; // Visual Studio: type_info::name() includes the text "class " at the start - std::string name = mangled; - for (const auto& prefix : std::vector<std::string>{ "class ", "struct " }) + static constexpr auto class_prefix = "class "sv; + static constexpr auto struct_prefix = "struct "sv; + if (0 == mangled.compare(0, class_prefix.length(), class_prefix)) { - if (0 == name.compare(0, prefix.length(), prefix)) - { - return name.substr(prefix.length()); - } + return std::string(mangled.substr(class_prefix.length())); } + else if (0 == mangled.compare(0, struct_prefix.length(), struct_prefix)) + { + return std::string(mangled.substr(struct_prefix.length())); + } + // huh, that's odd, we should see one or the other prefix -- but don't // try to log unless logging is already initialized // in Python, " or ".join(vector) -- but in C++, a PITB LL_DEBUGS() << "Did not see 'class' or 'struct' prefix on '" - << name << "'" << LL_ENDL; - return name; + << mangled << "'" << LL_ENDL; + return std::string(mangled); #else // neither GCC nor Visual Studio return mangled; diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h index 5905e14f179550a151be327d3f8f7793584c5bcc..2598b41e103494ecb015f9212db307b8af006c76 100644 --- a/indra/llcommon/llerror.h +++ b/indra/llcommon/llerror.h @@ -203,7 +203,7 @@ namespace LLError static std::ostringstream* out(); static void flush(std::ostringstream* out, char* message); static void flush(std::ostringstream*, const CallSite&); - static std::string demangle(const char* mangled); + static std::string demangle(const std::string_view mangled); /// classname<TYPE>() template <typename T> static std::string classname() { return demangle(typeid(T).name()); } diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index d5b657d7ce15cbfe4c16e6ce3e1badd0d61238eb..01ea04b09982c3055baa629bb25ff39edbeacaa4 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -130,19 +130,19 @@ class LLSD::Impl virtual const String& asStringRef() const { static const std::string empty; return empty; } - virtual bool has(const String&) const { return false; } - virtual LLSD get(const String&) const { return LLSD(); } + virtual bool has(const std::string_view) const { return false; } + virtual LLSD get(const std::string_view) const { return LLSD(); } virtual LLSD getKeys() const { return LLSD::emptyArray(); } virtual void erase(const String&) { } - virtual const LLSD& ref(const String&) const{ return undef(); } + virtual const LLSD& ref(const std::string_view) const{ return undef(); } virtual int size() const { return 0; } virtual LLSD get(Integer) const { return LLSD(); } virtual void erase(Integer) { } virtual const LLSD& ref(Integer) const { return undef(); } - virtual const std::map<String, LLSD>& map() const { static const std::map<String, LLSD> empty; return empty; } - virtual std::map<String, LLSD>& map() { static std::map<String, LLSD> empty; return empty; } + virtual const LLSD::map_t& map() const { static const LLSD::map_t empty; return empty; } + virtual LLSD::map_t& map() { static LLSD::map_t empty; return empty; } LLSD::map_const_iterator beginMap() const { return endMap(); } LLSD::map_const_iterator endMap() const { return map().end(); } virtual const std::vector<LLSD>& array() const { static const std::vector<LLSD> empty; return empty; } @@ -364,7 +364,7 @@ namespace class ImplMap : public LLSD::Impl { private: - typedef std::map<LLSD::String, LLSD> DataMap; + typedef LLSD::map_t DataMap; DataMap mData; @@ -380,17 +380,17 @@ namespace virtual LLSD::Boolean asBoolean() const { return !mData.empty(); } - virtual bool has(const LLSD::String&) const; + virtual bool has(const std::string_view) const; using LLSD::Impl::get; // Unhiding get(LLSD::Integer) using LLSD::Impl::erase; // Unhiding erase(LLSD::Integer) using LLSD::Impl::ref; // Unhiding ref(LLSD::Integer) - virtual LLSD get(const LLSD::String&) const; + virtual LLSD get(const std::string_view) const; virtual LLSD getKeys() const; void insert(const LLSD::String& k, const LLSD& v); virtual void erase(const LLSD::String&); - LLSD& ref(const LLSD::String&); - virtual const LLSD& ref(const LLSD::String&) const; + LLSD& ref(const std::string_view); + virtual const LLSD& ref(const std::string_view) const; virtual int size() const { return mData.size(); } @@ -415,13 +415,13 @@ namespace } } - bool ImplMap::has(const LLSD::String& k) const + bool ImplMap::has(const std::string_view k) const { DataMap::const_iterator i = mData.find(k); return i != mData.end(); } - LLSD ImplMap::get(const LLSD::String& k) const + LLSD ImplMap::get(const std::string_view k) const { DataMap::const_iterator i = mData.find(k); return (i != mData.end()) ? i->second : LLSD(); @@ -449,12 +449,18 @@ namespace mData.erase(k); } - LLSD& ImplMap::ref(const LLSD::String& k) + LLSD& ImplMap::ref(const std::string_view k) { - return mData[k]; + DataMap::iterator i = mData.find(k); + if (i == mData.end()) + { + return mData.emplace(k, LLSD()).first->second; + } + + return i->second; } - const LLSD& ImplMap::ref(const LLSD::String& k) const + const LLSD& ImplMap::ref(const std::string_view k) const { DataMap::const_iterator i = mData.find(k); if (i == mData.end()) @@ -874,8 +880,8 @@ LLSD LLSD::emptyMap() return v; } -bool LLSD::has(const String& k) const { return safe(impl).has(k); } -LLSD LLSD::get(const String& k) const { return safe(impl).get(k); } +bool LLSD::has(const std::string_view k) const { return safe(impl).has(k); } +LLSD LLSD::get(const std::string_view k) const { return safe(impl).get(k); } LLSD LLSD::getKeys() const { return safe(impl).getKeys(); } void LLSD::insert(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); } @@ -886,9 +892,9 @@ LLSD& LLSD::with(const String& k, const LLSD& v) } void LLSD::erase(const String& k) { makeMap(impl).erase(k); } -LLSD& LLSD::operator[](const String& k) +LLSD& LLSD::operator[](const std::string_view k) { return makeMap(impl).ref(k); } -const LLSD& LLSD::operator[](const String& k) const +const LLSD& LLSD::operator[](const std::string_view k) const { return safe(impl).ref(k); } @@ -956,8 +962,8 @@ const char *LLSD::dump(const LLSD &llsd) return llsd_dump(llsd, false); } -std::map<LLSD::String, LLSD>& LLSD::map() { return makeMap(impl).map(); } -const std::map<LLSD::String, LLSD>& LLSD::map() const { return safe(impl).map(); } +LLSD::map_t& LLSD::map() { return makeMap(impl).map(); } +const LLSD::map_t& LLSD::map() const { return safe(impl).map(); } LLSD::map_iterator LLSD::beginMap() { return map().begin(); } LLSD::map_iterator LLSD::endMap() { return map().end(); } diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 0e8ffe96ac82a41ccc73e35f53a2f5cea83f27a9..022f455d308805103d84814f86e5d4a79a69b440 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -282,17 +282,17 @@ class LL_COMMON_API LLSD //@{ static LLSD emptyMap(); - bool has(const String&) const; - LLSD get(const String&) const; + bool has(const std::string_view) const; + LLSD get(const std::string_view) const; LLSD getKeys() const; // Return an LLSD array with keys as strings void insert(const String&, const LLSD&); void erase(const String&); LLSD& with(const String&, const LLSD&); - LLSD& operator[](const String&); - LLSD& operator[](const char* c) { return (*this)[String(c)]; } - const LLSD& operator[](const String&) const; - const LLSD& operator[](const char* c) const { return (*this)[String(c)]; } + LLSD& operator[](const std::string_view); + LLSD& operator[](const char* c) { return (*this)[std::string_view(c)]; } + const LLSD& operator[](const std::string_view) const; + const LLSD& operator[](const char* c) const { return (*this)[std::string_view(c)]; } //@} /** @name Array Values */ @@ -314,11 +314,12 @@ class LL_COMMON_API LLSD //@{ int size() const; - typedef std::map<String, LLSD>::iterator map_iterator; - typedef std::map<String, LLSD>::const_iterator map_const_iterator; + typedef std::map<String, LLSD, std::less<>> map_t; + typedef map_t::iterator map_iterator; + typedef map_t::const_iterator map_const_iterator; - std::map<String, LLSD>& map(); - const std::map<String, LLSD>& map() const; + map_t& map(); + const map_t& map() const; map_iterator beginMap(); map_iterator endMap(); diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index fc157f6d28abaa39367e46273155d742c2a154a1..4d63492a4ede0c0f372a33dc9c4ec9b0a301b883 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -932,7 +932,7 @@ boost::optional<std::string> llstring_getoptenv(const std::string& key) long LLStringOps::sPacificTimeOffset = 0; long LLStringOps::sLocalTimeOffset = 0; bool LLStringOps::sPacificDaylightTime = 0; -std::map<std::string, std::string> LLStringOps::datetimeToCodes; +absl::flat_hash_map<std::string, std::string> LLStringOps::datetimeToCodes; std::vector<std::string> LLStringOps::sWeekDayList; std::vector<std::string> LLStringOps::sWeekDayShortList; @@ -1041,18 +1041,16 @@ void LLStringOps::setupDayFormat(const std::string& data) } -std::string LLStringOps::getDatetimeCode (std::string key) +std::string LLStringOps::getDatetimeCode (std::string_view key) { - std::map<std::string, std::string>::iterator iter; - - iter = datetimeToCodes.find (key); + auto iter = datetimeToCodes.find (key); if (iter != datetimeToCodes.end()) { return iter->second; } else { - return std::string(""); + return std::string(); } } @@ -1262,7 +1260,7 @@ bool LLStringUtil::simpleReplacement(std::string &replacement, std::string token template<> void LLStringUtil::setLocale(std::string inLocale) { - sLocale = inLocale; + sLocale = std::move(inLocale); }; //static diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 3df199141f368f316ef2a9f627528695a5c55e8d..be782730d89e6a632c0fc193221be4378c511085 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -32,6 +32,7 @@ #pragma GCC diagnostic ignored "-Wdeprecated-copy-dtor" #endif #include <boost/optional/optional.hpp> +#include <absl/container/flat_hash_map.h> #if LL_GNUC #pragma GCC diagnostic pop #endif @@ -157,7 +158,7 @@ class LL_COMMON_API LLStringOps static long sLocalTimeOffset; static bool sPacificDaylightTime; - static std::map<std::string, std::string> datetimeToCodes; + static absl::flat_hash_map<std::string, std::string> datetimeToCodes; public: static std::vector<std::string> sWeekDayList; @@ -214,7 +215,7 @@ class LL_COMMON_API LLStringOps // currently in daylight savings time? static bool getPacificDaylightTime(void) { return sPacificDaylightTime;} - static std::string getDatetimeCode (std::string key); + static std::string getDatetimeCode (std::string_view key); // Express a value like 1234567 as "1.23M" static std::string getReadableNumber(F64 num); @@ -233,10 +234,11 @@ LL_COMMON_API std::string ll_safe_string(const char* in, S32 maxlen); class LLFormatMapString { public: - LLFormatMapString() {}; + LLFormatMapString() = default; LLFormatMapString(const char* s) : mString(ll_safe_string(s)) {}; - LLFormatMapString(const std::string& s) : mString(s) {}; + LLFormatMapString(const std::string s) : mString(std::move(s)) {}; operator std::string() const { return mString; } + operator std::string_view() const { return mString; } bool operator<(const LLFormatMapString& rhs) const { return mString < rhs.mString; } std::size_t length() const { return mString.length(); } diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index e924421ff2a8100e8da21680b709f2f1fc757e68..fa66adc7b8fff80330dc07c09665eb5dff843d4f 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -211,10 +211,10 @@ std::string LLUUID::asString() const BOOL LLUUID::set(const char* in_string, BOOL emit) { - return set(ll_safe_string(in_string),emit); + return set(absl::NullSafeStringView(in_string),emit); } -BOOL LLUUID::set(const std::string& in_string, BOOL emit) +BOOL LLUUID::set(const std::string_view in_string, BOOL emit) { BOOL broken_format = FALSE; @@ -318,7 +318,7 @@ BOOL LLUUID::set(const std::string& in_string, BOOL emit) return TRUE; } -BOOL LLUUID::validate(const std::string& in_string) +BOOL LLUUID::validate(const std::string_view in_string) { BOOL broken_format = FALSE; if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */ @@ -1006,23 +1006,11 @@ LLAssetID LLTransactionID::makeAssetID(const LLUUID& session) const LLUUID::LLUUID(const char *in_string) { - if (!in_string || in_string[0] == 0) - { - setNull(); - return; - } - set(in_string); } - LLUUID::LLUUID(const std::string& in_string) + LLUUID::LLUUID(const std::string_view in_string) { - if (in_string.empty()) - { - setNull(); - return; - } - set(in_string); } diff --git a/indra/llcommon/lluuid.h b/indra/llcommon/lluuid.h index b750378eee7b29ffad71856700ecd2b3dc2f13cc..2598f5af41cd1247cef9f06dfd81912578c9cf39 100644 --- a/indra/llcommon/lluuid.h +++ b/indra/llcommon/lluuid.h @@ -58,7 +58,7 @@ class LL_COMMON_API LLUUID // LLUUID() = default; explicit LLUUID(const char *in_string); // Convert from string. - explicit LLUUID(const std::string& in_string); // Convert from string. + explicit LLUUID(const std::string_view in_string); // Convert from string. // // MANIPULATORS @@ -71,7 +71,7 @@ class LL_COMMON_API LLUUID static LLUUID generateNewID(const std::string& stream); //static version of above for use in initializer expressions such as constructor params, etc. BOOL set(const char *in_string, BOOL emit = TRUE); // Convert from string, if emit is FALSE, do not emit warnings - BOOL set(const std::string& in_string, BOOL emit = TRUE); // Convert from string, if emit is FALSE, do not emit warnings + BOOL set(const std::string_view in_string, BOOL emit = TRUE); // Convert from string, if emit is FALSE, do not emit warnings void setNull(); // Faster than setting to LLUUID::null. S32 cmpTime(uuid_time_t *t1, uuid_time_t *t2); @@ -215,7 +215,7 @@ class LL_COMMON_API LLUUID U16 getCRC16() const; U32 getCRC32() const; - static BOOL validate(const std::string& in_string); // Validate that the UUID string is legal. + static BOOL validate(const std::string_view in_string); // Validate that the UUID string is legal. static const LLUUID null; static LLMutex * mMutex; diff --git a/indra/llinventory/llfoldertype.cpp b/indra/llinventory/llfoldertype.cpp index a41e5394554499d535e71dee87172b6e8c6e39ca..fd3027c296566071f0a9d62582a8b69c078454c5 100644 --- a/indra/llinventory/llfoldertype.cpp +++ b/indra/llinventory/llfoldertype.cpp @@ -109,7 +109,7 @@ LLFolderDictionary::LLFolderDictionary() }; // static -LLFolderType::EType LLFolderType::lookup(const std::string& name) +LLFolderType::EType LLFolderType::lookup(const std::string_view name) { return LLFolderDictionary::getInstance()->lookup(name); } diff --git a/indra/llinventory/llfoldertype.h b/indra/llinventory/llfoldertype.h index 7addc18bead1522ce09f67ba84f1337a0e1637a4..9a5af86e07476be66f3d1a7d3121263b994ee318 100644 --- a/indra/llinventory/llfoldertype.h +++ b/indra/llinventory/llfoldertype.h @@ -103,7 +103,7 @@ class LLFolderType FT_NONE = -1 }; - static EType lookup(const std::string& type_name); + static EType lookup(const std::string_view type_name); static const std::string& lookup(EType folder_type); static bool lookupIsProtectedType(EType folder_type); diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp index d641a3f30a97c502dbd142d5af24e57abe6b6209..87030a16f844e08b0e0505093b39ea7ead2051fe 100644 --- a/indra/llinventory/llinventorytype.cpp +++ b/indra/llinventory/llinventorytype.cpp @@ -166,7 +166,7 @@ const std::string &LLInventoryType::lookup(EType type) } // static -LLInventoryType::EType LLInventoryType::lookup(const std::string& name) +LLInventoryType::EType LLInventoryType::lookup(const std::string_view name) { return LLInventoryDictionary::getInstance()->lookup(name); } diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h index 200d2a9fffb197217d04d07e3314411787ed9be3..76f949da0e849d5430c57836d142cefb6ebaae74 100644 --- a/indra/llinventory/llinventorytype.h +++ b/indra/llinventory/llinventorytype.h @@ -126,7 +126,7 @@ class LLInventoryType // machine transation between type and strings - static EType lookup(const std::string& name); + static EType lookup(const std::string_view name); static const std::string &lookup(EType type); // translation from a type to a human readable form. static const std::string &lookupHumanReadable(EType type); diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 05c1838dfeeedff66ab7a9d5820c4c4da0358f22..ac112281fd2a8263ebee9e71fb316b75fbe6fabf 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -217,7 +217,7 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLNotifica BOOL show_notification = TRUE; if (p.ignore.control.isProvided()) { - mIgnoreSetting = ui_inst->mSettingGroups["config"]->getControl(p.ignore.control); + mIgnoreSetting = ui_inst->mSettingGroups["config"]->getControl(p.ignore.control.getValue()); mInvertSetting = p.ignore.invert_control; } else if (mIgnore > IGNORE_NO) @@ -424,7 +424,7 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par mSoundName("") { if (p.sound.isProvided() - && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound)) + && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound.getValue())) { mSoundName = p.sound; } diff --git a/indra/llui/lltrans.cpp b/indra/llui/lltrans.cpp index a1a8feedaa937608dcb95bf3448f4cf98c320735..ee3ada2cfec598c7c7897920af64a7534bf1ee42 100644 --- a/indra/llui/lltrans.cpp +++ b/indra/llui/lltrans.cpp @@ -35,6 +35,9 @@ #include <map> +#include <absl/strings/str_format.h> +#include <absl/strings/str_cat.h> + LLTrans::template_map_t LLTrans::sStringTemplates; LLTrans::template_map_t LLTrans::sDefaultStringTemplates; LLStringUtil::format_map_t LLTrans::sDefaultArgs; @@ -143,7 +146,7 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) static LLTrace::BlockTimerStatHandle FTM_GET_TRANS("Translate string"); //static -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string) { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC @@ -167,12 +170,12 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil:: else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString("+xml_desc+")"; + return absl::StrCat("MissingString(", xml_desc, ")"); } } //static -std::string LLTrans::getDefString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args) +std::string LLTrans::getDefString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args) { template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc); if (iter != sDefaultStringTemplates.end()) @@ -187,12 +190,12 @@ std::string LLTrans::getDefString(const std::string &xml_desc, const LLStringUti else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString(" + xml_desc + ")"; + return absl::StrCat("MissingString(", xml_desc, ")"); } } //static -std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLSD& msg_args, bool def_string) { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC @@ -213,12 +216,12 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString("+xml_desc+")"; + return absl::StrCat("MissingString(", xml_desc, ")"); } } //static -std::string LLTrans::getDefString(const std::string &xml_desc, const LLSD& msg_args) +std::string LLTrans::getDefString(std::string_view xml_desc, const LLSD& msg_args) { template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc); if (iter != sDefaultStringTemplates.end()) @@ -230,12 +233,12 @@ std::string LLTrans::getDefString(const std::string &xml_desc, const LLSD& msg_a else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString(" + xml_desc + ")"; + return absl::StrCat("MissingString(", xml_desc, ")"); } } //static -bool LLTrans::findString(std::string &result, const std::string &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_RECORD_BLOCK_TIME(FTM_GET_TRANS); @@ -257,7 +260,7 @@ bool LLTrans::findString(std::string &result, const std::string &xml_desc, const } //static -bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLSD& msg_args) +bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLSD& msg_args) { LL_RECORD_BLOCK_TIME(FTM_GET_TRANS); @@ -277,7 +280,7 @@ bool LLTrans::findString(std::string &result, const std::string &xml_desc, const } //static -std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count) +std::string LLTrans::getCountString(const std::string_view language, const std::string_view xml_desc, S32 count) { // Compute which string identifier to use const char* form = ""; @@ -334,14 +337,14 @@ std::string LLTrans::getCountString(const std::string& language, const std::stri // Translate that string LLStringUtil::format_map_t args; - args["[COUNT]"] = llformat("%d", count); + args["[COUNT]"] = std::to_string(count); // Look up "AgeYearsB" or "AgeWeeksC" including the "form" - std::string key = llformat("%s%s", xml_desc.c_str(), form); + std::string key = absl::StrCat(xml_desc, form); return getString(key, args); } -void LLTrans::setDefaultArg(const std::string& name, const std::string& value) +void LLTrans::setDefaultArg(const std::string& name, const std::string value) { - sDefaultArgs[name] = value; + sDefaultArgs[name] = std::move(value); } diff --git a/indra/llui/lltrans.h b/indra/llui/lltrans.h index 9bd751fc78aeb0fffcc57c6c9425a46cdb06a958..10bafdfbc116db19baa9ea3f470ab315c801e399 100644 --- a/indra/llui/lltrans.h +++ b/indra/llui/lltrans.h @@ -43,7 +43,7 @@ class LLSD; class LLTransTemplate { public: - LLTransTemplate(const std::string& name = LLStringUtil::null, const std::string& text = LLStringUtil::null) : mName(name), mText(text) {} + LLTransTemplate(const std::string name = std::string(), const std::string text = std::string()) : mName(std::move(name)), mText(std::move(text)) {} std::string mName; std::string mText; @@ -76,41 +76,40 @@ class LLTrans * @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(const std::string_view language, const 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 @@ -119,7 +118,7 @@ class LLTrans return sDefaultArgs; } - static void setDefaultArg(const std::string& name, const std::string& value); + static void setDefaultArg(const std::string& name, const std::string value); // insert default args into an arg list static void getArgs(LLStringUtil::format_map_t& args) @@ -128,7 +127,7 @@ class LLTrans } 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; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index c0e438e988939db966f1276b174f8ffdd87496ac..019c5cbcd2ab60db9151a8b25d85b3dc933d25c7 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -89,23 +89,22 @@ static LLDefaultChildRegistry::Register<LLToolBar> register_toolbar("toolbar"); // Functions // -LLUUID find_ui_sound(const char * namep) +LLUUID find_ui_sound(std::string_view name) { - std::string name = ll_safe_string(namep); LLUUID uuid = LLUUID(NULL); - LLUI *ui_inst = LLUI::getInstance(); - if (!ui_inst->mSettingGroups["config"]->controlExists(name)) + LLUI& ui_inst = LLUI::instance(); + if (!ui_inst.mSettingGroups["config"]->controlExists(name)) { LL_WARNS() << "tried to make UI sound for unknown sound name: " << name << LL_ENDL; } else { - uuid = LLUUID(ui_inst->mSettingGroups["config"]->getString(name)); + uuid = LLUUID(ui_inst.mSettingGroups["config"]->getString(name)); if (uuid.isNull()) { - if (ui_inst->mSettingGroups["config"]->getString(name) == LLUUID::null.asString()) + if (ui_inst.mSettingGroups["config"]->getString(name) == LLUUID::null.asString()) { - if (ui_inst->mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle")) + if (ui_inst.mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle")) { LL_INFOS() << "UI sound name: " << name << " triggered but silent (null uuid)" << LL_ENDL; } @@ -115,9 +114,9 @@ LLUUID find_ui_sound(const char * namep) LL_WARNS() << "UI sound named: " << name << " does not translate to a valid uuid" << LL_ENDL; } } - else if (ui_inst->mAudioCallback != NULL) + else if (ui_inst.mAudioCallback != NULL) { - if (ui_inst->mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle")) + if (ui_inst.mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle")) { LL_INFOS() << "UI sound name: " << name << LL_ENDL; } @@ -127,9 +126,14 @@ LLUUID find_ui_sound(const char * namep) return uuid; } +LLUUID find_ui_sound(const char* namep) +{ + return find_ui_sound(absl::NullSafeStringView(namep)); +} + void make_ui_sound(const char* namep) { - LLUUID soundUUID = find_ui_sound(namep); + LLUUID soundUUID = find_ui_sound(absl::NullSafeStringView(namep)); if(soundUUID.notNull()) { LLUI::getInstance()->mAudioCallback(soundUUID); @@ -138,7 +142,7 @@ void make_ui_sound(const char* namep) void make_ui_sound_deferred(const char* namep) { - LLUUID soundUUID = find_ui_sound(namep); + LLUUID soundUUID = find_ui_sound(absl::NullSafeStringView(namep)); if(soundUUID.notNull()) { LLUI::getInstance()->mDeferredAudioCallback(soundUUID); @@ -531,7 +535,7 @@ namespace LLInitParam { if (control.isProvided() && !control().empty()) { - updateValue(LLUIColorTable::instance().getColor(control)); + updateValue(LLUIColorTable::instance().getColor(control.getValue())); } else { diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp index c0ab83cf470da77170017d12e6ec2713eadb89b0..0fdac292f8246c6f502f5a79ef94ea51fe662f18 100644 --- a/indra/llui/lluicolortable.cpp +++ b/indra/llui/lluicolortable.cpp @@ -63,7 +63,7 @@ void LLUIColorTable::insertFromParams(const Params& p, string_color_map_t& table ColorEntryParams color_entry = *it; if(color_entry.color.value.isChosen()) { - setColor(color_entry.name, color_entry.color.value, table); + setColor(color_entry.name.getValue(), color_entry.color.value, table); } else { @@ -176,7 +176,7 @@ void LLUIColorTable::clear() clearTable(mUserSetColors); } -LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const +LLUIColor LLUIColorTable::getColor(std::string_view name, const LLColor4& default_color) const { string_color_map_t::const_iterator iter = mUserSetColors.find(name); @@ -196,7 +196,7 @@ LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& defa } // update user color, loaded colors are parsed on initialization -void LLUIColorTable::setColor(const std::string& name, const LLColor4& color) +void LLUIColorTable::setColor(std::string_view name, const LLColor4& color) { setColor(name, color, mUserSetColors); setColor(name, color, mLoadedColors); @@ -254,7 +254,7 @@ void LLUIColorTable::saveUserSettings() const } } -bool LLUIColorTable::colorExists(const std::string& color_name) const +bool LLUIColorTable::colorExists(std::string_view color_name) const { return ((mLoadedColors.find(color_name) != mLoadedColors.end()) || (mUserSetColors.find(color_name) != mUserSetColors.end())); @@ -272,7 +272,7 @@ void LLUIColorTable::clearTable(string_color_map_t& table) // this method inserts a color into the table if it does not exist // if the color already exists it changes the color -void LLUIColorTable::setColor(const std::string& name, const LLColor4& color, string_color_map_t& table) +void LLUIColorTable::setColor(std::string_view name, const LLColor4& color, string_color_map_t& table) { string_color_map_t::iterator it = table.lower_bound(name); if(it != table.end() diff --git a/indra/llui/lluicolortable.h b/indra/llui/lluicolortable.h index d6f9a93f832ce1b2680cb88828ec4a54bc987c6f..153a4b21cb5ba515d7e15a3e02d09d792d50d7a5 100644 --- a/indra/llui/lluicolortable.h +++ b/indra/llui/lluicolortable.h @@ -42,7 +42,7 @@ class LLUIColorTable final : public LLSingleton<LLUIColorTable> LOG_CLASS(LLUIColorTable); // consider using sorted vector, can be much faster - typedef std::map<std::string, LLUIColor> string_color_map_t; + typedef std::map<std::string, LLUIColor, std::less<>> string_color_map_t; public: struct ColorParams : LLInitParam::ChoiceBlock<ColorParams> @@ -75,13 +75,13 @@ class LLUIColorTable final : public LLSingleton<LLUIColorTable> void clear(); // color lookup - LLUIColor getColor(const std::string& name, const LLColor4& default_color = LLColor4::magenta) const; + LLUIColor getColor(std::string_view, const LLColor4& default_color = LLColor4::magenta) const; // if the color is in the table, it's value is changed, otherwise it is added - void setColor(const std::string& name, const LLColor4& color); + void setColor(std::string_view name, const LLColor4& color); // returns true if color_name exists in the table - bool colorExists(const std::string& color_name) const; + bool colorExists(std::string_view color_name) const; // loads colors from settings files bool loadFromSettings(); @@ -95,7 +95,7 @@ class LLUIColorTable final : public LLSingleton<LLUIColorTable> void insertFromParams(const Params& p, string_color_map_t& table); void clearTable(string_color_map_t& table); - void setColor(const std::string& name, const LLColor4& color, string_color_map_t& table); + void setColor(std::string_view name, const LLColor4& color, string_color_map_t& table); string_color_map_t mLoadedColors; string_color_map_t mUserSetColors; diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index 9e5f980e5c248e3b572ac13a6313b7ea54e1afd2..fa866ed9342d91dcb16f8e93e9e722158c7360b0 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -42,7 +42,7 @@ enum EKeystate }; typedef boost::function<void(EKeystate keystate)> LLKeyFunc; -typedef std::string (LLKeyStringTranslatorFunc)(const char *label); +typedef std::string (LLKeyStringTranslatorFunc)(std::string_view label); enum EKeyboardInsertMode { diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 63c82f04f5ed677e21e2f614cf44cc8af9e3a2a8..b6bb17d854a1544e834b4da1d5ca72368201767a 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -86,22 +86,22 @@ template <> LLSD convert_to_llsd<LLColor4>(const LLColor4& in); template <> LLSD convert_to_llsd<LLColor3>(const LLColor3& in); template <> LLSD convert_to_llsd<LLColor4U>(const LLColor4U& in); -template <> bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLVector4 convert_from_llsd<LLVector4>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLColor4U convert_from_llsd<LLColor4U>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLUUID convert_from_llsd<LLUUID>(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, const std::string& control_name); +template <> bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLVector4 convert_from_llsd<LLVector4>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLColor4U convert_from_llsd<LLColor4U>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLUUID convert_from_llsd<LLUUID>(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, std::string_view control_name); //this defines the current version of the settings file const S32 CURRENT_VERSION = 101; @@ -112,7 +112,7 @@ const S32 CURRENT_VERSION = 101; // by SETTINGS_PROFILE below. Only settings with an average access rate >= 2/second are output. typedef std::pair<std::string, U32> settings_pair_t; typedef std::vector<settings_pair_t> settings_vec_t; -LLSD getCount; +std::map<std::string, int, std::less<>> getCount; settings_vec_t getCount_v; F64 start_time = 0; std::string SETTINGS_PROFILE = "settings_profile.log"; @@ -164,11 +164,11 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) return result; } -LLControlVariable::LLControlVariable(const std::string& name, eControlType type, - LLSD initial, const std::string& comment, +LLControlVariable::LLControlVariable(const std::string name, eControlType type, + LLSD initial, const std::string comment, ePersist persist, bool hidefromsettingseditor) - : mName(name), - mComment(comment), + : mName(std::move(name)), + mComment(std::move(comment)), mType(type), mPersist(persist), mHideFromSettingsEditor(hidefromsettingseditor) @@ -300,9 +300,9 @@ void LLControlVariable::setHiddenFromSettingsEditor(bool hide) mHideFromSettingsEditor = hide; } -void LLControlVariable::setComment(const std::string& comment) +void LLControlVariable::setComment(const std::string comment) { - mComment = comment; + mComment = std::move(comment); } void LLControlVariable::resetToDefault(bool fire_signal) @@ -367,7 +367,7 @@ void LLControlVariable::firePropertyChanged(const LLSD &pPreviousValue) } } -LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name) +LLPointer<LLControlVariable> LLControlGroup::getControl(std::string_view name) { if (mSettingsProfile) { @@ -444,9 +444,9 @@ void LLControlGroup::cleanup() LL_WARNS("SettingsProfile") << "Failed to write settings profile header" << LL_ENDL; } - for (LLSD::map_const_iterator iter = getCount.beginMap(); iter != getCount.endMap(); ++iter) + for (const auto& [first, second] : getCount) { - getCount_v.push_back(settings_pair_t(iter->first, iter->second.asInteger())); + getCount_v.emplace_back(first, second); } sort(getCount_v.begin(), getCount_v.end(), compareRoutine); @@ -469,7 +469,7 @@ void LLControlGroup::cleanup() } } } - getCount = LLSD::emptyMap(); + getCount.clear(); fclose(out); } } @@ -589,51 +589,59 @@ LLControlVariable* LLControlGroup::declareLLSD(const std::string& name, const LL return declareControl(name, TYPE_LLSD, initial_val, comment, persist); } -void LLControlGroup::incrCount(const std::string& name) +void LLControlGroup::incrCount(std::string_view name) { if (0.0 == start_time) { start_time = LLTimer::getTotalSeconds(); } - getCount[name] = getCount[name].asInteger() + 1; + auto it = getCount.find(name); + if (it != getCount.end()) + { + it->second = it->second + 1; + } + else + { + getCount.emplace(name, 1); + } } -BOOL LLControlGroup::getBOOL(const std::string& name) +BOOL LLControlGroup::getBOOL(std::string_view name) { return (BOOL)get<bool>(name); } -bool LLControlGroup::getBool(const std::string& name) +bool LLControlGroup::getBool(std::string_view name) { return get<bool>(name); } -S32 LLControlGroup::getS32(const std::string& name) +S32 LLControlGroup::getS32(std::string_view name) { return get<S32>(name); } -U32 LLControlGroup::getU32(const std::string& name) +U32 LLControlGroup::getU32(std::string_view name) { return get<U32>(name); } -F32 LLControlGroup::getF32(const std::string& name) +F32 LLControlGroup::getF32(std::string_view name) { return get<F32>(name); } -std::string LLControlGroup::getString(const std::string& name) +std::string LLControlGroup::getString(std::string_view name) { return get<std::string>(name); } -LLWString LLControlGroup::getWString(const std::string& name) +LLWString LLControlGroup::getWString(std::string_view name) { return get<LLWString>(name); } -std::string LLControlGroup::getText(const std::string& name) +std::string LLControlGroup::getText(std::string_view name) { std::string utf8_string = getString(name); LLStringUtil::replaceChar(utf8_string, '^', '\n'); @@ -641,59 +649,59 @@ std::string LLControlGroup::getText(const std::string& name) return (utf8_string); } -LLVector3 LLControlGroup::getVector3(const std::string& name) +LLVector3 LLControlGroup::getVector3(std::string_view name) { return get<LLVector3>(name); } -LLVector3d LLControlGroup::getVector3d(const std::string& name) +LLVector3d LLControlGroup::getVector3d(std::string_view name) { return get<LLVector3d>(name); } -LLVector4 LLControlGroup::getVector4(const std::string& name) +LLVector4 LLControlGroup::getVector4(std::string_view name) { return get<LLVector4>(name); } -LLQuaternion LLControlGroup::getQuaternion(const std::string& name) +LLQuaternion LLControlGroup::getQuaternion(std::string_view name) { return get<LLQuaternion>(name); } -LLRect LLControlGroup::getRect(const std::string& name) +LLRect LLControlGroup::getRect(std::string_view name) { return get<LLRect>(name); } -LLColor4 LLControlGroup::getColor(const std::string& name) +LLColor4 LLControlGroup::getColor(std::string_view name) { return get<LLColor4>(name); } -LLColor4 LLControlGroup::getColor4(const std::string& name) +LLColor4 LLControlGroup::getColor4(std::string_view name) { return get<LLColor4>(name); } -LLColor3 LLControlGroup::getColor3(const std::string& name) +LLColor3 LLControlGroup::getColor3(std::string_view name) { return get<LLColor3>(name); } -LLUUID LLControlGroup::getUUID(const std::string& name) +LLUUID LLControlGroup::getUUID(std::string_view name) { return get<LLUUID>(name); } -LLSD LLControlGroup::getLLSD(const std::string& name) +LLSD LLControlGroup::getLLSD(std::string_view name) { return get<LLSD>(name); } -BOOL LLControlGroup::controlExists(const std::string& name) +BOOL LLControlGroup::controlExists(std::string_view name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter != mNameTable.end(); @@ -704,77 +712,77 @@ BOOL LLControlGroup::controlExists(const std::string& name) // Set functions //------------------------------------------------------------------- -void LLControlGroup::setBOOL(const std::string& name, BOOL val) +void LLControlGroup::setBOOL(std::string_view name, BOOL val) { set<bool>(name, val); } -void LLControlGroup::setS32(const std::string& name, S32 val) +void LLControlGroup::setS32(std::string_view name, S32 val) { set(name, val); } -void LLControlGroup::setF32(const std::string& name, F32 val) +void LLControlGroup::setF32(std::string_view name, F32 val) { set(name, val); } -void LLControlGroup::setU32(const std::string& name, U32 val) +void LLControlGroup::setU32(std::string_view name, U32 val) { set(name, val); } -void LLControlGroup::setString(const std::string& name, const std::string &val) +void LLControlGroup::setString(std::string_view name, const std::string &val) { set(name, val); } -void LLControlGroup::setVector3(const std::string& name, const LLVector3 &val) +void LLControlGroup::setVector3(std::string_view name, const LLVector3 &val) { set(name, val); } -void LLControlGroup::setVector3d(const std::string& name, const LLVector3d &val) +void LLControlGroup::setVector3d(std::string_view name, const LLVector3d &val) { set(name, val); } -void LLControlGroup::setQuaternion(const std::string& name, const LLQuaternion &val) +void LLControlGroup::setQuaternion(std::string_view name, const LLQuaternion &val) { set(name, val); } -void LLControlGroup::setVector4(const std::string& name, const LLVector4& val) +void LLControlGroup::setVector4(std::string_view name, const LLVector4& val) { set(name, val); } -void LLControlGroup::setRect(const std::string& name, const LLRect &val) +void LLControlGroup::setRect(std::string_view name, const LLRect &val) { set(name, val); } -void LLControlGroup::setColor4(const std::string& name, const LLColor4 &val) +void LLControlGroup::setColor4(std::string_view name, const LLColor4 &val) { set(name, val); } -void LLControlGroup::setUUID(const std::string& name, const LLUUID& val) +void LLControlGroup::setUUID(std::string_view name, const LLUUID& val) { set(name, val); } -void LLControlGroup::setLLSD(const std::string& name, const LLSD& val) +void LLControlGroup::setLLSD(std::string_view name, const LLSD& val) { set(name, val); } -void LLControlGroup::setUntypedValue(const std::string& name, const LLSD& val) +void LLControlGroup::setUntypedValue(std::string_view name, const LLSD& val) { if (name.empty()) { @@ -1420,7 +1428,7 @@ template <> LLSD convert_to_llsd<LLColor4U>(const LLColor4U& in) template<> -bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::string& control_name) +bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_BOOLEAN) return sd.asBoolean(); @@ -1432,7 +1440,7 @@ bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::strin } template<> -S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string& control_name) +S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_S32) return sd.asInteger(); @@ -1444,7 +1452,7 @@ S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string& } template<> -U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string& control_name) +U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_U32) return sd.asInteger(); @@ -1456,7 +1464,7 @@ U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string& } template<> -F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string& control_name) +F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_F32) return (F32) sd.asReal(); @@ -1468,7 +1476,7 @@ F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string& } template<> -std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, const std::string& control_name) +std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_STRING) return sd.asString(); @@ -1480,13 +1488,13 @@ std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, co } template<> -LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, const std::string& control_name) +LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, std::string_view control_name) { return utf8str_to_wstring(convert_from_llsd<std::string>(sd, type, control_name)); } template<> -LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const std::string& control_name) +LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_VEC3) return (LLVector3)sd; @@ -1498,7 +1506,7 @@ LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const } template<> -LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, const std::string& control_name) +LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_VEC3D) return (LLVector3d)sd; @@ -1510,7 +1518,7 @@ LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, cons } template<> -LLVector4 convert_from_llsd<LLVector4>(const LLSD& sd, eControlType type, const std::string& control_name) +LLVector4 convert_from_llsd<LLVector4>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_VEC4) return (LLVector4)sd; @@ -1522,7 +1530,7 @@ LLVector4 convert_from_llsd<LLVector4>(const LLSD& sd, eControlType type, const } template<> -LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, const std::string& control_name) +LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_QUAT) return (LLQuaternion)sd; @@ -1534,7 +1542,7 @@ LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, } template<> -LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::string& control_name) +LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_RECT) return LLRect(sd); @@ -1547,7 +1555,7 @@ LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::s template<> -LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, const std::string& control_name) +LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_COL4) { @@ -1579,7 +1587,7 @@ LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, const st } template<> -LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const std::string& control_name) +LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_COL3) return sd; @@ -1591,7 +1599,7 @@ LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const st } template<> -LLUUID convert_from_llsd<LLUUID>(const LLSD& sd, eControlType type, const std::string& control_name) +LLUUID convert_from_llsd<LLUUID>(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_UUID) return sd.asUUID(); @@ -1603,7 +1611,7 @@ LLUUID convert_from_llsd<LLUUID>(const LLSD& sd, eControlType type, const std::s } template<> -LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, const std::string& control_name) +LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, std::string_view control_name) { return sd; } diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index c26a0195b5066d4e2f36669f07fca411ff6f9b41..23c1845eed3f83ba79dacedf6a92460d1de79a87 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -34,6 +34,8 @@ #include "llrefcount.h" #include "llinstancetracker.h" +#include <absl/strings/string_view.h> + #include <vector> // *NOTE: boost::visit_each<> generates warning 4675 on .net 2003 @@ -119,8 +121,8 @@ class LLControlVariable final : public LLRefCount validate_signal_t mValidateSignal; public: - LLControlVariable(const std::string& name, eControlType type, - LLSD initial, const std::string& comment, + LLControlVariable(const std::string name, eControlType type, + LLSD initial, const std::string comment, ePersist persist = PERSIST_NONDFT, bool hidefromsettingseditor = false); virtual ~LLControlVariable() = default; @@ -154,7 +156,7 @@ class LLControlVariable final : public LLRefCount void setDefaultValue(const LLSD& value); void setPersist(ePersist); void setHiddenFromSettingsEditor(bool hide); - void setComment(const std::string& comment); + void setComment(const std::string comment); private: void firePropertyChanged(const LLSD &pPreviousValue); @@ -180,7 +182,7 @@ LLSD convert_to_llsd(const T& in) } template <class T> -T convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +T convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { // needs specialization return T(sd); @@ -192,7 +194,7 @@ class LLControlGroup final : public LLInstanceTracker<LLControlGroup, std::strin LOG_CLASS(LLControlGroup); protected: - typedef std::map<std::string, LLControlVariablePtr > ctrl_name_table_t; + typedef std::map<std::string, LLControlVariablePtr, std::less<>> ctrl_name_table_t; ctrl_name_table_t mNameTable; static const std::string mTypeString[TYPE_COUNT]; @@ -206,7 +208,7 @@ class LLControlGroup final : public LLInstanceTracker<LLControlGroup, std::strin ~LLControlGroup(); void cleanup(); - LLControlVariablePtr getControl(const std::string& name); + LLControlVariablePtr getControl(std::string_view name); struct ApplyFunctor { @@ -231,30 +233,30 @@ class LLControlGroup final : public LLInstanceTracker<LLControlGroup, std::strin LLControlVariable* declareUUID(const std::string& name, const LLUUID& initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); - std::string getString(const std::string& name); - std::string getText(const std::string& name); - BOOL getBOOL(const std::string& name); - bool getBool(const std::string& name); - S32 getS32(const std::string& name); - F32 getF32(const std::string& name); - U32 getU32(const std::string& name); + std::string getString(std::string_view name); + std::string getText(std::string_view name); + BOOL getBOOL(std::string_view name); + bool getBool(std::string_view name); + S32 getS32(std::string_view name); + F32 getF32(std::string_view name); + U32 getU32(std::string_view name); - LLWString getWString(const std::string& name); - LLVector3 getVector3(const std::string& name); - LLVector3d getVector3d(const std::string& name); - LLVector4 getVector4(const std::string& name); - LLRect getRect(const std::string& name); - LLUUID getUUID(const std::string& name); - LLSD getLLSD(const std::string& name); - LLQuaternion getQuaternion(const std::string& name); + LLWString getWString(std::string_view name); + LLVector3 getVector3(std::string_view name); + LLVector3d getVector3d(std::string_view name); + LLVector4 getVector4(std::string_view name); + LLRect getRect(std::string_view name); + LLUUID getUUID(std::string_view name); + LLSD getLLSD(std::string_view name); + LLQuaternion getQuaternion(std::string_view name); - LLColor4 getColor(const std::string& name); - LLColor4 getColor4(const std::string& name); - LLColor3 getColor3(const std::string& name); + LLColor4 getColor(std::string_view name); + LLColor4 getColor4(std::string_view name); + LLColor3 getColor3(std::string_view name); // generic getter - template<typename T> T get(const std::string& name) + template<typename T> T get(std::string_view name) { LLControlVariable* control = getControl(name); LLSD value; @@ -273,25 +275,25 @@ class LLControlGroup final : public LLInstanceTracker<LLControlGroup, std::strin return convert_from_llsd<T>(value, type, name); } - void setBOOL(const std::string& name, BOOL val); - void setS32(const std::string& name, S32 val); - void setF32(const std::string& name, F32 val); - void setU32(const std::string& name, U32 val); - void setString(const std::string& name, const std::string& val); - void setVector3(const std::string& name, const LLVector3 &val); - void setVector3d(const std::string& name, const LLVector3d &val); - void setVector4(const std::string& name, const LLVector4& val); - void setQuaternion(const std::string& name, const LLQuaternion &val); - void setRect(const std::string& name, const LLRect &val); - void setColor4(const std::string& name, const LLColor4 &val); - void setUUID(const std::string& name, const LLUUID& val); - void setLLSD(const std::string& name, const LLSD& val); + void setBOOL(std::string_view name, BOOL val); + void setS32(std::string_view name, S32 val); + void setF32(std::string_view name, F32 val); + void setU32(std::string_view name, U32 val); + void setString(std::string_view name, const std::string& val); + void setVector3(std::string_view name, const LLVector3 &val); + void setVector3d(std::string_view name, const LLVector3d &val); + void setVector4(std::string_view name, const LLVector4& val); + void setQuaternion(std::string_view name, const LLQuaternion &val); + void setRect(std::string_view name, const LLRect &val); + void setColor4(std::string_view name, const LLColor4 &val); + void setUUID(std::string_view name, const LLUUID& val); + void setLLSD(std::string_view name, const LLSD& val); // type agnostic setter that takes LLSD - void setUntypedValue(const std::string& name, const LLSD& val); + void setUntypedValue(std::string_view name, const LLSD& val); // generic setter - template<typename T> void set(const std::string& name, const T& val) + template<typename T> void set(std::string_view name, const T& val) { LLControlVariable* control = getControl(name); @@ -305,7 +307,7 @@ class LLControlGroup final : public LLInstanceTracker<LLControlGroup, std::strin } } - BOOL controlExists(const std::string& name); + BOOL controlExists(std::string_view name); // Returns number of controls loaded, 0 if failed // If require_declaration is false, will auto-declare controls it finds @@ -314,7 +316,7 @@ class LLControlGroup final : public LLInstanceTracker<LLControlGroup, std::strin U32 saveToFile(const std::string& filename, BOOL nondefault_only); U32 loadFromFile(const std::string& filename, bool default_values = false, bool save_values = true); void resetToDefaults(); - void incrCount(const std::string& name); + void incrCount(std::string_view name); bool mSettingsProfile; }; @@ -466,21 +468,21 @@ template <> LLSD convert_to_llsd<LLColor4>(const LLColor4& in); template <> LLSD convert_to_llsd<LLColor3>(const LLColor3& in); template <> LLSD convert_to_llsd<LLColor4U>(const LLColor4U& in); -template<> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLVector4 convert_from_llsd<LLVector4>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLUUID convert_from_llsd<LLUUID>(const LLSD& sd, eControlType type, const std::string& control_name); -template<> LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, const std::string& control_name); +template<> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLVector4 convert_from_llsd<LLVector4>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLUUID convert_from_llsd<LLUUID>(const LLSD& sd, eControlType type, std::string_view control_name); +template<> LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, std::string_view control_name); //#define TEST_CACHED_CONTROL 1 #ifdef TEST_CACHED_CONTROL diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index ee8bd5ef3523cd4f8d83bce1286fe4caa7efaff9..72519ae6554961cbe3aef75624627f5d60c9031b 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -120,6 +120,7 @@ set(viewer_SOURCE_FILES alfloaterregiontracker.cpp alpanelaomini.cpp alpanelaopulldown.cpp + alpanelmusicticker.cpp alpanelquicksettings.cpp alpanelquicksettingspulldown.cpp altoolalign.cpp @@ -775,6 +776,7 @@ set(viewer_HEADER_FILES alfloaterregiontracker.h alpanelaomini.h alpanelaopulldown.h + alpanelmusicticker.h alpanelquicksettings.h alpanelquicksettingspulldown.h altoolalign.h diff --git a/indra/newview/alpanelmusicticker.cpp b/indra/newview/alpanelmusicticker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9dd56825cddac464fba209f1d6f6433254627b31 --- /dev/null +++ b/indra/newview/alpanelmusicticker.cpp @@ -0,0 +1,248 @@ +/** +* @file alpanelmusicticker.cpp +* @brief ALPanelMusicTicker implementation +* +* $LicenseInfo:firstyear=2015&license=viewerlgpl$ +* Copyright (C) Shyotl Kuhr +* Copyright (C) 2015 Drake Arconis +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* $/LicenseInfo$ +**/ + +#include "llviewerprecompiledheaders.h" + +#include "alpanelmusicticker.h" + +// Library includes +#include "llaudioengine.h" +#include "lliconctrl.h" +#include "llstreamingaudio.h" +#include "lltextbox.h" +#include "lluicolortable.h" +#include "lluictrl.h" + +// Viewer includes +#include "llviewercontrol.h" + +static LLPanelInjector<ALPanelMusicTicker> t_music_ticker("music_ticker"); + +ALPanelMusicTicker::ALPanelMusicTicker() : LLPanel(), + mPlayState(STATE_PLAYING), + mArtistScrollChars(0), + mTitleScrollChars(0), + mCurScrollChar(0), + mArtistText(nullptr), + mTitleText(nullptr), + mVisualizer(nullptr) +{ +} + +BOOL ALPanelMusicTicker::postBuild() +{ + mArtistText = getChild<LLTextBox>("artist_text"); + mTitleText = getChild<LLTextBox>("title_text"); + mVisualizer = getChild<LLUICtrl>("visualizer_box"); + mszLoading = getString("loading"); + mszPaused = getString("paused"); + mOscillatorColor = LLUIColorTable::getInstance()->getColor("ALMediaTickerOscillatorColor"); + + setPaused(true); + + return LLPanel::postBuild(); +} + +void ALPanelMusicTicker::draw() +{ + updateTickerText(); + drawOscilloscope(); + LLPanel::draw(); +} + +void ALPanelMusicTicker::reshape(S32 width, S32 height, BOOL called_from_parent/*=TRUE*/) +{ + bool width_changed = (getRect().getWidth() != width); + LLPanel::reshape(width, height, called_from_parent); + if(width_changed) + { + if(mTitleText) + mTitleScrollChars = countExtraChars(mTitleText, mszTitle); + if(mArtistText) + mArtistScrollChars = countExtraChars(mArtistText, mszArtist); + resetTicker(); + } +} + +void ALPanelMusicTicker::updateTickerText() //called via draw. +{ + if(!gAudiop) + return; + + bool stream_paused = gAudiop->getStreamingAudioImpl()->isPlaying() != 1; //will return 1 if playing. + + bool dirty = setPaused(stream_paused); + if(!stream_paused) + { + if (dirty || gAudiop->getStreamingAudioImpl()->hasNewMetaData()) + { + const LLSD* metadata = gAudiop->getStreamingAudioImpl()->getMetaData(); + LLSD artist = metadata ? metadata->get("ARTIST") : LLSD(); + LLSD title = metadata ? metadata->get("TITLE") : LLSD(); + + dirty |= setArtist(artist.isDefined() ? artist.asString() : mszLoading); + dirty |= setTitle(title.isDefined() ? title.asString() : mszLoading); + if(artist.isDefined() && title.isDefined()) + mLoadTimer.stop(); + else if(dirty) + mLoadTimer.start(); + else if(mLoadTimer.getStarted() && mLoadTimer.getElapsedTimeF64() > 10.f) //It has been 10 seconds.. give up. + { + if(!artist.isDefined()) + dirty |= setArtist(LLStringUtil::null); + if(!title.isDefined()) + dirty |= setTitle(LLStringUtil::null); + mLoadTimer.stop(); + } + } + } + if(dirty) + resetTicker(); + else + iterateTickerOffset(); +} + +void ALPanelMusicTicker::drawOscilloscope() //called via draw. +{ + if(!gAudiop || !mVisualizer || !gAudiop->getStreamingAudioImpl()->supportsWaveData()) + return; + + static const S32 NUM_LINE_STRIPS = 64; //How many lines to draw. 64 is more than enough. + static const S32 WAVE_DATA_STEP_SIZE = 4; //Increase to provide more history at expense of cpu/memory. + + static const S32 NUM_WAVE_DATA_VALUES = NUM_LINE_STRIPS * WAVE_DATA_STEP_SIZE; //Actual buffer size. Don't toy with this. Change above vars to tweak. + static F32 buf[NUM_WAVE_DATA_VALUES]; + + const LLRect& root_rect = mVisualizer->getRect(); + + F32 height = root_rect.getHeight(); + F32 height_scale = height / 2.f; //WaveData ranges from 1 to -1, so height_scale = height / 2 + F32 width = root_rect.getWidth(); + F32 width_scale = width / (F32)NUM_WAVE_DATA_VALUES; + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4fv(mOscillatorColor.mV); + gGL.pushMatrix(); + const auto& ui_scale = gGL.getUIScale(); + F32 x = (F32) root_rect.mLeft * ui_scale[VX]; + F32 y = (F32) (root_rect.mBottom + height * 0.5f) * ui_scale[VY]; + gGL.translatef(x, y, 0.f); + gGL.begin( LLRender::LINE_STRIP ); + if(mPlayState == STATE_PAUSED + || !gAudiop->getStreamingAudioImpl()->getWaveData(&buf[0], NUM_WAVE_DATA_VALUES,WAVE_DATA_STEP_SIZE)) + { + gGL.vertex2i(0, 0); + gGL.vertex2i((S32)width, 0); + } + else + for(S32 i = NUM_WAVE_DATA_VALUES - 1; i >= 0; i -= WAVE_DATA_STEP_SIZE) + gGL.vertex2f((F32)i * width_scale, buf[i] * height_scale); + gGL.end(); + gGL.popMatrix(); + gGL.flush(); +} + +bool ALPanelMusicTicker::setPaused(bool pause) +{ + if(pause == (mPlayState == STATE_PAUSED)) + return false; + mPlayState = pause ? STATE_PAUSED : STATE_PLAYING; + if(pause) + { + setArtist(mszPaused); + setTitle(mszPaused); + } + return true; +} + +void ALPanelMusicTicker::resetTicker() +{ + mScrollTimer.reset(); + mCurScrollChar = 0; + if(mArtistText) + mArtistText->setText(LLStringExplicit(mszArtist.substr(0, mszArtist.length() - mArtistScrollChars))); + if(mTitleText) + mTitleText->setText(LLStringExplicit(mszTitle.substr(0, mszTitle.length() - mTitleScrollChars))); +} + +bool ALPanelMusicTicker::setArtist(const std::string &artist) +{ + if(!mArtistText || mszArtist == artist) + return false; + mszArtist = artist; + mArtistText->setText(mszArtist); + mArtistScrollChars = countExtraChars(mArtistText, mszArtist); + return true; +} + +bool ALPanelMusicTicker::setTitle(const std::string &title) +{ + if(!mTitleText || mszTitle == title) + return false; + mszTitle = title; + mTitleText->setText(mszTitle); + mTitleScrollChars = countExtraChars(mTitleText, mszTitle); + return true; +} + +S32 ALPanelMusicTicker::countExtraChars(LLTextBox *texbox, const std::string &text) +{ + S32 text_width = texbox->getTextPixelWidth(); + S32 box_width = texbox->getRect().getWidth(); + if(text_width > box_width) + { + const LLFontGL* font = texbox->getFont(); + for(S32 count = 1; count < (S32)text.length(); count++) + { + //This isn't very efficient... + const std::string substr = text.substr(0, text.length() - count); + if (font->getWidth(substr) <= box_width) + return count; + } + } + return 0; +} + +void ALPanelMusicTicker::iterateTickerOffset() +{ + if((mPlayState != STATE_PAUSED) + && (mArtistScrollChars || mTitleScrollChars) + && ((!mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= 5.f) + || (mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= .5f))) + { + if(++mCurScrollChar > llmax(mArtistScrollChars, mTitleScrollChars)) + { + if(mScrollTimer.getElapsedTimeF32() >= 2.f) //pause for a bit when it reaches beyond last character. + resetTicker(); + } + else + { + mScrollTimer.reset(); + if(mArtistText && mCurScrollChar <= mArtistScrollChars) + { + mArtistText->setText(LLStringExplicit(mszArtist.substr(mCurScrollChar, mszArtist.length()-mArtistScrollChars + mCurScrollChar))); + } + if(mTitleText && mCurScrollChar <= mTitleScrollChars) + { + mTitleText->setText(LLStringExplicit(mszTitle.substr(mCurScrollChar, mszTitle.length()-mTitleScrollChars + mCurScrollChar))); + } + } + } +} diff --git a/indra/newview/alpanelmusicticker.h b/indra/newview/alpanelmusicticker.h new file mode 100644 index 0000000000000000000000000000000000000000..6e3168330db4d2a4e9a34a237b76116c42910092 --- /dev/null +++ b/indra/newview/alpanelmusicticker.h @@ -0,0 +1,72 @@ +/** +* @file alpanelmusicticker.h +* @brief ALPanelMusicTicker declaration +* +* $LicenseInfo:firstyear=2015&license=viewerlgpl$ +* Copyright (C) Shyotl Kuhr +* Copyright (C) 2015 Drake Arconis +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* $/LicenseInfo$ +**/ + +#ifndef AL_PANELMUSICTICKER_H +#define AL_PANELMUSICTICKER_H + +#include "llpanel.h" + +class LLIconCtrl; +class LLTextBox; + +class ALPanelMusicTicker final : public LLPanel +{ +public: + ALPanelMusicTicker(); //ctor + + BOOL postBuild() final override; + void draw() final override; + void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE) final override; +private: + void updateTickerText(); //called via draw. + void drawOscilloscope(); //called via draw. + bool setPaused(bool pause); //returns true on state change. + void resetTicker(); //Resets tickers to their innitial values (no offset). + bool setArtist(const std::string &artist); //returns true on change + bool setTitle(const std::string &title); //returns true on change + S32 countExtraChars(LLTextBox *texbox, const std::string &text); //calculates how many characters are truncated by bounds. + void iterateTickerOffset(); //Logic that actually shuffles the text to the left. + + enum ePlayState + { + STATE_PAUSED, + STATE_PLAYING + }; + + ePlayState mPlayState; + std::string mszLoading; + std::string mszPaused; + std::string mszArtist; + std::string mszTitle; + LLTimer mScrollTimer; + LLTimer mLoadTimer; + S32 mArtistScrollChars; + S32 mTitleScrollChars; + S32 mCurScrollChar; + + LLColor4 mOscillatorColor; + + //UI elements + LLTextBox* mArtistText; + LLTextBox* mTitleText; + LLUICtrl* mVisualizer; +}; + +#endif // AL_PANELMUSICTICKER_H diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index df0a627350e0a5ac57d297fa562b6c72b44d2dad..8b525b7b019bcd6335997dbcf1f5ae962f81ba9a 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2327,10 +2327,10 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, std::string full_settings_path; if (file.file_name_setting.isProvided() - && gSavedSettings.controlExists(file.file_name_setting)) + && gSavedSettings.controlExists(file.file_name_setting.getValue())) { // try to find filename stored in file_name_setting control - full_settings_path = gSavedSettings.getString(file.file_name_setting); + full_settings_path = gSavedSettings.getString(file.file_name_setting.getValue()); if (full_settings_path.empty()) { continue; diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 27d69264b07da6f9e84b50004f69019743bea323..2173347c0f0f761831040a546675265322698f2c 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -93,7 +93,7 @@ class LLObjectIMHandler : public LLCommandHandler } LLUUID object_id; - if (!object_id.set(params[0], FALSE)) + if (!object_id.set(params[0].asStringRef(), FALSE)) { return false; } diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index 8896de14db5f6794002462b8578180044f3d821f..7e6db3652aae6ef23bb7166625e8fe431cb8363c 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -65,12 +65,12 @@ class LLObjectHandler : public LLCommandHandler if (params.size() < 2) return false; LLUUID object_id; - if (!object_id.set(params[0], FALSE)) + if (!object_id.set(params[0].asStringRef(), FALSE)) { return false; } - const std::string verb = params[1].asString(); + const std::string& verb = params[1].asStringRef(); if (verb == "inspect") { diff --git a/indra/newview/llfirstuse.cpp b/indra/newview/llfirstuse.cpp index 65c457da7235c16075abc549668a5fc0388d8080..f94954264ec74653a97f0f68002df65f98f3c7c9 100644 --- a/indra/newview/llfirstuse.cpp +++ b/indra/newview/llfirstuse.cpp @@ -170,7 +170,7 @@ bool LLFirstUse::processNotification(const LLSD& notify) if (notification) { // disable any future notifications - gWarningSettings.setBOOL(notification->getPayload()["control_var"], FALSE); + gWarningSettings.setBOOL(notification->getPayload()["control_var"].asStringRef(), FALSE); } } return false; diff --git a/indra/newview/llfloatersearch.cpp b/indra/newview/llfloatersearch.cpp index 779542cfcc8821d83232b693f5f02ae7663f1b72..31ac7c57071594dad28a40864bb182fd4461109c 100644 --- a/indra/newview/llfloatersearch.cpp +++ b/indra/newview/llfloatersearch.cpp @@ -157,9 +157,9 @@ void LLFloaterSearch::search(const SearchQuery &p) // work out the subdir to use based on the requested category LLSD subs; - if (mCategoryPaths.has(p.category)) + if (mCategoryPaths.has(p.category.getValue())) { - subs["CATEGORY"] = mCategoryPaths[p.category].asString(); + subs["CATEGORY"] = mCategoryPaths[p.category.getValue()].asString(); } else { diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 61f2662bfa792f4a7e6e215a3ca98ffbec8fff7c..fc7edbd4e361291756a653f0542fabe9d79b8a18 100644 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -179,7 +179,7 @@ class LLMapTrackAvatarHandler : public LLCommandHandler //Get the ID LLUUID id; - if (!id.set( params[0], FALSE )) + if (!id.set( params[0].asStringRef(), FALSE )) { return false; } diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp index c33ff3e709fb64b76847a3dc758b3601edd44987..81d6f086964784dac66577d79bc3d5fc466f5a71 100644 --- a/indra/newview/llgroupactions.cpp +++ b/indra/newview/llgroupactions.cpp @@ -96,7 +96,7 @@ class LLGroupHandler : public LLCommandHandler } LLUUID group_id; - if (!group_id.set(tokens[0], FALSE)) + if (!group_id.set(tokens[0].asStringRef(), FALSE)) { return false; } diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index e6397532a9d3932361774b8ee3b2cebba31de35c..3c28396be0e2ff5356618eb57305fa532e1857a9 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -3805,8 +3805,8 @@ void LLMeshRepository::notifyLoadedMeshes() { inventory_data& data = mInventoryQ.front(); - LLAssetType::EType asset_type = LLAssetType::lookup(data.mPostData["asset_type"].asString()); - LLInventoryType::EType inventory_type = LLInventoryType::lookup(data.mPostData["inventory_type"].asString()); + LLAssetType::EType asset_type = LLAssetType::lookup(data.mPostData["asset_type"].asStringRef()); + LLInventoryType::EType inventory_type = LLInventoryType::lookup(data.mPostData["inventory_type"].asStringRef()); // Handle addition of texture, if any. if ( data.mResponse.has("new_texture_folder_id") ) diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp index 3687584492070381d115530c9e9248c5e6a1da5d..043e739457f6aeb5f5ad40ac015c77a6697c6036 100644 --- a/indra/newview/llpanelplaces.cpp +++ b/indra/newview/llpanelplaces.cpp @@ -104,7 +104,7 @@ class LLParcelHandler : public LLCommandHandler } LLUUID parcel_id; - if (!parcel_id.set(params[0], FALSE)) + if (!parcel_id.set(params[0].asStringRef(), FALSE)) { return false; } diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 6d6ba1ce0c4e5803574ec0e633189cb9b573133e..dfa3be8c661a39a992a512a8594936a571352eff 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -124,7 +124,7 @@ class LLAgentHandler : public LLCommandHandler { if (params.size() < 2) return false; LLUUID avatar_id; - if (!avatar_id.set(params[0], FALSE)) + if (!avatar_id.set(params[0].asStringRef(), FALSE)) { return false; } diff --git a/indra/newview/llpanelprofileclassifieds.cpp b/indra/newview/llpanelprofileclassifieds.cpp index 825fea7981f81ca6c7c11277261631bce3b66b21..161826ee56aa25b7b76710eaa4ad7e3d737df2b1 100644 --- a/indra/newview/llpanelprofileclassifieds.cpp +++ b/indra/newview/llpanelprofileclassifieds.cpp @@ -101,7 +101,7 @@ class LLClassifiedHandler : public LLCommandHandler // get the ID for the classified LLUUID classified_id; - if (!classified_id.set(params[0], FALSE)) + if (!classified_id.set(params[0].asStringRef(), FALSE)) { return false; } diff --git a/indra/newview/llpanelprofilepicks.cpp b/indra/newview/llpanelprofilepicks.cpp index 17132fcd3d91b87d1db64017c20a8c356d0e618f..d596aad73ae20dd7bfc44ff4528af8504e212c28 100644 --- a/indra/newview/llpanelprofilepicks.cpp +++ b/indra/newview/llpanelprofilepicks.cpp @@ -88,7 +88,7 @@ class LLPickHandler : public LLCommandHandler // get the ID for the pick_id LLUUID pick_id; - if (!pick_id.set(params[0], FALSE)) + if (!pick_id.set(params[0].asStringRef(), FALSE)) { return false; } diff --git a/indra/newview/llshareavatarhandler.cpp b/indra/newview/llshareavatarhandler.cpp index 142e00c3f7e5203437cc1848cd51e5ccfd49edf7..09de61509c75be8bb4c317c176e6f150a03bde0a 100644 --- a/indra/newview/llshareavatarhandler.cpp +++ b/indra/newview/llshareavatarhandler.cpp @@ -54,7 +54,7 @@ class LLShareWithAvatarHandler : public LLCommandHandler //Get the ID LLUUID id; - if (!id.set( params[0], FALSE )) + if (!id.set( params[0].asStringRef(), FALSE )) { return false; } diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index e6d2ff357df567909830166e5cf8e4d9472f851d..f1b1c50a6c17722ff0fcdf12af97876690b411e1 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -393,6 +393,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("ao", "floater_ao.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<ALFloaterAO>); LLFloaterReg::add("delete_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeleteQueue>); + LLFloaterReg::add("music_ticker", "floater_music_ticker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>); LLFloaterReg::add("particle_editor", "floater_particle_editor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<ALFloaterParticleEditor>); LLFloaterReg::add("quick_settings", "floater_quick_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>); LLFloaterReg::add("region_tracker", "floater_region_tracker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<ALFloaterRegionTracker>); diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 47cae6f6136e7625f6a7e0e39cd556524b0bb197..d3cec8b4dbdb84f8dc5b7df11a5f188a3efb2713 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -275,12 +275,12 @@ class LLInventoryHandler : public LLCommandHandler return false; } LLUUID inventory_id; - if (!inventory_id.set(params[0], FALSE)) + if (!inventory_id.set(params[0].asStringRef(), FALSE)) { return false; } - const std::string verb = params[1].asString(); + const std::string& verb = params[1].asStringRef(); if (verb == "select") { uuid_vec_t items_to_open; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index fe97e7915923723ef1468883ef2974d49c8c3945..94abf710abe8db833065d3ab3e946534eec955ac 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -5975,7 +5975,7 @@ bool script_question_cb(const LLSD& notification, const LLSD& response) // [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) if ( (allowed) && (notification["payload"].has("rlv_blocked")) ) { - RlvUtil::notifyBlocked(notification["payload"]["rlv_blocked"], LLSD().with("OBJECT", notification["payload"]["object_name"])); + RlvUtil::notifyBlocked(notification["payload"]["rlv_blocked"].asStringRef(), LLSD().with("OBJECT", notification["payload"]["object_name"])); } // [/RLVa:KB] diff --git a/indra/newview/llvoicecallhandler.cpp b/indra/newview/llvoicecallhandler.cpp index 1e993d13843aaf3af2c93fa95ebd55508ee0f36b..8d8de80cf45433b11156d8a47ef5c8066b892a51 100644 --- a/indra/newview/llvoicecallhandler.cpp +++ b/indra/newview/llvoicecallhandler.cpp @@ -54,7 +54,7 @@ class LLVoiceCallAvatarHandler : public LLCommandHandler //Get the ID LLUUID id; - if (!id.set( params[0], FALSE )) + if (!id.set(params[0].asStringRef(), FALSE )) { return false; } diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index 4e4cb381e3de166bb2ad033a9d12c985a8437981..89d8e8f7266f039db2ffa0e316aaba38340a0ffa 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -466,7 +466,7 @@ class LLVoiceClient final : public LLParamSingleton<LLVoiceClient> /// @name Voice effects //@{ bool getVoiceEffectEnabled() const { return mVoiceEffectEnabled; }; - LLUUID getVoiceEffectDefault() const { return LLUUID(mVoiceEffectDefault); }; + LLUUID getVoiceEffectDefault() const { return LLUUID(mVoiceEffectDefault()); }; // Returns NULL if voice effects are not supported, or not enabled. LLVoiceEffectInterface* getVoiceEffectInterface() const; diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index 130dcc7d71fc4d1d711b5548af87a1ee83167cf1..5365a8c1cd5e931e28d2495a21343dd921701e6d 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -618,11 +618,7 @@ bool RlvActions::isRlvEnabled() return RlvHandler::isEnabled(); } -#ifdef CATZNIP_STRINGVIEW -void RlvActions::notifyBlocked(const boost::string_view& strNotifcation, const LLSD& sdArgs) -#else -void RlvActions::notifyBlocked(const std::string& strNotifcation, const LLSD& sdArgs) -#endif // CATZNIP_STRINGVIEW +void RlvActions::notifyBlocked(std::string_view strNotifcation, const LLSD& sdArgs) { RlvUtil::notifyBlocked(strNotifcation, sdArgs); } diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h index fb2e14f7aafabff85044fae8f0e84831ff17055e..4ac4cd23e6b42503fac4f6f315b6b5bf5e1a37fa 100644 --- a/indra/newview/rlvactions.h +++ b/indra/newview/rlvactions.h @@ -20,6 +20,8 @@ #include "llchat.h" #include "rlvdefines.h" +#include <absl/strings/string_view.h> + // ============================================================================ // Forward declarations // @@ -329,11 +331,7 @@ class RlvActions /* * Shows one of the blocked toast notifications (see rlva_strings.xml) */ -#ifdef CATZNIP_STRINGVIEW - static void notifyBlocked(const boost::string_view& strNotifcation, const LLSD& sdArgs = LLSD()); -#else - static void notifyBlocked(const std::string& strNotifcation, const LLSD& sdArgs = LLSD()); -#endif // CATZNIP_STRINGVIEW + static void notifyBlocked(std::string_view strNotifcation, const LLSD& sdArgs = LLSD()); }; // ============================================================================ diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp index 5d6c7e7ea70e528b8e6dd01c3cb7146a05dd085c..953a339daee1d427aa95ddad9f986c1e04b05948 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -360,11 +360,7 @@ const std::string& RlvStrings::getAnonym(const std::string& strName) } // Checked: 2011-11-08 (RLVa-1.5.0) -#ifdef CATZNIP_STRINGVIEW -const std::string& RlvStrings::getString(const boost::string_view& strStringName) -#else -const std::string& RlvStrings::getString(const std::string& strStringName) -#endif // CATZNIP_STRINGVIEW +const std::string& RlvStrings::getString(std::string_view strStringName) { static const std::string strMissing = "(Missing RLVa string)"; string_map_t::const_iterator itString = m_StringMap.find(strStringName); @@ -534,7 +530,7 @@ void RlvUtil::filterScriptQuestions(S32& nQuestions, LLSD& sdPayload) if ((!gRlvAttachmentLocks.canAttach()) && (SCRIPT_PERMISSIONS[SCRIPT_PERMISSION_ATTACH].permbit & nQuestions)) { // Notify the user that we blocked it since they're not allowed to wear any new attachments - sdPayload["rlv_blocked"] = RlvStringKeys::Blocked::PermissionAttach; + sdPayload["rlv_blocked"] = std::string(RlvStringKeys::Blocked::PermissionAttach); nQuestions &= ~SCRIPT_PERMISSIONS[SCRIPT_PERMISSION_ATTACH].permbit; } @@ -542,7 +538,7 @@ void RlvUtil::filterScriptQuestions(S32& nQuestions, LLSD& sdPayload) if ((gRlvHandler.hasBehaviour(RLV_BHVR_TPLOC)) && (SCRIPT_PERMISSIONS[SCRIPT_PERMISSION_TELEPORT].permbit & nQuestions)) { // Notify the user that we blocked it since they're not allowed to teleport - sdPayload["rlv_blocked"] = RlvStringKeys::Blocked::PermissionTeleport; + sdPayload["rlv_blocked"] = std::string(RlvStringKeys::Blocked::PermissionTeleport); nQuestions &= ~SCRIPT_PERMISSIONS[SCRIPT_PERMISSION_TELEPORT].permbit; } @@ -584,11 +580,7 @@ bool RlvUtil::isNearbyRegion(const std::string& strRegion) } // Checked: 2011-04-11 (RLVa-1.3.0h) | Modified: RLVa-1.3.0h -#ifdef CATZNIP_STRINGVIEW -void RlvUtil::notifyBlocked(const boost::string_view& strNotifcation, const LLSD& sdArgs, bool fLogToChat) -#else -void RlvUtil::notifyBlocked(const std::string& strNotifcation, const LLSD& sdArgs, bool fLogToChat) -#endif // CATZNIP_STRINGVIEW +void RlvUtil::notifyBlocked(std::string_view strNotifcation, const LLSD& sdArgs, bool fLogToChat) { std::string strMsg = RlvStrings::getString(strNotifcation); LLStringUtil::format(strMsg, sdArgs); diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h index 216b5320d37c57a8534ab061536fc129c9a8931b..6bc9ef831a5b4bde6f480d877e3ca7eb0dac2d20 100644 --- a/indra/newview/rlvcommon.h +++ b/indra/newview/rlvcommon.h @@ -63,21 +63,13 @@ class RlvGCTimer; // RlvSettings // -#ifdef CATZNIP_STRINGVIEW -template<typename T> inline T rlvGetSetting(const boost::string_view& strSetting, const T& defaultValue) -#else -template<typename T> inline T rlvGetSetting(const std::string& strSetting, const T& defaultValue) -#endif // CATZNIP_STRINGVIEW +template<typename T> inline T rlvGetSetting(std::string_view strSetting, const T& defaultValue) { RLV_ASSERT_DBG(gSavedSettings.controlExists(strSetting)); return (gSavedSettings.controlExists(strSetting)) ? gSavedSettings.get<T>(strSetting) : defaultValue; } -#ifdef CATZNIP_STRINGVIEW -template<typename T> inline T rlvGetPerUserSetting(const boost::string_view& strSetting, const T& defaultValue) -#else -template<typename T> inline T rlvGetPerUserSetting(const std::string& strSetting, const T& defaultValue) -#endif // CATZNIP_STRINGVIEW +template<typename T> inline T rlvGetPerUserSetting(std::string_view strSetting, const T& defaultValue) { RLV_ASSERT_DBG(gSavedPerAccountSettings.controlExists(strSetting)); return (gSavedPerAccountSettings.controlExists(strSetting)) ? gSavedPerAccountSettings.get<T>(strSetting) : defaultValue; @@ -153,11 +145,7 @@ class RlvStrings static const std::string& getAnonym(const LLAvatarName& avName); // @shownames static const std::string& getAnonym(const std::string& strName); // @shownames -#ifdef CATZNIP_STRINGVIEW - static const std::string& getString(const boost::string_view& strStringName); -#else - static const std::string& getString(const std::string& strStringName); -#endif // CATZNIP_STRINGVIEW + static const std::string& getString(std::string_view strStringName); static const char* getStringFromReturnCode(ERlvCmdRet eRet); static const std::string& getStringMapPath() { return m_StringMapPath; } static std::string getVersion(const LLUUID& idRlvObject, bool fLegacy = false); @@ -192,12 +180,7 @@ class RlvUtil static bool isForceTp() { return m_fForceTp; } static void forceTp(const LLVector3d& posDest); // Ignores restrictions that might otherwise prevent tp'ing -#ifdef CATZNIP_STRINGVIEW - static void notifyBlocked(const std::string& strNotifcation, const LLSD& sdArgs = LLSD(), bool fLogToChat = false) { notifyBlocked(boost::string_view(strNotifcation), sdArgs, fLogToChat); } - static void notifyBlocked(const boost::string_view& strNotifcation, const LLSD& sdArgs = LLSD(), bool fLogToChat = false); -#else - static void notifyBlocked(const std::string& strNotifcation, const LLSD& sdArgs = LLSD(), bool fLogToChat = false); -#endif // CATZNIP_STRINGVIEW + static void notifyBlocked(std::string_view strNotifcation, const LLSD& sdArgs = LLSD(), bool fLogToChat = false); static void notifyBlockedGeneric() { notifyBlocked(RlvStringKeys::Blocked::Generic); } static void notifyBlockedViewXXX(LLAssetType::EType assetType) { notifyBlocked(RlvStringKeys::Blocked::ViewXxx, LLSD().with("[TYPE]", LLAssetType::lookup(assetType))); } static void notifyFailedAssertion(const std::string& strAssert, const std::string& strFile, int nLine); diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index ca3180d5c18ccad603422bcf7ac4e4016a44a27e..f9563492803f3365e49a39d7cdebbd657513ee0b 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -16,9 +16,7 @@ #pragma once -#ifdef CATZNIP_STRINGVIEW -#include "llstringview.h" -#endif // CATZNIP_STRINGVIE +#include <absl/strings/string_view.h> // ============================================================================ // Defines @@ -369,57 +367,31 @@ enum ERlvAttachGroupType namespace RlvSettingNames { -#ifdef CATZNIP_STRINGVIEW - /*inline*/ constexpr boost::string_view Main = make_string_view("RestrainedLove"); - /*inline*/ constexpr boost::string_view Debug = make_string_view("RestrainedLoveDebug"); - /*inline*/ constexpr boost::string_view CanOoc = make_string_view("RestrainedLoveCanOOC"); - /*inline*/ constexpr boost::string_view ForbidGiveToRlv = make_string_view("RestrainedLoveForbidGiveToRLV"); - /*inline*/ constexpr boost::string_view NoSetEnv = make_string_view("RestrainedLoveNoSetEnv"); - /*inline*/ constexpr boost::string_view ShowEllipsis = make_string_view("RestrainedLoveShowEllipsis"); - /*inline*/ constexpr boost::string_view WearAddPrefix = make_string_view("RestrainedLoveStackWhenFolderBeginsWith"); - /*inline*/ constexpr boost::string_view WearReplacePrefix = make_string_view("RestrainedLoveReplaceWhenFolderBeginsWith"); - - /*inline*/ constexpr boost::string_view DebugHideUnsetDup = make_string_view("RLVaDebugHideUnsetDuplicate"); - /*inline*/ constexpr boost::string_view EnableIMQuery = make_string_view("RLVaEnableIMQuery"); - /*inline*/ constexpr boost::string_view EnableLegacyNaming = make_string_view("RLVaEnableLegacyNaming"); - /*inline*/ constexpr boost::string_view EnableSharedWear = make_string_view("RLVaEnableSharedWear"); - /*inline*/ constexpr boost::string_view EnableTempAttach = make_string_view("RLVaEnableTemporaryAttachments"); - /*inline*/ constexpr boost::string_view HideLockedLayer = make_string_view("RLVaHideLockedLayers"); - /*inline*/ constexpr boost::string_view HideLockedAttach = make_string_view("RLVaHideLockedAttachments"); - /*inline*/ constexpr boost::string_view HideLockedInventory = make_string_view("RLVaHideLockedInventory"); - /*inline*/ constexpr boost::string_view LoginLastLocation = make_string_view("RLVaLoginLastLocation"); - /*inline*/ constexpr boost::string_view SharedInvAutoRename = make_string_view("RLVaSharedInvAutoRename"); - /*inline*/ constexpr boost::string_view ShowAssertionFail = make_string_view("RLVaShowAssertionFailures"); - /*inline*/ constexpr boost::string_view ShowRedirectChatTyping = make_string_view("RLVaShowRedirectChatTyping"); - /*inline*/ constexpr boost::string_view SplitRedirectChat = make_string_view("RLVaSplitRedirectChat"); - /*inline*/ constexpr boost::string_view TopLevelMenu = make_string_view("RLVaTopLevelMenu"); - /*inline*/ constexpr boost::string_view WearReplaceUnlocked = make_string_view("RLVaWearReplaceUnlocked"); -#else - constexpr const char Main[] = "RestrainedLove"; - constexpr const char Debug[] = "RestrainedLoveDebug"; - constexpr const char CanOoc[] = "RestrainedLoveCanOOC"; - constexpr const char ForbidGiveToRlv[] = "RestrainedLoveForbidGiveToRLV"; - constexpr const char NoSetEnv[] = "RestrainedLoveNoSetEnv"; - constexpr const char ShowEllipsis[] = "RestrainedLoveShowEllipsis"; - constexpr const char WearAddPrefix[] = "RestrainedLoveStackWhenFolderBeginsWith"; - constexpr const char WearReplacePrefix[] = "RestrainedLoveReplaceWhenFolderBeginsWith"; - - constexpr const char DebugHideUnsetDup[] = "RLVaDebugHideUnsetDuplicate"; - constexpr const char EnableIMQuery[] = "RLVaEnableIMQuery"; - constexpr const char EnableLegacyNaming[] = "RLVaEnableLegacyNaming"; - constexpr const char EnableSharedWear[] = "RLVaEnableSharedWear"; - constexpr const char EnableTempAttach[] = "RLVaEnableTemporaryAttachments"; - constexpr const char HideLockedLayer[] = "RLVaHideLockedLayers"; - constexpr const char HideLockedAttach[] = "RLVaHideLockedAttachments"; - constexpr const char HideLockedInventory[] = "RLVaHideLockedInventory"; - constexpr const char LoginLastLocation[] = "RLVaLoginLastLocation"; - constexpr const char SharedInvAutoRename[] = "RLVaSharedInvAutoRename"; - constexpr const char ShowAssertionFail[] = "RLVaShowAssertionFailures"; - constexpr const char ShowRedirectChatTyping[] = "RLVaShowRedirectChatTyping"; - constexpr const char SplitRedirectChat[] = "RLVaSplitRedirectChat"; - constexpr const char TopLevelMenu[] = "RLVaTopLevelMenu"; - constexpr const char WearReplaceUnlocked[] = "RLVaWearReplaceUnlocked"; -#endif // CATZNIP_STRINGVIEW + using namespace std::string_view_literals; + inline constexpr std::string_view Main = "RestrainedLove"sv; + inline constexpr std::string_view Debug = "RestrainedLoveDebug"sv; + inline constexpr std::string_view CanOoc = "RestrainedLoveCanOOC"sv; + inline constexpr std::string_view ForbidGiveToRlv = "RestrainedLoveForbidGiveToRLV"sv; + inline constexpr std::string_view NoSetEnv = "RestrainedLoveNoSetEnv"sv; + inline constexpr std::string_view ShowEllipsis = "RestrainedLoveShowEllipsis"sv; + inline constexpr std::string_view WearAddPrefix = "RestrainedLoveStackWhenFolderBeginsWith"sv; + inline constexpr std::string_view WearReplacePrefix = "RestrainedLoveReplaceWhenFolderBeginsWith"sv; + + inline constexpr std::string_view DebugHideUnsetDup = "RLVaDebugHideUnsetDuplicate"sv; + inline constexpr std::string_view EnableIMQuery = "RLVaEnableIMQuery"sv; + inline constexpr std::string_view EnableLegacyNaming = "RLVaEnableLegacyNaming"sv; + inline constexpr std::string_view EnableSharedWear = "RLVaEnableSharedWear"sv; + inline constexpr std::string_view EnableTempAttach = "RLVaEnableTemporaryAttachments"sv; + inline constexpr std::string_view HideLockedLayer = "RLVaHideLockedLayers"sv; + inline constexpr std::string_view HideLockedAttach = "RLVaHideLockedAttachments"sv; + inline constexpr std::string_view HideLockedInventory = "RLVaHideLockedInventory"sv; + inline constexpr std::string_view LoginLastLocation = "RLVaLoginLastLocation"sv; + inline constexpr std::string_view SharedInvAutoRename = "RLVaSharedInvAutoRename"sv; + inline constexpr std::string_view ShowAssertionFail = "RLVaShowAssertionFailures"sv; + inline constexpr std::string_view ShowRedirectChatTyping = "RLVaShowRedirectChatTyping"sv; + inline constexpr std::string_view SplitRedirectChat = "RLVaSplitRedirectChat"sv; + inline constexpr std::string_view TopLevelMenu = "RLVaTopLevelMenu"sv; + inline constexpr std::string_view WearReplaceUnlocked = "RLVaWearReplaceUnlocked"sv; } // ============================================================================ @@ -430,67 +402,39 @@ namespace RlvStringKeys { namespace Blocked { -#ifdef CATZNIP_STRINGVIEW - /*inline*/ constexpr boost::string_view AutoPilot = make_string_view("blocked_autopilot"); - /*inline*/ constexpr boost::string_view Generic = make_string_view("blocked_generic"); - /*inline*/ constexpr boost::string_view GroupChange = make_string_view("blocked_groupchange"); - /*inline*/ constexpr boost::string_view InvFolder = make_string_view("blocked_invfolder"); - /*inline*/ constexpr boost::string_view PermissionAttach = make_string_view("blocked_permattach"); - /*inline*/ constexpr boost::string_view PermissionTeleport = make_string_view("blocked_permteleport"); - /*inline*/ constexpr boost::string_view RecvIm = make_string_view("blocked_recvim"); - /*inline*/ constexpr boost::string_view RecvImRemote = make_string_view("blocked_recvim_remote"); - /*inline*/ constexpr boost::string_view SendIm = make_string_view("blocked_sendim"); - /*inline*/ constexpr boost::string_view StartConference = make_string_view("blocked_startconf"); - /*inline*/ constexpr boost::string_view StartIm = make_string_view("blocked_startim"); - /*inline*/ constexpr boost::string_view Teleport = make_string_view("blocked_teleport"); - /*inline*/ constexpr boost::string_view TeleportOffer = make_string_view("blocked_teleport_offer"); - /*inline*/ constexpr boost::string_view TpLureRequestRemote = make_string_view("blocked_tplurerequest_remote"); - /*inline*/ constexpr boost::string_view ViewXxx = make_string_view("blocked_viewxxx"); - /*inline*/ constexpr boost::string_view Wireframe = make_string_view("blocked_wireframe"); -#else - constexpr const char AutoPilot[] = "blocked_autopilot"; - constexpr const char Generic[] = "blocked_generic"; - constexpr const char GroupChange[] = "blocked_groupchange"; - constexpr const char InvFolder[] = "blocked_invfolder"; - constexpr const char PermissionAttach[] = "blocked_permattach"; - constexpr const char PermissionTeleport[] = "blocked_permteleport"; - constexpr const char RecvIm[] = "blocked_recvim"; - constexpr const char RecvImRemote[] = "blocked_recvim_remote"; - constexpr const char SendIm[] = "blocked_sendim"; - constexpr const char StartConference[] = "blocked_startconf"; - constexpr const char StartIm[] = "blocked_startim"; - constexpr const char Teleport[] = "blocked_teleport"; - constexpr const char TeleportOffer[] = "blocked_teleport_offer"; - constexpr const char TpLureRequestRemote[] = "blocked_tplurerequest_remote"; - constexpr const char ViewXxx[] = "blocked_viewxxx"; - constexpr const char Wireframe[] = "blocked_wireframe"; -#endif // CATZNIP_STRINGVIEW + using namespace std::string_view_literals; + inline constexpr std::string_view AutoPilot = "blocked_autopilot"sv; + inline constexpr std::string_view Generic = "blocked_generic"sv; + inline constexpr std::string_view GroupChange = "blocked_groupchange"sv; + inline constexpr std::string_view InvFolder = "blocked_invfolder"sv; + inline constexpr std::string_view PermissionAttach = "blocked_permattach"sv; + inline constexpr std::string_view PermissionTeleport = "blocked_permteleport"sv; + inline constexpr std::string_view RecvIm = "blocked_recvim"sv; + inline constexpr std::string_view RecvImRemote = "blocked_recvim_remote"sv; + inline constexpr std::string_view SendIm = "blocked_sendim"sv; + inline constexpr std::string_view StartConference = "blocked_startconf"sv; + inline constexpr std::string_view StartIm = "blocked_startim"sv; + inline constexpr std::string_view Teleport = "blocked_teleport"sv; + inline constexpr std::string_view TeleportOffer = "blocked_teleport_offer"sv; + inline constexpr std::string_view TpLureRequestRemote = "blocked_tplurerequest_remote"sv; + inline constexpr std::string_view ViewXxx = "blocked_viewxxx"sv; + inline constexpr std::string_view Wireframe = "blocked_wireframe"sv; } namespace Hidden { -#ifdef CATZNIP_STRINGVIEW - /*inline*/ constexpr boost::string_view Generic = make_string_view("hidden_generic"); - /*inline*/ constexpr boost::string_view Parcel = make_string_view("hidden_parcel"); - /*inline*/ constexpr boost::string_view Region = make_string_view("hidden_region"); -#else - constexpr const char Generic[] = "hidden_generic"; - constexpr const char Parcel[] = "hidden_parcel"; - constexpr const char Region[] = "hidden_region"; -#endif // CATZNIP_STRINGVIEW + using namespace std::string_view_literals; + inline constexpr std::string_view Generic = "hidden_generic"sv; + inline constexpr std::string_view Parcel = "hidden_parcel"sv; + inline constexpr std::string_view Region = "hidden_region"sv; } namespace StopIm { -#ifdef CATZNIP_STRINGVIEW - /*inline*/ constexpr boost::string_view NoSession = make_string_view("stopim_nosession"); - /*inline*/ constexpr boost::string_view EndSessionRemote = make_string_view("stopim_endsession_remote"); - /*inline*/ constexpr boost::string_view EndSessionLocal = make_string_view("stopim_endsession_local"); -#else - constexpr const char NoSession[] = "stopim_nosession"; - constexpr const char EndSessionRemote[] = "stopim_endsession_remote"; - constexpr const char EndSessionLocal[] = "stopim_endsession_local"; -#endif // CATZNIP_STRINGVIEW + using namespace std::string_view_literals; + inline constexpr std::string_view NoSession = "stopim_nosession"sv; + inline constexpr std::string_view EndSessionRemote = "stopim_endsession_remote"sv; + inline constexpr std::string_view EndSessionLocal = "stopim_endsession_local"sv; } } diff --git a/indra/newview/rlvui.cpp b/indra/newview/rlvui.cpp index ae6a4e358af11c55fe61be91d39c184ffb1c9cdc..f02bef1510bbfbcfec3d3cb0bce55edd2b6c88cd 100644 --- a/indra/newview/rlvui.cpp +++ b/indra/newview/rlvui.cpp @@ -279,11 +279,7 @@ void RlvUIEnabler::onUpdateLoginLastLocation(bool fQuitting) // ============================================================================ -#ifdef CATZNIP_STRINGVIEW -bool RlvUIEnabler::addGenericFloaterFilter(const std::string& strFloaterName, const boost::string_view& strRlvNotification) -#else -bool RlvUIEnabler::addGenericFloaterFilter(const std::string& strFloaterName, const std::string& strRlvNotification) -#endif // CATZNIP_STRINGVIEW +bool RlvUIEnabler::addGenericFloaterFilter(const std::string& strFloaterName, std::string_view strRlvNotification) { return addGenericFloaterFilter(strFloaterName, [strRlvNotification]() { RlvUtil::notifyBlocked(strRlvNotification); }); } diff --git a/indra/newview/rlvui.h b/indra/newview/rlvui.h index 36478d6442d594cdad0ed7f5404c08c75bf5eb46..1bb2857846357b5c772705517c41aa27f71374b2 100644 --- a/indra/newview/rlvui.h +++ b/indra/newview/rlvui.h @@ -55,11 +55,7 @@ class RlvUIEnabler final : public LLSingleton<RlvUIEnabler> * Floater and sidebar validation callbacks */ public: -#ifdef CATZNIP_STRINGVIEW - bool addGenericFloaterFilter(const std::string& strFloaterName, const boost::string_view& strRlvNotification); -#else - bool addGenericFloaterFilter(const std::string& strFloaterName, const std::string& strRlvNotification); -#endif // CATZNIP_STRINGVIEW + bool addGenericFloaterFilter(const std::string& strFloaterName, std::string_view strRlvNotification); bool addGenericFloaterFilter(const std::string& strFloaterName, const std::function<void()>& fn = nullptr); bool removeGenericFloaterFilter(const std::string& strFloaterName); diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 836dabfe55284a8c602275b304a32d4d0c9da76a..957d581629e7285c4b86f65ec35173bbd17df32a 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -753,6 +753,8 @@ with the same filename but different name <texture name="cloud-particle.j2c" use_mips="true" /> <texture name="transparent.j2c" use_mips="true" /> + <texture name="Ticker_Grid" file_name="ticker_visualizer_grid.tga" preload="false" /> + <!--WARNING OLD ART BELOW *do not use*--> <texture name="icn_media_web.tga" preload="true" /> <texture name="icn_media_movie.tga" preload="true" /> diff --git a/indra/newview/skins/default/textures/ticker_visualizer_grid.tga b/indra/newview/skins/default/textures/ticker_visualizer_grid.tga new file mode 100644 index 0000000000000000000000000000000000000000..a7bb07b4e84feead52f5720b6873a1861cb1a4d4 Binary files /dev/null and b/indra/newview/skins/default/textures/ticker_visualizer_grid.tga differ diff --git a/indra/newview/skins/default/xui/en/floater_music_ticker.xml b/indra/newview/skins/default/xui/en/floater_music_ticker.xml new file mode 100644 index 0000000000000000000000000000000000000000..99daa03b410cf2de60ff6df31d945ae8b6f0487e --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_music_ticker.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + width="320" + height="39" + layout="topleft" + min_width="300" + min_height="39" + name="floater_music_ticker" + positioning="cascading" + title="" + can_minimize="false" + header_height="0" + can_resize="true" + can_resize_height="false" + show_title="false" + save_rect="true" + chrome="true"> + <panel + class="music_ticker" + name="music_ticker" + filename="panel_music_ticker.xml" + layout="topleft" + follows="all" + width="296" + top="0" + mouse_opaque="false"/> +</floater> diff --git a/indra/newview/skins/default/xui/en/panel_music_ticker.xml b/indra/newview/skins/default/xui/en/panel_music_ticker.xml new file mode 100644 index 0000000000000000000000000000000000000000..4c380ec932d7fed3471ced17c1b5ff5ca91b6ad2 --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_music_ticker.xml @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + layout="topleft" + follows="top|right|left" + width="300" + height="38" + name="music_ticker"> + <string name="paused"> + (not playing) + </string> + <string name="loading"> + (loading...) + </string> + <icon + top="19" + color="AlAshGrey" + follows="left|top|right" + height="1" + layout="topleft" + image_name="white.tga" + left="0" + mouse_opaque="false" + name="ticker_background" + width="244" /> + <locate + top="0" + bottom="-1" + left="244" + name="visualizer_box" + width="60" + follows="top|right" + use_bounding_rect="true" + layout="topleft"/> + <icon + top="0" + bottom="-1" + color="AlAshGrey" + follows="top|right" + layout="topleft" + image_name="Ticker_Grid" + left="244" + mouse_opaque="false" + name="visualizer_grid" + width="60" /> + <text + text_color="AlBlue" + bg_visible="false" + border_visible="false" + layout="topleft" + top="0" + follows="top|left" + font="SansSerifBold" + h_pad="0" + halign="left" + height="16" + left="4" + mouse_opaque="false" + name="artist_label" + v_pad="0" + width="50"> + Artist: + </text> + <text + bg_visible="false" + border_visible="false" + layout="topleft" + top="0" + follows="top|left|right" + font="SansSerifBold" + h_pad="0" + halign="left" + height="16" + left="50" + mouse_opaque="false" + name="artist_text" + v_pad="0" + width="193"> + </text> + <text + text_color="AlBlue" + bg_visible="false" + border_visible="false" + layout="topleft" + top="19" + follows="top|left" + font="SansSerifBold" + h_pad="0" + halign="left" + height="16" + left="4" + mouse_opaque="false" + name="title_label" + v_pad="0" + width="50"> + Title: + </text> + <text + bg_visible="false" + border_visible="false" + layout="topleft" + top="19" + follows="top|left|right" + font="SansSerifBold" + h_pad="0" + halign="left" + height="16" + left="50" + mouse_opaque="false" + name="title_text" + v_pad="0" + width="193"> + </text> +</panel> diff --git a/indra/newview/tests/llagentaccess_test.cpp b/indra/newview/tests/llagentaccess_test.cpp index 9a8d8bb61fa845c469cad3928b766d18c52cfa2b..a2db5a54f47dd9e2e525c27768ff451b56a08645 100644 --- a/indra/newview/tests/llagentaccess_test.cpp +++ b/indra/newview/tests/llagentaccess_test.cpp @@ -55,12 +55,12 @@ LLControlVariable* LLControlGroup::declareU32(const std::string& name, U32 initi return NULL; } -void LLControlGroup::setU32(const std::string& name, U32 val) +void LLControlGroup::setU32(const std::string_view name, U32 val) { test_preferred_maturity = val; } -U32 LLControlGroup::getU32(const std::string& name) +U32 LLControlGroup::getU32(const std::string_view name) { return test_preferred_maturity; } diff --git a/indra/newview/tests/lldateutil_test.cpp b/indra/newview/tests/lldateutil_test.cpp index 62158d8f66973fb3d3ee88900f35f23a7761a3ef..ad299448c5fa0c664bc65955e90738d21e7c43ae 100644 --- a/indra/newview/tests/lldateutil_test.cpp +++ b/indra/newview/tests/lldateutil_test.cpp @@ -38,26 +38,31 @@ // Baked-in return values for getString() -std::map< std::string, std::string > gString; +std::map< std::string, std::string, std::less<> > gString; // Baked-in return values for getCountString() // map of pairs of input xml_desc and integer count typedef std::pair< std::string, int > count_string_t; std::map< count_string_t, std::string > gCountString; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { - std::string text = gString[xml_desc]; - LLStringUtil::format(text, args); - return text; + auto it = gString.find(xml_desc); + if (it != gString.end()) + { + std::string text = it->second; + LLStringUtil::format(text, args); + return text; + } + return {}; } -std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count) +std::string LLTrans::getCountString(const std::string_view language, const 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 ") + std::string(xml_desc); } return gCountString[ count_string_t(xml_desc, count) ]; } diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp index 57f2d31eabe68f3da8940dac7a00cb21958ceb06..11711a64766333436f64d6255b6a1b0d1ef1d5b6 100644 --- a/indra/newview/tests/lllogininstance_test.cpp +++ b/indra/newview/tests/lllogininstance_test.cpp @@ -188,12 +188,12 @@ LLControlGroup gSavedSettings("Global"); LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker<LLControlGroup, std::string>(name){} LLControlGroup::~LLControlGroup() {} -void LLControlGroup::setBOOL(const std::string& name, BOOL val) {} -BOOL LLControlGroup::getBOOL(const std::string& name) { return FALSE; } -F32 LLControlGroup::getF32(const std::string& name) { return 0.0f; } +void LLControlGroup::setBOOL(const std::string_view name, BOOL val) {} +BOOL LLControlGroup::getBOOL(const std::string_view name) { return FALSE; } +F32 LLControlGroup::getF32(const std::string_view name) { return 0.0f; } U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only) { return 1; } -void LLControlGroup::setString(const std::string& name, const std::string& val) {} -std::string LLControlGroup::getString(const std::string& name) { return "test_string"; } +void LLControlGroup::setString(const std::string_view name, const std::string& val) {} +std::string LLControlGroup::getString(const std::string_view name) { return "test_string"; } LLControlVariable* LLControlGroup::declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, LLControlVariable::ePersist persist) { return NULL; } LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string &initial_val, const std::string& comment, LLControlVariable::ePersist persist) { return NULL; } diff --git a/indra/newview/tests/llsecapi_test.cpp b/indra/newview/tests/llsecapi_test.cpp index caa3016d2e9e92f0eb061ea2b89c8c0761dff90c..d27126ce2d6c8f22af83c1216b8b3a15bb26a7d0 100644 --- a/indra/newview/tests/llsecapi_test.cpp +++ b/indra/newview/tests/llsecapi_test.cpp @@ -43,8 +43,8 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} -std::string LLControlGroup::getString(const std::string& name) +void LLControlGroup::setString(const std::string_view name, const std::string& val){} +std::string LLControlGroup::getString(const std::string_view name) { return ""; } diff --git a/indra/newview/tests/llsechandler_basic_test.cpp b/indra/newview/tests/llsechandler_basic_test.cpp index e5d226a2a4966cea58d25fca2939073d71e424f6..15ca66ee013ccf352a2d10745df8b09c4116c91d 100644 --- a/indra/newview/tests/llsechandler_basic_test.cpp +++ b/indra/newview/tests/llsechandler_basic_test.cpp @@ -78,8 +78,8 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} -std::string LLControlGroup::getString(const std::string& name) +void LLControlGroup::setString(const std::string_view name, const std::string& val){} +std::string LLControlGroup::getString(const std::string_view name) { if (name == "FirstName") @@ -90,7 +90,7 @@ std::string LLControlGroup::getString(const std::string& name) } // Stub for --no-verify-ssl-cert -BOOL LLControlGroup::getBOOL(const std::string& name) { return FALSE; } +BOOL LLControlGroup::getBOOL(const std::string_view name) { return FALSE; } LLSD LLCredential::getLoginParams() { diff --git a/indra/newview/tests/llslurl_test.cpp b/indra/newview/tests/llslurl_test.cpp index 6a1b96f75a45ec3efa55a4a34b0d50fb85f1cff8..d341f8c0c1c6daeede5802a73ec3569ee09e526c 100644 --- a/indra/newview/tests/llslurl_test.cpp +++ b/indra/newview/tests/llslurl_test.cpp @@ -46,10 +46,10 @@ static const char * const TEST_FILENAME("llslurl_test.xml"); class LLTrans { public: - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); }; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { return std::string(); } @@ -58,7 +58,7 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil:: // Stub implementation to get the test to compile properly #include "../rlvhandler.h" -const std::string& RlvStrings::getString(const std::string& strStringName) +const std::string& RlvStrings::getString(const std::string_view strStringName) { static const std::string strMissing = "(Missing RLVa string)"; return strMissing; @@ -100,14 +100,14 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} +void LLControlGroup::setString(const std::string_view name, const std::string& val){} std::string gCmdLineLoginURI; std::string gCmdLineGridChoice; std::string gCmdLineHelperURI; std::string gLoginPage; std::string gCurrentGrid; -std::string LLControlGroup::getString(const std::string& name) +std::string LLControlGroup::getString(const std::string_view name) { if (name == "CmdLineGridChoice") return gCmdLineGridChoice; @@ -120,7 +120,7 @@ std::string LLControlGroup::getString(const std::string& name) return ""; } -LLSD LLControlGroup::getLLSD(const std::string& name) +LLSD LLControlGroup::getLLSD(const std::string_view name) { if (name == "CmdLineLoginURI") { @@ -132,7 +132,7 @@ LLSD LLControlGroup::getLLSD(const std::string& name) return LLSD(); } -LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name) +LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string_view name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter == mNameTable.end() ? LLPointer<LLControlVariable>() : iter->second; diff --git a/indra/newview/tests/llviewerhelputil_test.cpp b/indra/newview/tests/llviewerhelputil_test.cpp index f6456a28392b5af902743800117c0c60203f4127..d4b6b68d24da3ff219171e4a2399c2479cc5495f 100644 --- a/indra/newview/tests/llviewerhelputil_test.cpp +++ b/indra/newview/tests/llviewerhelputil_test.cpp @@ -53,8 +53,8 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} -std::string LLControlGroup::getString(const std::string& name) +void LLControlGroup::setString(const std::string_view name, const std::string& val){} +std::string LLControlGroup::getString(const std::string_view name) { if (name == "HelpURLFormat") return gHelpURL; diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp index 9fc9ca01ac8d09ed40489050e3727df7e6996ae7..b46b9ecfc572dd497a862ec4484560f5a80bd4c2 100644 --- a/indra/newview/tests/llviewernetwork_test.cpp +++ b/indra/newview/tests/llviewernetwork_test.cpp @@ -45,10 +45,10 @@ static const char * const TEST_FILENAME("llviewernetwork_test.xml"); class LLTrans { public: - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); }; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { std::string grid_label = std::string(); if(xml_desc == "AgniGridLabel") @@ -73,14 +73,14 @@ LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist) {return NULL;} -void LLControlGroup::setString(const std::string& name, const std::string& val){} +void LLControlGroup::setString(const std::string_view name, const std::string& val){} std::string gCmdLineLoginURI; std::string gCmdLineGridChoice; std::string gCmdLineHelperURI; std::string gLoginPage; std::string gCurrentGrid; -std::string LLControlGroup::getString(const std::string& name) +std::string LLControlGroup::getString(const std::string_view name) { if (name == "CmdLineGridChoice") return gCmdLineGridChoice; @@ -93,7 +93,7 @@ std::string LLControlGroup::getString(const std::string& name) return ""; } -LLSD LLControlGroup::getLLSD(const std::string& name) +LLSD LLControlGroup::getLLSD(const std::string_view name) { if (name == "CmdLineLoginURI") { @@ -105,7 +105,7 @@ LLSD LLControlGroup::getLLSD(const std::string& name) return LLSD(); } -LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name) +LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string_view name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter == mNameTable.end() ? LLPointer<LLControlVariable>() : iter->second; diff --git a/indra/newview/tests/llworldmap_test.cpp b/indra/newview/tests/llworldmap_test.cpp index f1dd8acccf10936bffc6abfd983f1a8ada5c883c..c765f83a188550e303165992edfc1220381632b0 100644 --- a/indra/newview/tests/llworldmap_test.cpp +++ b/indra/newview/tests/llworldmap_test.cpp @@ -66,7 +66,7 @@ void LLWorldMipmap::equalizeBoostLevels() { } LLPointer<LLViewerFetchedTexture> LLWorldMipmap::getObjectsTile(U32 grid_x, U32 grid_y, S32 level, bool load) { return NULL; } // Stub other stuff -std::string LLTrans::getString(const std::string &, const LLStringUtil::format_map_t&, bool def_string) { return std::string("test_trans"); } +std::string LLTrans::getString(const std::string_view, const LLStringUtil::format_map_t&, bool def_string) { return std::string("test_trans"); } void LLUIString::updateResult() const { } void LLUIString::setArg(const std::string& , const std::string& ) { } void LLUIString::assign(const std::string& ) { } diff --git a/indra/newview/tests/llworldmipmap_test.cpp b/indra/newview/tests/llworldmipmap_test.cpp index 142d75bcfd523689f275f60091377f13c6e164a0..cf6cd61262ee69f050b9c8a692ea69e831d2b142 100644 --- a/indra/newview/tests/llworldmipmap_test.cpp +++ b/indra/newview/tests/llworldmipmap_test.cpp @@ -48,7 +48,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const s LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker<LLControlGroup, std::string>(name) { } LLControlGroup::~LLControlGroup() { } -std::string LLControlGroup::getString(const std::string& ) { return std::string("test_url"); } +std::string LLControlGroup::getString(const std::string_view) { return std::string("test_url"); } LLControlGroup gSavedSettings("test_settings"); // End Stubbing