library/src/blockclass/subclasses/BP_CommandLineOptionParser.cc
// returns a new command line option parser with duplicated values.
returns a new command line option parser with duplicated values.
returns a new command line option parser with duplicated values .
BP_CommandLineOptionParser * BP_CommandLineOptionParser::clone()
{
	BP_CommandLineOptionParser * ret_clone = new BP_CommandLineOptionParser();
	if(!ret_clone)
		return NULL;
	ret_clone->tokens_n = this->tokens_n;
	ret_clone->tokens = (P_BP_COMMAND_LINE_PARSER_TOKENS) tq_calloc(ret_clone->tq, sizeof(BP_COMMAND_LINE_PARSER_TOKENS) * ret_clone->tokens_n, 1, BPLN);
	P_BP_COMMAND_LINE_PARSER_TOKENS clone_token_to   = NULL;
	P_BP_COMMAND_LINE_PARSER_TOKENS clone_token_from = NULL;
	size_t n = 0;
	for(; n < ret_clone->tokens_n; n++)
	{
		clone_token_from = &this->tokens[n];
		clone_token_to   = &ret_clone->tokens[n];
		clone_token_to->token = tq_strdup(ret_clone->tq, clone_token_from->token, BPLN);
		clone_token_to->token_length = clone_token_from->token_length;
		clone_token_to->token_is_long_form = clone_token_from->token_is_long_form;
		clone_token_to->token_required = clone_token_from->token_required;
		clone_token_to->value_type = clone_token_from->value_type;
		clone_token_to->token_description = tq_strdup(ret_clone->tq, clone_token_from->token_description, BPLN);
		clone_token_to->token_usage_example = tq_strdup(ret_clone->tq, clone_token_from->token_usage_example, BPLN);
		clone_token_to->default_value_as_toggle = clone_token_from->default_value_as_toggle;
		clone_token_to->default_value_as_string = tq_strdup(ret_clone->tq, clone_token_from->default_value_as_string, BPLN);
		clone_token_to->max_length_for_string = clone_token_from->max_length_for_string;
		clone_token_to->min_length_for_string = clone_token_from->min_length_for_string;
		clone_token_to->default_value_as_size_t = clone_token_from->default_value_as_size_t;
		clone_token_to->max_value_as_size_t = clone_token_from->max_value_as_size_t;
		clone_token_to->min_value_as_size_t = clone_token_from->min_value_as_size_t;
	}
	ret_clone->parseOptions(this->argc, this->argv, this->envp, this->envpc);
	return ret_clone;
}
BP_CommandLineOptionParser * BP_CommandLineOptionParser :: clone ( ) { BP_CommandLineOptionParser * ret_clone = new BP_CommandLineOptionParser ( ) ; if ( ! ret_clone ) return NULL ; ret_clone -> tokens_n = this -> tokens_n ; ret_clone -> tokens = ( P_BP_COMMAND_LINE_PARSER_TOKENS ) tq_calloc ( ret_clone -> tq , sizeof ( BP_COMMAND_LINE_PARSER_TOKENS ) * ret_clone -> tokens_n , 1 , BPLN ) ; P_BP_COMMAND_LINE_PARSER_TOKENS clone_token_to = NULL ; P_BP_COMMAND_LINE_PARSER_TOKENS clone_token_from = NULL ; size_t n = 0 ; for ( ; n < ret_clone -> tokens_n ; n ++ ) { clone_token_from = & this -> tokens [ n ] ; clone_token_to = & ret_clone -> tokens [ n ] ; clone_token_to -> token = tq_strdup ( ret_clone -> tq , clone_token_from -> token , BPLN ) ; clone_token_to -> token_length = clone_token_from -> token_length ; clone_token_to -> token_is_long_form = clone_token_from -> token_is_long_form ; clone_token_to -> token_required = clone_token_from -> token_required ; clone_token_to -> value_type = clone_token_from -> value_type ; clone_token_to -> token_description = tq_strdup ( ret_clone -> tq , clone_token_from -> token_description , BPLN ) ; clone_token_to -> token_usage_example = tq_strdup ( ret_clone -> tq , clone_token_from -> token_usage_example , BPLN ) ; clone_token_to -> default_value_as_toggle = clone_token_from -> default_value_as_toggle ; clone_token_to -> default_value_as_string = tq_strdup ( ret_clone -> tq , clone_token_from -> default_value_as_string , BPLN ) ; clone_token_to -> max_length_for_string = clone_token_from -> max_length_for_string ; clone_token_to -> min_length_for_string = clone_token_from -> min_length_for_string ; clone_token_to -> default_value_as_size_t = clone_token_from -> default_value_as_size_t ; clone_token_to -> max_value_as_size_t = clone_token_from -> max_value_as_size_t ; clone_token_to -> min_value_as_size_t = clone_token_from -> min_value_as_size_t ; } ret_clone -> parseOptions ( this -> argc , this -> argv , this -> envp , this -> envpc ) ; return ret_clone ; }
returns a new command line option parser with duplicated values.
returns a new command line option parser with duplicated values .
// create a new command line option parser // set the token count // clone the tokens overall structure // create pointers for doing to->from copying // now copy in basic token data.  The rest of the token information will // be filled in by calling ->parseOptions() on the local data. // set the clone to/from values // order will always be: // clone_token_to <- clone_token_from // set token string // set token length // set long form flag // set required flag // set value type // set token description // set token usage example // set default value as toggle // set default value as string // set max length for string // set min length for string // set default value as size_t // set max value as size_t // set min value as size_t // parse the options at this point // return the cloned option parser