/* PropertyList::copyTo * Copies all properties to [list] *******************************************************************/ void PropertyList::copyTo(PropertyList& list) { // Clear given list list.clear(); // Get iterator to first property std::map<string, Property>::iterator i = properties.begin(); // Add all properties to given list while (i != properties.end()) { if (i->second.hasValue()) list[i->first] = i->second; i++; } }
// Example: /category/command?arg1=value&arg2=value bool IseServerInspector::parseCommandUrl(const HttpRequest& request, string& category, string& command, PropertyList& argList) { bool result = false; string url = request.getUrl(); string argStr; StrList strList; if (!url.empty() && url[0] == '/') url.erase(0, 1); // find the splitter char ('?') string::size_type argPos = url.find('?'); bool hasArgs = (argPos != string::npos); if (hasArgs) { argStr = url.substr(argPos + 1); url.erase(argPos); } // parse the string before the '?' splitString(url, '/', strList, true); if (strList.getCount() >= 2) { category = strList[0]; command = strList[1]; result = true; } // parse the args if (result) { argList.clear(); splitString(argStr, '&', strList, true); for (int i = 0; i < strList.getCount(); ++i) { StrList parts; splitString(strList[i], '=', parts, true); if (parts.getCount() == 2 && !parts[0].empty()) { argList.add(parts[0], parts[1]); } } } return result; }