diff options
author | Loren Shih <seraph@lindenlab.com> | 2010-10-25 16:10:35 -0400 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2010-10-25 16:10:35 -0400 |
commit | 066986a09ee2f1c046023619242385eda345d9b5 (patch) | |
tree | a3c30313c870cdf669f9b22169a4981187625287 /indra/llmessage | |
parent | 6368f6f84958c8c3c2e48c9f47ec98c7e35308c7 (diff) | |
parent | 1a53efe23335c3a92ce1c279d7487fb979141211 (diff) |
Automated merge up from viewer-development
Diffstat (limited to 'indra/llmessage')
-rw-r--r-- | indra/llmessage/llcachename.cpp | 27 | ||||
-rw-r--r-- | indra/llmessage/llcachename.h | 6 |
2 files changed, 33 insertions, 0 deletions
diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 4a66a31c35..522b99bc02 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -38,6 +38,8 @@ #include "message.h" #include "llmemtype.h" +#include <boost/regex.hpp> + // llsd serialization constants static const std::string AGENTS("agents"); static const std::string GROUPS("groups"); @@ -551,6 +553,31 @@ std::string LLCacheName::buildUsername(const std::string& full_name) return full_name; } +//static +std::string LLCacheName::buildLegacyName(const std::string& complete_name) +{ + boost::regex complete_name_regex("(.+)( \\()([A-Za-z]+)(.[A-Za-z]+)*(\\))"); + boost::match_results<std::string::const_iterator> name_results; + if (!boost::regex_match(complete_name, name_results, complete_name_regex)) return complete_name; + + std::string legacy_name = name_results[3]; + // capitalize the first letter + std::string cap_letter = legacy_name.substr(0, 1); + LLStringUtil::toUpper(cap_letter); + legacy_name = cap_letter + legacy_name.substr(1); + + if (name_results[4].matched) + { + std::string last_name = name_results[4]; + std::string cap_letter = last_name.substr(1, 1); + LLStringUtil::toUpper(cap_letter); + last_name = cap_letter + last_name.substr(2); + legacy_name = legacy_name + " " + last_name; + } + + return legacy_name; +} + // This is a little bit kludgy. LLCacheNameCallback is a slot instead of a function pointer. // The reason it is a slot is so that the legacy get() function below can bind an old callback // and pass it as a slot. The reason it isn't a boost::function is so that trackable behavior diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index b469803060..b108e37157 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -90,6 +90,12 @@ public: // "Random Linden" -> "random.linden" static std::string buildUsername(const std::string& name); + // Converts a complete display name to a legacy name + // if possible, otherwise returns the input + // "Alias (random.linden)" -> "Random Linden" + // "Something random" -> "Something random" + static std::string buildLegacyName(const std::string& name); + // If available, this method copies the group name into the string // provided. The caller must allocate at least // DB_GROUP_NAME_BUF_SIZE characters. If not available, this |