MCPcopy Create free account
hub / github.com/apache/cloudberry / UriDecode

Function UriDecode

gpcontrib/gpcloud/src/s3utils.cpp:309–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307}
308
309string UriDecode(const string &src) {
310 signed char dec1, dec2;
311
312 auto srcStr = src.begin();
313 auto srcEnd = src.end() - 2;
314
315 string retStr;
316 while (srcStr < srcEnd) {
317 if (*srcStr == '%') {
318 dec1 = UriMapping[(int)*(srcStr + 1)];
319 dec2 = UriMapping[(int)*(srcStr + 2)];
320
321 if ((dec1 != -1) && (dec2 != -1)) {
322 retStr.push_back((dec1 << 4) + dec2);
323 srcStr += 3;
324 continue;
325 }
326 }
327
328 retStr.push_back(*srcStr);
329 srcStr++;
330 }
331
332 while (srcStr < src.end()) {
333 retStr.push_back(*srcStr);
334 srcStr++;
335 }
336
337 return retStr;
338}
339
340void FindAndReplace(string &str, const string &find, const string &replace) {
341 if (find.empty()) return;

Callers 1

TESTFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by 1

TESTFunction · 0.68