library/src/blockclass/subclasses/BP_ApplicationHelpGenerator.cc
// Add an entry to the option group via the local command line parser.  Works
// by looking up the token in the command line parser class, and assigns it
// to the specified group.
Add an entry to the option group via the local command line parser.  Works
by looking up the token in the command line parser class, and assigns it
to the specified group.
Add an entry to the option group via the local command line parser . Works by looking up the token in the command line parser class and assigns it to the specified group .
BP_ERROR_T BP_ApplicationHelpGenerator::addOptionEntryToOptionGroup
(
		char * group_name,
		char * new_entry_name,
		char * new_entry_description,
		char * token,
		P_BP_STRING_ROW_BORDER_SET border_set
)
{
	if(!this->clop)
		return ERR_FAILURE;
	if(!group_name || !new_entry_name || !new_entry_description || !token)
		return ERR_FAILURE;
	P_BP_AHG_OPTION_GROUP group = this->lookupOptionGroupByName(group_name);
	if(!group)
		return ERR_FAILURE;
	P_BP_COMMAND_LINE_PARSER_TOKENS token_ptr = this->clop->optionLookup(token);
	if(!token_ptr)
	{
		return ERR_FAILURE;
	}
	group->entries = (P_BP_AHG_OPTION_ENTRY) tq_realloc
	(
			this->tq,
			group->entries,
			sizeof(BP_AHG_OPTION_ENTRY) * (group->entry_n+1),
			BPLN
	);
	if(!group->entries)
		return ERR_FAILURE;
	memset(&group->entries[group->entry_n], 0x00, sizeof(BP_AHG_OPTION_ENTRY));
	group->entries[group->entry_n].name        = tq_strdup(this->tq, new_entry_name,        BPLN);
	group->entries[group->entry_n].description = tq_strdup(this->tq, new_entry_description, BPLN);
	group->entries[group->entry_n].token = token_ptr;
	if(border_set)
		group->entries[group->entry_n].border_set = border_set;
	group->entry_n++;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_ApplicationHelpGenerator :: addOptionEntryToOptionGroup ( char * group_name , char * new_entry_name , char * new_entry_description , char * token , P_BP_STRING_ROW_BORDER_SET border_set ) { if ( ! this -> clop ) return ERR_FAILURE ; if ( ! group_name || ! new_entry_name || ! new_entry_description || ! token ) return ERR_FAILURE ; P_BP_AHG_OPTION_GROUP group = this -> lookupOptionGroupByName ( group_name ) ; if ( ! group ) return ERR_FAILURE ; P_BP_COMMAND_LINE_PARSER_TOKENS token_ptr = this -> clop -> optionLookup ( token ) ; if ( ! token_ptr ) { return ERR_FAILURE ; } group -> entries = ( P_BP_AHG_OPTION_ENTRY ) tq_realloc ( this -> tq , group -> entries , sizeof ( BP_AHG_OPTION_ENTRY ) * ( group -> entry_n + 1 ) , BPLN ) ; if ( ! group -> entries ) return ERR_FAILURE ; memset ( & group -> entries [ group -> entry_n ] , 0x00 , sizeof ( BP_AHG_OPTION_ENTRY ) ) ; group -> entries [ group -> entry_n ] . name = tq_strdup ( this -> tq , new_entry_name , BPLN ) ; group -> entries [ group -> entry_n ] . description = tq_strdup ( this -> tq , new_entry_description , BPLN ) ; group -> entries [ group -> entry_n ] . token = token_ptr ; if ( border_set ) group -> entries [ group -> entry_n ] . border_set = border_set ; group -> entry_n ++ ; return ERR_SUCCESS ; }
Add an entry to the option group via the local command line parser.
Add an entry to the option group via the local command line parser .
// ensure that we have command line option parser set // ensure parameters are set // set the group to work with // attempt to lookup the token // set entries here // ensure memory was allocated // zero out memory // set name and description // set token // set border set if one was passed in // increase entry count // return indicating success