// remove a flag in the string␊ |
void KernOptionsParser::removeFlag(const std::string& flag)␊ |
{␊ |
␉std::string::size_type found = _options.find(flag);␊ |
␉if (flag.length()==0) return; // not a flag, bye␊ |
␉std::string::size_type pos, l = _options.length();␉␊ |
␉if (l==0) return; // empty options nothing to do␉␊ |
␉std::string f = string_left(flag, "=");␊ |
␉std::string::size_type found = _options.find(f);␊ |
␉if (found==std::string::npos) return;␊ |
␉_options.erase(found, found+flag.length());␊ |
␉// find the end of the flag␊ |
␉for ( pos=found+flag.length(); pos<l && _options[pos]!=' '; pos++);␊ |
␉_options.erase(found, pos);␊ |
␉_options = trim(_options);␊ |
}␊ |
␊ |
// remove a flag in the string␊ |
void KernOptionsParser::addFlag(const std::string& flag)␊ |
{␊ |
␉std::string::size_type found = _options.find(flag);␊ |
␉if (found!=std::string::npos) return;␊ |
␉// finding a flag can be tricky as some have a variable part of the form:␊ |
␉// flag=value and what we want is to keep identify them while they will varyĆ ␊ |
␉std::string key= string_left(flag,"=");␊ |
␉␊ |
␉std::string::size_type found = _options.find(key);␊ |
␉if (found!=std::string::npos) ␊ |
␉␉removeFlag(key);␊ |
␉_options = " " + _options;␊ |
␉_options = flag + _options;␊ |
␉_options = trim(_options);␊ |