// // This function parses configuration options from a text string. Removes any previous // options stored in the configuration list. // void CommandParser::ParseConfigurationOptions(cString arguments, cString delimiter) { CleanConfigurationOptions(); std::vector<cString> argumentList; size_t pos; size_t nextPos = arguments.find_first_of(delimiter, 0); // // Break out parameters from command line // while (nextPos != std::string::npos) { pos = nextPos + 1; nextPos = arguments.find_first_of(delimiter, pos); argumentList.push_back(arguments.substr(pos, nextPos - pos)); } // // Remove leading spaces from arguments. // for (std::vector<cString>::iterator it = argumentList.begin(); it != argumentList.end(); it++) { std::string::size_type pos = it->find_first_not_of(' '); if (pos != std::string::npos) { it->erase(0, pos); } } // // Remove trailing spaces from arguments // for (std::vector<cString>::iterator it = argumentList.begin(); it != argumentList.end(); it++) { std::string::size_type pos = it->find_last_not_of(' '); if (pos != std::string::npos) { it->erase(pos + 1); } } // // Split the values from the parameter name // cString arg; for (std::vector<cString>::iterator it = argumentList.begin(); it != argumentList.end(); it++) { arg = *it; pos = arg.find_first_of(_L(":"), 0); if (pos != cString::npos) { m_ArgumentMap.insert(std::make_pair(arg.substr(0, pos), arg.substr(pos + 1, std::string::npos))); } else { m_ArgumentMap.insert(std::make_pair(arg.substr(0, pos), _L(""))); } } return; }