MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPLURLGetValue

Function CPLURLGetValue

port/cplstring.cpp:500–518  ·  view source on GitHub ↗

* Return the value matching a key from a key=value pair in a URL. * * @param pszURL the URL. * @param pszKey the key to find. * @return the value of empty string if not found. */

Source from the content-addressed store, hash-verified

498 * @return the value of empty string if not found.
499 */
500CPLString CPLURLGetValue(const char *pszURL, const char *pszKey)
501{
502 CPLString osKey(pszKey);
503 osKey += "=";
504 size_t nKeyPos = CPLString(pszURL).ifind(osKey);
505 if (nKeyPos != std::string::npos && nKeyPos > 0 &&
506 (pszURL[nKeyPos - 1] == '?' || pszURL[nKeyPos - 1] == '&'))
507 {
508 CPLString osValue(pszURL + nKeyPos + osKey.size());
509 const char *pszValue = osValue.c_str();
510 const char *pszSep = strchr(pszValue, '&');
511 if (pszSep)
512 {
513 osValue.resize(pszSep - pszValue);
514 }
515 return osValue;
516 }
517 return "";
518}
519
520/************************************************************************/
521/* CPLURLAddKVP() */

Callers 15

MakeGetFeatureURLMethod · 0.85
SendGetCapabilitiesMethod · 0.85
OpenMethod · 0.85
MakeGetFeatureURLMethod · 0.85
FetchGetFeatureMethod · 0.85
BuildLayerDefnMethod · 0.85
OpenMethod · 0.85
ParseURLFunction · 0.85

Calls 5

CPLStringFunction · 0.85
ifindMethod · 0.80
sizeMethod · 0.45
c_strMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected