mrg_ui/src/mtkargs.cxx
//============================================================================
// Parse an argument string from the argument list.
// If the argument begins with '-' then it's a tag-based argument;
// otherwise the chunk consists of just this one free-form string.
// A tag-based argument is grouped with succeeding non-tag-based arguments,
// up to the stated limit for that particular tag.  However, only one
// index in argv is processed by parseChunk at a time, based on the current
// tag.  It is an error if an unexpected tag appears in the list.
//
Parse an argument string from the argument list.
If the argument begins with '-' then it's a tag-based argument;
otherwise the chunk consists of just this one free-form string.
A tag-based argument is grouped with succeeding non-tag-based arguments,
up to the stated limit for that particular tag.  However, only one
index in argv is processed by parseChunk at a time, based on the current
tag.  It is an error if an unexpected tag appears in the list.
Parse an argument string from the argument list . If the argument begins with ' - ' then it ' s a tag - based argument ; otherwise the chunk consists of just this one free - form string . A tag - based argument is grouped with succeeding non - tag - based arguments up to the stated limit for that particular tag . However only one index in argv is processed by parseChunk at a time based on the current tag . It is an error if an unexpected tag appears in the list .
int MtkArgs::parseChunk()
{
    if (current_tag >= 0 && num_assoc[current_tag] >= spec[current_tag].nassocs) {
        current_tag = -1;
    }
    char *arg = curArg();
    if (arg == NULL) {
	current_tag = -1;
	return chn_done;
    }
    next_index += 1;
    if (arg[0] == '-') {
        current_tag = findTag(arg+1);
	if (current_tag < 0) {
	    return chn_error;
	}
	return chn_tag;
    }
    else if (current_tag >= 0) {
	num_assoc[current_tag] += 1;
	return chn_assoc;
    }
    else {
        num_additions += 1;
	return chn_free;
    }
}
int MtkArgs :: parseChunk ( ) { if ( current_tag >= 0 && num_assoc [ current_tag ] >= spec [ current_tag ] . nassocs ) { current_tag = -1 ; } char * arg = curArg ( ) ; if ( arg == NULL ) { current_tag = -1 ; return chn_done ; } next_index += 1 ; if ( arg [ 0 ] == ' ' ) { current_tag = findTag ( arg + 1 ) ; if ( current_tag < 0 ) { return chn_error ; } return chn_tag ; } else if ( current_tag >= 0 ) { num_assoc [ current_tag ] += 1 ; return chn_assoc ; } else { num_additions += 1 ; return chn_free ; } }
Parse an argument string from the argument list.
Parse an argument string from the argument list .
// current tag can accept no more associations // error // Introduced current tag. // Found an association for current tag. // Found an unassociated argument.