␉␊ |
␉// first remove spaces around '=' to simplify parsing␊ |
␉std::string::size_type found = std::string::npos;␊ |
␉while ((found=_options.find(" =")) != std::string::npos) _options.replace(found, 3,"=");␊ |
␉while ((found=_options.find("= ")) != std::string::npos) _options.replace(found, 3,"=");␊ |
␉while ((found=_options.find(" =")) != std::string::npos) _options.replace(found, 2,"=");␊ |
␉while ((found=_options.find("= ")) != std::string::npos) _options.replace(found, 2,"=");␊ |
␉␊ |
␉// then tokenize the string␊ |
␉_optionsList = tokenize(_options);␊ |
|
␉return sEmpty;␊ |
}␊ |
␊ |
// get the left member of kern option "xxxx=yyyy"␊ |
const std::string& KernOptionsParser::leftMember(const std::string& expression) const␊ |
{␊ |
␉static std::string sLeft;␊ |
␉std::string::size_type pos = expression.find('=');␊ |
␉␊ |
␉if (pos!=std::string::npos)␊ |
␉␉return (sLeft = expression.substr(0, pos));␊ |
␉return expression;␊ |
}␊ |
␊ |
// get the right member of kern option "xxxx=yyyy"␊ |
const std::string& KernOptionsParser::rightMember(const std::string& expression) const␊ |
{␊ |
␉static std::string sLeft;␊ |
␉std::string::size_type pos = expression.find('=');␊ |
␉␊ |
␉if (pos!=std::string::npos)␊ |
␉␉return (sLeft = expression.substr(pos+1));␊ |
␉return expression;␊ |
}␊ |
// remove a flag in the string␊ |
void KernOptionsParser::removeFlag(const std::string& 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 f = leftMember(flag);␊ |
␉std::string::size_type found = _options.find(f);␊ |
␉if (found==std::string::npos) return;␊ |
␉// find the end of the flag␊ |
|
␉std::string::size_type found = _options.find(key);␊ |
␉if (found!=std::string::npos) ␊ |
␉␉removeFlag(key);␊ |
␉_options = " " + _options;␊ |
␉_options = " " + _options;␊ |
␉_options = flag + _options;␊ |
␉_options = trim(_options);␊ |
}␊ |