library/src/blockclass/subclasses/BP_CommandLineOptionParser.cc
// post parse checks (checks tokens to ensure that values that must be set, have been set and
// performs basic consistency checks)
post parse checks (checks tokens to ensure that values that must be set, have been set and
performs basic consistency checks)
post parse checks ( checks tokens to ensure that values that must be set have been set and performs basic consistency checks )
BP_ERROR_T BP_CommandLineOptionParser::runPostParseTokenChecks()
{
	if(!this->tokens)
	{
		this->AddErr("Token Pointer is NULL.");
		return ERR_FAILURE;
	}
	if(!this->tokens_n)
	{
		this->AddErr("Token count is zero.");
		return ERR_FAILURE;
	}
	P_BP_COMMAND_LINE_PARSER_TOKENS current_token = NULL;
	size_t n = 0;
	for(; n < this->tokens_n; n++)
	{
		current_token = &this->tokens[n];
		if(this->runTokenCheck(current_token) != ERR_SUCCESS)
		{
			char tmp_buff[1024];
			BP_ZERO_STACK(tmp_buff);
			snprintf((char *) &tmp_buff, 1000, "Command line option parser token check failed on token index %zu (%s).  Please ensure you've set your parameters correctly.", n, current_token->token);
			this->AddErr((char *) &tmp_buff);
			return ERR_FAILURE;
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_CommandLineOptionParser :: runPostParseTokenChecks ( ) { if ( ! this -> tokens ) { this -> AddErr ( " " ) ; return ERR_FAILURE ; } if ( ! this -> tokens_n ) { this -> AddErr ( " " ) ; return ERR_FAILURE ; } P_BP_COMMAND_LINE_PARSER_TOKENS current_token = NULL ; size_t n = 0 ; for ( ; n < this -> tokens_n ; n ++ ) { current_token = & this -> tokens [ n ] ; if ( this -> runTokenCheck ( current_token ) != ERR_SUCCESS ) { char tmp_buff [ 1024 ] ; BP_ZERO_STACK ( tmp_buff ) ; snprintf ( ( char * ) & tmp_buff , 1000 , " " , n , current_token -> token ) ; this -> AddErr ( ( char * ) & tmp_buff ) ; return ERR_FAILURE ; } } return ERR_SUCCESS ; }
post parse checks (checks tokens to ensure that values that must be set, have been set and
performs basic consistency checks)
post parse checks ( checks tokens to ensure that values that must be set have been set and performs basic consistency checks )
// check token stack // check token count // current token for examination // walk all the tokens and run checks // set current token for code simplification // run the token check // create temporary buffer // add err // return indicating success