parsercmd/src/clconvert.cxx
// ===========================================================================
// Parses one option with its arguments.  Translates the option to oargs.
//
Parses one option with its arguments.  Translates the option to oargs.
Parses one option with its arguments . Translates the option to oargs .
bool CommandLineConverter::complete_option() {
    if (fault) return false;
    queue<const OptionInterpreter *> options;
    if (!option_token(options)) {
	return false;
    }
    string arg;
    bool have_arg = false;
    bool need_arg = false;
    if (options.size() == 1) {
	const OptionInterpreter *ointerp = options.front();
	if (ointerp->swallow_remaining()) {
	    iargp = iargs.end();
	    delete istrm;
	    istrm = NULL;
	}
	if (ointerp->separate_arg()) {
	    whitespace();
	}
	if (at_argument()) {
	    if (ointerp->immediate_arg() || ointerp->separate_arg()) {
		have_arg = argument(arg);
	    }
	    else if (ointerp->no_arg()) {
	    }
	    else {
#ifdef ISO_CPP_HEADERS
		ostringstream d;
#else
		ostrstream d;
#endif
		d << "option " << ointerp->diagnostic_name() << " does not specify its argument handling";
		makeDiagnostic(d);
		fault = true;
	    }
	}
	else {
	    if (ointerp->no_arg() || ointerp->swallow_remaining()) {
	    }
	    else {
                if (interp->unrecognized_msg() <= unknown_sev) {
		    msg("Option $1 does not support no argument.", interp->unrecognized_msg())
			    << ointerp->diagnostic_name() << eoarg << eom;
		}
		need_arg = true;
	    }
	}
	if (!fault && (have_arg || !need_arg)) {
	    interpret(ointerp, have_arg ? &arg : NULL);
	}
    }
    else {
	while (!options.empty()) {
	    const OptionInterpreter *ointerp = options.front();
	    options.pop();
	    if (ointerp->no_arg()) {
		interpret(ointerp, NULL);
	    }
	    else {
#ifdef ISO_CPP_HEADERS
		ostringstream d;
#else
		ostrstream d;
#endif
		d << "flag " << ointerp->diagnostic_name() << " expects an an argument and occurs with other flags.";
		makeDiagnostic(d);
		fault = true;
	    }
	}
    }
    return !fault;
}
bool CommandLineConverter :: complete_option ( ) { if ( fault ) return false ; queue < const OptionInterpreter * > options ; if ( ! option_token ( options ) ) { return false ; } string arg ; bool have_arg = false ; bool need_arg = false ; if ( options . size ( ) == 1 ) { const OptionInterpreter * ointerp = options . front ( ) ; if ( ointerp -> swallow_remaining ( ) ) { iargp = iargs . end ( ) ; delete istrm ; istrm = NULL ; } if ( ointerp -> separate_arg ( ) ) { whitespace ( ) ; } if ( at_argument ( ) ) { if ( ointerp -> immediate_arg ( ) || ointerp -> separate_arg ( ) ) { have_arg = argument ( arg ) ; } else if ( ointerp -> no_arg ( ) ) { } else { #ifdef ISO_CPP_HEADERS ostringstream d ; #else ostrstream d ; #endif d << " " << ointerp -> diagnostic_name ( ) << " " ; makeDiagnostic ( d ) ; fault = true ; } } else { if ( ointerp -> no_arg ( ) || ointerp -> swallow_remaining ( ) ) { } else { if ( interp -> unrecognized_msg ( ) <= unknown_sev ) { msg ( " " , interp -> unrecognized_msg ( ) ) << ointerp -> diagnostic_name ( ) << eoarg << eom ; } need_arg = true ; } } if ( ! fault && ( have_arg || ! need_arg ) ) { interpret ( ointerp , have_arg ? & arg : NULL ) ; } } else { while ( ! options . empty ( ) ) { const OptionInterpreter * ointerp = options . front ( ) ; options . pop ( ) ; if ( ointerp -> no_arg ( ) ) { interpret ( ointerp , NULL ) ; } else { #ifdef ISO_CPP_HEADERS ostringstream d ; #else ostrstream d ; #endif d << " " << ointerp -> diagnostic_name ( ) << " " ; makeDiagnostic ( d ) ; fault = true ; } } } return ! fault ; }
Parses one option with its arguments.
Parses one option with its arguments .