aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llservicebuilder.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/llmessage/llservicebuilder.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/llmessage/llservicebuilder.cpp')
-rw-r--r--linden/indra/llmessage/llservicebuilder.cpp72
1 files changed, 15 insertions, 57 deletions
diff --git a/linden/indra/llmessage/llservicebuilder.cpp b/linden/indra/llmessage/llservicebuilder.cpp
index 138ab2d..96f49ab 100644
--- a/linden/indra/llmessage/llservicebuilder.cpp
+++ b/linden/indra/llmessage/llservicebuilder.cpp
@@ -39,7 +39,7 @@
39void LLServiceBuilder::loadServiceDefinitionsFromFile( 39void LLServiceBuilder::loadServiceDefinitionsFromFile(
40 const std::string& service_filename) 40 const std::string& service_filename)
41{ 41{
42 llifstream service_file(service_filename.c_str(), std::ios::binary); 42 llifstream service_file(service_filename, std::ios::binary);
43 if(service_file.is_open()) 43 if(service_file.is_open())
44 { 44 {
45 LLSD service_data; 45 LLSD service_data;
@@ -111,10 +111,13 @@ std::string LLServiceBuilder::buildServiceURI(
111 const std::string& service_name, 111 const std::string& service_name,
112 const LLSD& option_map) 112 const LLSD& option_map)
113{ 113{
114 std::string service_url = buildServiceURI(service_name); 114 return russ_format(buildServiceURI(service_name), option_map);
115 115}
116 // Find the Service Name 116
117 if(!service_url.empty() && option_map.isMap()) 117std::string russ_format(const std::string& format_str, const LLSD& context)
118{
119 std::string service_url(format_str);
120 if(!service_url.empty() && context.isMap())
118 { 121 {
119 // throw in a ridiculously large limiter to make sure we don't 122 // throw in a ridiculously large limiter to make sure we don't
120 // loop forever with bad input. 123 // loop forever with bad input.
@@ -134,9 +137,9 @@ std::string LLServiceBuilder::buildServiceURI(
134 std::string::iterator end(service_url.end()); 137 std::string::iterator end(service_url.end());
135 std::string::iterator deepest_node(service_url.end()); 138 std::string::iterator deepest_node(service_url.end());
136 std::string::iterator deepest_node_end(service_url.end()); 139 std::string::iterator deepest_node_end(service_url.end());
137 //parse out the variables to replace by going through {}s one at a time, 140 // parse out the variables to replace by going through {}s
138 // starting with the "deepest" in series {{}}, 141 // one at a time, starting with the "deepest" in series
139 // and otherwise replacing right-to-left 142 // {{}}, and otherwise replacing right-to-left
140 for(; iter != end; ++iter) 143 for(; iter != end; ++iter)
141 { 144 {
142 switch(*iter) 145 switch(*iter)
@@ -171,7 +174,7 @@ std::string LLServiceBuilder::buildServiceURI(
171 // params and straight string substitution, so it's a 174 // params and straight string substitution, so it's a
172 // known distance of 2 to skip the directive. 175 // known distance of 2 to skip the directive.
173 std::string key(deepest_node + 2, deepest_node_end); 176 std::string key(deepest_node + 2, deepest_node_end);
174 LLSD value = option_map[key]; 177 LLSD value = context[key];
175 switch(*(deepest_node + 1)) 178 switch(*(deepest_node + 1))
176 { 179 {
177 case '$': 180 case '$':
@@ -184,7 +187,9 @@ std::string LLServiceBuilder::buildServiceURI(
184 } 187 }
185 else 188 else
186 { 189 {
187 llwarns << "Unknown key: " << key << " in option map: " << LLSDOStreamer<LLSDNotationFormatter>(option_map) << llendl; 190 llwarns << "Unknown key: " << key << " in option map: "
191 << LLSDOStreamer<LLSDNotationFormatter>(context)
192 << llendl;
188 keep_looping = false; 193 keep_looping = false;
189 } 194 }
190 break; 195 break;
@@ -212,50 +217,3 @@ std::string LLServiceBuilder::buildServiceURI(
212 } 217 }
213 return service_url; 218 return service_url;
214} 219}
215
216
217
218// Old, not as good implementation. Phoenix 2007-10-15
219#if 0
220 // Do brace replacements - NOT CURRENTLY RECURSIVE
221 for(LLSD::map_const_iterator option_itr = option_map.beginMap();
222 option_itr != option_map.endMap();
223 ++option_itr)
224 {
225 std::string variable_name = "{$";
226 variable_name.append((*option_itr).first);
227 variable_name.append("}");
228 std::string::size_type find_pos = service_url.find(variable_name);
229 if(find_pos != std::string::npos)
230 {
231 service_url.replace(
232 find_pos,
233 variable_name.length(),
234 (*option_itr).second.asString());
235 continue;
236 }
237 variable_name.assign("{%");
238 variable_name.append((*option_itr).first);
239 variable_name.append("}");
240 find_pos = service_url.find(variable_name);
241 if(find_pos != std::string::npos)
242 {
243 std::string query_str = LLURI::mapToQueryString(
244 (*option_itr).second);
245 service_url.replace(
246 find_pos,
247 variable_name.length(),
248 query_str);
249 }
250 }
251 }
252
253 if (service_url.find('{') != std::string::npos)
254 {
255 llwarns << "Constructed a likely bogus service URL: " << service_url
256 << llendl;
257 }
258
259 return service_url;
260}
261#endif