本文整理汇总了C++中AnyString::find方法的典型用法代码示例。如果您正苦于以下问题:C++ AnyString::find方法的具体用法?C++ AnyString::find怎么用?C++ AnyString::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyString
的用法示例。
在下文中一共展示了AnyString::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DecodeURLQuery
static bool DecodeURLQuery(KeyValueStore& params, const AnyString& query)
{
// note: mongoose does not provide the fragment here, so we don't have
// to check it
// Some tests are already done before calling this method
assert(not query.empty());
String key; // temporary string for parameters handling
uint offset = 0;
uint start = 0;
AnyString value;
do
{
offset = query.find_first_of("=&", offset);
if (offset >= query.size())
{
// ignoring fields with empty value (using default)
break;
}
if (query[offset] == '=')
{
key.assign(query, offset - start, start);
if (key.empty()) // malformed url. aborting
return false;
++offset;
// FIXME !!!! & are not properly handled !!!!!!!!!!!!
uint ampersand = offset;
ampersand = query.find('&', ampersand);
if (ampersand >= query.size())
{
value.adapt(query, query.size() - offset, offset);
ampersand = query.size();
}
else
value.adapt(query, ampersand - offset, offset);
if (not value.empty())
{
KeyValueStore::iterator i = params.find(key);
if (i != params.end())
{
// the item has been found !
params[key] = value;
}
}
offset = ampersand;
}
else
{
// ignoring fields with empty value (using default)
}
// updating offsets
start = ++offset;
}
while (true);
return true;
}