diff --git a/src/Arg.cpp b/src/Arg.cpp index 8f38181..92cb82f 100644 --- a/src/Arg.cpp +++ b/src/Arg.cpp @@ -290,4 +290,12 @@ void Arg::xorSet() _xorSet = true; } +/** + * Overridden by Args that need to added to the end of the list. + */ +void Arg::addToList( list& argList ) const +{ + argList.push_front( (Arg*)this ); +} + } diff --git a/src/CmdLine.cpp b/src/CmdLine.cpp index bf82f09..030889a 100644 --- a/src/CmdLine.cpp +++ b/src/CmdLine.cpp @@ -101,10 +101,7 @@ void CmdLine::add( Arg* a ) return; } - if ( a->getFlag() == "" ) - _argList.push_back( a ); - else - _argList.push_front( a ); + a->addToList( _argList ); if ( a->isRequired() ) _numRequired++; @@ -201,4 +198,5 @@ bool CmdLine::_emptyCombined(const string& s) return true; } + }