aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llurlsimstring.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llurlsimstring.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/llurlsimstring.cpp')
-rw-r--r--linden/indra/newview/llurlsimstring.cpp54
1 files changed, 32 insertions, 22 deletions
diff --git a/linden/indra/newview/llurlsimstring.cpp b/linden/indra/newview/llurlsimstring.cpp
index 07669db..03c6f84 100644
--- a/linden/indra/newview/llurlsimstring.cpp
+++ b/linden/indra/newview/llurlsimstring.cpp
@@ -1,5 +1,5 @@
1/** 1/**
2 * @file llsimurlstring.cpp 2 * @file llurlsimstring.cpp (was llsimurlstring.cpp)
3 * @brief Handles "SLURL fragments" like Ahern/123/45 for 3 * @brief Handles "SLURL fragments" like Ahern/123/45 for
4 * startup processing, login screen, prefs, etc. 4 * startup processing, login screen, prefs, etc.
5 * 5 *
@@ -41,13 +41,13 @@
41 41
42//static 42//static
43LLURLSimString LLURLSimString::sInstance; 43LLURLSimString LLURLSimString::sInstance;
44LLString LLURLSimString::sLocationStringHome("My Home"); 44std::string LLURLSimString::sLocationStringHome("My Home");
45LLString LLURLSimString::sLocationStringLast("My Last Location"); 45std::string LLURLSimString::sLocationStringLast("My Last Location");
46 46
47// "secondlife://simname/x/y/z" -> "simname/x/y/z" 47// "secondlife://simname/x/y/z" -> "simname/x/y/z"
48// (actually .*//foo -> foo) 48// (actually .*//foo -> foo)
49// static 49// static
50void LLURLSimString::setString(const LLString& sim_string) 50void LLURLSimString::setString(const std::string& sim_string)
51{ 51{
52 sInstance.mSimString.clear(); 52 sInstance.mSimString.clear();
53 sInstance.mSimName.clear(); 53 sInstance.mSimName.clear();
@@ -63,29 +63,31 @@ void LLURLSimString::setString(const LLString& sim_string)
63 else 63 else
64 { 64 {
65 char* curlstr = curl_unescape(sim_string.c_str(), sim_string.size()); 65 char* curlstr = curl_unescape(sim_string.c_str(), sim_string.size());
66 LLString tstring = LLString(curlstr); 66 std::string tstring = std::string(curlstr);
67 curl_free(curlstr); 67 curl_free(curlstr);
68 std::string::size_type idx = tstring.find("//"); 68 std::string::size_type idx = tstring.find("//");
69 idx = (idx == LLString::npos) ? 0 : idx+2; 69 idx = (idx == std::string::npos) ? 0 : idx+2;
70 sInstance.mSimString = tstring.substr(idx); 70 sInstance.mSimString = tstring.substr(idx);
71 } 71 }
72} 72}
73 73
74// "/100" -> 100 74// "/100" -> 100
75// static 75// static
76S32 LLURLSimString::parseGridIdx(const LLString& in_string, S32 idx0, S32* res) 76std::string::size_type LLURLSimString::parseGridIdx(const std::string& in_string,
77 std::string::size_type idx0,
78 std::string::size_type* res)
77{ 79{
78 if (idx0 == LLString::npos || in_string[idx0] != '/') 80 if (idx0 == std::string::npos || in_string[idx0] != '/')
79 { 81 {
80 return (S32)LLString::npos; // parse error 82 return std::string::npos; // parse error
81 } 83 }
82 idx0++; 84 idx0++;
83 LLString::size_type idx1 = in_string.find_first_of('/', idx0); 85 std::string::size_type idx1 = in_string.find_first_of('/', idx0);
84 LLString::size_type len = (idx1 == LLString::npos) ? LLString::npos : idx1-idx0; 86 std::string::size_type len = (idx1 == std::string::npos) ? std::string::npos : idx1-idx0;
85 LLString tstring = in_string.substr(idx0,len); 87 std::string tstring = in_string.substr(idx0,len);
86 if (!tstring.empty()) 88 if (!tstring.empty())
87 { 89 {
88 S32 val = atoi(tstring.c_str()); 90 std::string::size_type val = atoi(tstring.c_str());
89 *res = val; 91 *res = val;
90 } 92 }
91 return idx1; 93 return idx1;
@@ -118,24 +120,32 @@ bool LLURLSimString::parse()
118} 120}
119 121
120// static 122// static
121bool LLURLSimString::parse(const LLString& sim_string, std::string *region_name, S32 *x, S32 *y, S32 *z) 123bool LLURLSimString::parse(const std::string& sim_string,
124 std::string *region_name,
125 S32 *x, S32 *y, S32 *z)
122{ 126{
123 // strip any bogus initial '/' 127 // strip any bogus initial '/'
124 LLString::size_type idx0 = sim_string.find_first_not_of('/'); 128 std::string::size_type idx0 = sim_string.find_first_not_of('/');
125 if (idx0 == std::string::npos) idx0 = 0; 129 if (idx0 == std::string::npos) idx0 = 0;
126 130
127 LLString::size_type idx1 = sim_string.find_first_of('/', idx0); 131 std::string::size_type idx1 = sim_string.find_first_of('/', idx0);
128 LLString::size_type len = (idx1 == std::string::npos) ? std::string::npos : idx1-idx0; 132 std::string::size_type len = (idx1 == std::string::npos) ? std::string::npos : idx1-idx0;
129 LLString tstring = sim_string.substr(idx0,len); 133 std::string tstring = sim_string.substr(idx0,len);
130 *region_name = unescapeRegionName(tstring); 134 *region_name = unescapeRegionName(tstring);
131 if (!region_name->empty()) 135 if (!region_name->empty())
132 { 136 {
137 // return position data if found. otherwise leave passed-in values alone. (DEV-18380) -MG
133 if (idx1 != std::string::npos) 138 if (idx1 != std::string::npos)
134 { 139 {
135 idx1 = parseGridIdx(sim_string, idx1, x); 140 std::string::size_type xs = *x, ys = *y, zs = *z;
136 idx1 = parseGridIdx(sim_string, idx1, y); 141 idx1 = parseGridIdx(sim_string, idx1, &xs);
137 idx1 = parseGridIdx(sim_string, idx1, z); 142 idx1 = parseGridIdx(sim_string, idx1, &ys);
143 idx1 = parseGridIdx(sim_string, idx1, &zs);
144 *x = xs;
145 *y = ys;
146 *z = zs;
138 } 147 }
148
139 return true; 149 return true;
140 } 150 }
141 else 151 else