From 109fc551ab40f9aff9eb62c4462efdbbe2e30e7a Mon Sep 17 00:00:00 2001 From: evomarc Date: Thu, 30 Nov 2000 06:20:20 +0000 Subject: [PATCH] Reversed the priority between command-line and parameter file --- eo/src/utils/eoParser.cpp | 44 +++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/eo/src/utils/eoParser.cpp b/eo/src/utils/eoParser.cpp index 2487cd67..4888e675 100644 --- a/eo/src/utils/eoParser.cpp +++ b/eo/src/utils/eoParser.cpp @@ -41,6 +41,32 @@ eoParser::eoParser ( int _argc, char **_argv , string _programDescription, strin programDescription( _programDescription), needHelp(false, "help", "Prints this message", 'h') { + // need to process the param file first + // if we want command-line to have highest priority + + for (int i = 1; i < _argc; ++i) + { + if (_argv[i][0] == '@') + { // read response file + char *pts = _argv[i]+1; // yes a char*, sorry :-) + + ifstream ifs (pts); + + ifs.peek(); // check if it exists + + if (!ifs) + { + string msg = (string)("Could not open response file: ") + pts; + throw runtime_error(msg); + } + + // read - will be overwritten by command-line + readFrom(ifs); + break; // stop reading command line args for '@' + } + } + + // now read arguments on command-line strstream stream; for (int i = 1; i < _argc; ++i) @@ -157,24 +183,6 @@ void eoParser::readFrom(istream& is) shortNameMap[str[1]] = value; } } - if (str[0] == '@') - { // read response file - string filename(str.begin() + 1, str.end()); - - ifstream ifs (filename.c_str()); - - ifs.peek(); // check if it exists - - if (!ifs) - { - string msg = "Could not open response file: " + filename; - throw runtime_error(msg); - } - - // read and overwrite - readFrom(ifs); - break; // stop reading command line - } } updateParameters();