[brlcad-commits] SF.net SVN: brlcad:[43184] geomcore/trunk/src/utility/Config.cxx
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <eri...@us...> - 2011-02-09 20:02:19
|
Revision: 43184 http://brlcad.svn.sourceforge.net/brlcad/?rev=43184&view=rev Author: erikgreenwald Date: 2011-02-09 20:02:12 +0000 (Wed, 09 Feb 2011) Log Message: ----------- simplify and correct line parsing logic Modified Paths: -------------- geomcore/trunk/src/utility/Config.cxx Modified: geomcore/trunk/src/utility/Config.cxx =================================================================== --- geomcore/trunk/src/utility/Config.cxx 2011-02-09 20:01:06 UTC (rev 43183) +++ geomcore/trunk/src/utility/Config.cxx 2011-02-09 20:02:12 UTC (rev 43184) @@ -105,31 +105,18 @@ std::string Config::processLine(std::string line) { - //Process the string, clean it up. + char key[BUFSIZ], value[BUFSIZ]; - this->removeAllOccurances(&line, "\t", " "); - this->removeAllOccurances(&line, " ", " "); - - //Check for blankline - if (line == "" || line == " ") { - //this->log->logDEBUG("Config", "Empty Line"); - return ""; + switch(sscanf(line.c_str(), "%s %s", &key, &value)) { + case -1: + return std::string(""); + case 2: + this->updateValue(std::string(key), std::string(value)); + return std::string(key); + default: + this->log->logERROR("Config", "Not enough elements for Key/Value pair on Config Line: " + line); + return ""; } - - QString qline(line.c_str()); - QStringList list = qline.split(" "); - if (list.length() < 2) { - this->log->logERROR("Config", - "Not enough elements for Key/Value pair on Config Line: " - + line); - return ""; - } - - std::string key = list[0].toStdString(); - std::string value = list[1].toStdString(); - - this->updateValue(key, value); - return key; } void Config::removeAllOccurances(std::string* data, std::string search, std::string replace) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |