library/src/blockclass/subclasses/BP_ApplicationHelpGenerator.cc
// This walks the options and checks to see that all dependencies are met ok.
This walks the options and checks to see that all dependencies are met ok.
This walks the options and checks to see that all dependencies are met ok .
BP_ERROR_T BP_ApplicationHelpGenerator::checkThatAllMandatoryDependenciesAreMet()
{
	if(!this->groups)
		return ERR_SUCCESS;
	if(!this->group_n)
		return ERR_SUCCESS;
	P_BP_AHG_OPTION_ENTRY current_entry = NULL;
	P_BP_AHG_OPTION_GROUP current_group = NULL;
	size_t n = 0;
	for(; n < this->group_n; n++)
	{
		current_group = &this->groups[n];
		size_t j = 0;
		for(j = 0; j < current_group->entry_n; j++)
		{
			current_entry = &current_group->entries[j];
			if(!current_entry->token->value_has_been_set_ok && current_entry->token->token_required)
			{
				return ERR_FAILURE;
			}
			size_t i = 0;
			for(i = 0; i < current_entry->dependency_n; i++)
			{
				if(current_entry->dependencies[i].depends_how == BP_AHG_ENTRY_DEPENDENCY_MANDATORY)
				if(current_entry->dependencies[i].entry)
				if(!current_entry->dependencies[i].entry->token->value_has_been_set_ok)
					return ERR_FAILURE;
			}
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_ApplicationHelpGenerator :: checkThatAllMandatoryDependenciesAreMet ( ) { if ( ! this -> groups ) return ERR_SUCCESS ; if ( ! this -> group_n ) return ERR_SUCCESS ; P_BP_AHG_OPTION_ENTRY current_entry = NULL ; P_BP_AHG_OPTION_GROUP current_group = NULL ; size_t n = 0 ; for ( ; n < this -> group_n ; n ++ ) { current_group = & this -> groups [ n ] ; size_t j = 0 ; for ( j = 0 ; j < current_group -> entry_n ; j ++ ) { current_entry = & current_group -> entries [ j ] ; if ( ! current_entry -> token -> value_has_been_set_ok && current_entry -> token -> token_required ) { return ERR_FAILURE ; } size_t i = 0 ; for ( i = 0 ; i < current_entry -> dependency_n ; i ++ ) { if ( current_entry -> dependencies [ i ] . depends_how == BP_AHG_ENTRY_DEPENDENCY_MANDATORY ) if ( current_entry -> dependencies [ i ] . entry ) if ( ! current_entry -> dependencies [ i ] . entry -> token -> value_has_been_set_ok ) return ERR_FAILURE ; } } } return ERR_SUCCESS ; }
This walks the options and checks to see that all dependencies are met ok.
This walks the options and checks to see that all dependencies are met ok .
// Ensure we have groups and group count.  If they're not set, we can // return indicating success, as we can't have mandatory dependencies // if we simply have no dependencies at all. // current entry and current group // walk group count // set current group // walk individual entries and check dependencies // set the current entry // if our current entry is required, and it hasn't been set ok, we have encountered // bad options (aka values which were required haven't been set by the user) // printf("\n Failing here?!: %s", current_entry->token->token); // check deps // now check individual mandatory dependencies // return indicating success