summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorNyx (Neal Orman) <nyx@lindenlab.com>2010-10-27 14:27:10 -0400
committerNyx (Neal Orman) <nyx@lindenlab.com>2010-10-27 14:27:10 -0400
commit1aee2f0d4d16548660df4995aaf3c349304962af (patch)
tree6a39c4a881013a2e0964c1f5a63567843c79ab89 /indra/llmessage
parente75fd8beb15fb89e7aba253cac989b242566c512 (diff)
parent92959895e2763e51b6ef9fab5a14e0d0930d4f2c (diff)
pull from hg.lindenlab.com/viewer-mesh to mesh-development
Note all future commits should happen in public mesh-development. Will ping internal devs to make sure they transition over.
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llcachename.cpp27
-rw-r--r--indra/llmessage/llcachename.h6
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