diff options
| author | brad kittenbrink <brad@lindenlab.com> | 2010-11-02 19:02:49 -0700 | 
|---|---|---|
| committer | brad kittenbrink <brad@lindenlab.com> | 2010-11-02 19:02:49 -0700 | 
| commit | 6a9e70053beaa0fb936482f5594137a8bcdf2f1e (patch) | |
| tree | 9f6a44825ed0886807c4b38d9a92188261bbaf25 /indra/llmessage | |
| parent | 4902a2752e6ee5dfd47be3d94955f88bf73bf5d8 (diff) | |
| parent | accbddaeadeec7221c9244bf1c0245b8ccbd12bc (diff) | |
Merge
Diffstat (limited to 'indra/llmessage')
| -rw-r--r-- | indra/llmessage/llcachename.cpp | 40 | ||||
| -rw-r--r-- | indra/llmessage/llcachename.h | 6 | 
2 files changed, 46 insertions, 0 deletions
| diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 4a66a31c35..a8f53a38c3 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,44 @@ std::string LLCacheName::buildUsername(const std::string& full_name)  	return full_name;  } +//static  +std::string LLCacheName::buildLegacyName(const std::string& complete_name) +{ +	// regexp doesn't play nice with unicode, chop off the display name +	S32 open_paren = complete_name.rfind(" ("); + +	if (open_paren == std::string::npos) +	{ +		return complete_name; +	} + +	std::string username = complete_name.substr(open_paren); +	boost::regex complete_name_regex("( \\()([a-z0-9]+)(.[a-z]+)*(\\))");
 +	boost::match_results<std::string::const_iterator> name_results;
 +	if (!boost::regex_match(username, name_results, complete_name_regex)) return complete_name;
 +
 +	std::string legacy_name = name_results[2]; +	// 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[3].matched)
 +	{
 +		std::string last_name = name_results[3]; +		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;
 +	}
 +	else
 +	{
 +		legacy_name = legacy_name + " Resident";
 +	}
 +
 +	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 | 
