library/src/blockclass/subclasses/BP_CommandLineOptionParser.cc
// Add Stand alone toggle option.
Add Stand alone toggle option.
Add Stand alone toggle option .
BP_ERROR_T BP_CommandLineOptionParser::addToggleOption
(
		char * token,
		size_t token_required,
		char *token_description,
		char *token_usage_example,
		size_t default_value,
		void * (*argument_activation_callback)(BP_CommandLineOptionParser * parser, P_BP_COMMAND_LINE_PARSER_TOKENS token),
		char ** preg_custom_filters
)
{
	if(!token)
		return ERR_FAILURE;
	size_t token_len = strnlen(token, 100);
	bool token_is_long_form = false;
	if(token_len >= 3)
	if
	(
		(token[0] == '-') &&
		(token[1] == '-')
	)
	{
		token_is_long_form = true;
	}
	return this->addOption
	(
			token,
			token_is_long_form,
			token_required,
			BP_COMMAND_LINE_ARGUMENT_STAND_ALONE_TOGGLE,
			token_description,
			token_usage_example,
			(void *) default_value,
			0,
			0,
			0,
			0,
			0,
			0,
			argument_activation_callback,
			preg_custom_filters
	);
}
BP_ERROR_T BP_CommandLineOptionParser :: addToggleOption ( char * token , size_t token_required , char * token_description , char * token_usage_example , size_t default_value , void * ( * argument_activation_callback ) ( BP_CommandLineOptionParser * parser , P_BP_COMMAND_LINE_PARSER_TOKENS token ) , char * * preg_custom_filters ) { if ( ! token ) return ERR_FAILURE ; size_t token_len = strnlen ( token , 100 ) ; bool token_is_long_form = false ; if ( token_len >= 3 ) if ( ( token [ 0 ] == ' ' ) && ( token [ 1 ] == ' ' ) ) { token_is_long_form = true ; } return this -> addOption ( token , token_is_long_form , token_required , BP_COMMAND_LINE_ARGUMENT_STAND_ALONE_TOGGLE , token_description , token_usage_example , ( void * ) default_value , 0 , 0 , 0 , 0 , 0 , 0 , argument_activation_callback , preg_custom_filters ) ; }
Add Stand alone toggle option.
Add Stand alone toggle option .
// ensure we have a token // calculate the token length // determine if the token is long form // add a generic option