Ookii.CommandLine for C++  2.0.0
Namespaces | Macros | Functions
command_line_generated.h File Reference

Provides helpers for using the New-Parser.ps1 and New-Subcommand.ps1 scripts. More...

#include "command_line.h"
Include dependency graph for command_line_generated.h:

Go to the source code of this file.

Namespaces

 ookii
 Namespace containing the core Ookii.CommandLine.Cpp types.
 

Macros

#define OOKII_DECLARE_CREATE_BUILDER_METHOD()   OOKII_DECLARE_CREATE_BUILDER_METHOD_EX(ookii::details::default_char_type)
 A macro to declare the static build() method that the New-Parser.ps1 script will generate, using the specified character type. More...
 
#define OOKII_DECLARE_CREATE_BUILDER_METHOD_EX(char_type)
 A macro to declare the static build() method that the New-Parser.ps1 script will generate, using the specified character type. More...
 
#define OOKII_GENERATED_METHODS(type)   OOKII_GENERATED_METHODS_EX(type, ookii::details::default_char_type)
 A macro to declare the methods that a struct used with New-Parser.ps1 must have, using the default character type. More...
 
#define OOKII_GENERATED_METHODS_EX(type, char_type)
 A macro to declare the methods that a struct used with New-Parser.ps1 must have, using the specified character type. More...
 

Functions

basic_command_manager< details::default_char_type > ookii::register_commands (std::basic_string< details::default_char_type > application_name, basic_localized_string_provider< details::default_char_type > *string_provider=nullptr, const std::locale &locale={})
 Function that registers all the subcommands generated by New-Subcommand.ps1. More...
 

Detailed Description

Provides helpers for using the New-Parser.ps1 and New-Subcommand.ps1 scripts.

Macro Definition Documentation

◆ OOKII_DECLARE_CREATE_BUILDER_METHOD

#define OOKII_DECLARE_CREATE_BUILDER_METHOD ( )    OOKII_DECLARE_CREATE_BUILDER_METHOD_EX(ookii::details::default_char_type)

A macro to declare the static build() method that the New-Parser.ps1 script will generate, using the specified character type.

When using New-Parser.ps1, the definition of this method will be generated. This macro makes it easy to define a method that matches the exact signature expected.

The default character type is wchar_t if _UNICODE is defined; otherwise, it's char.

◆ OOKII_DECLARE_CREATE_BUILDER_METHOD_EX

#define OOKII_DECLARE_CREATE_BUILDER_METHOD_EX (   char_type)
Value:
::ookii::basic_parser_builder<char_type> create_builder(::std::basic_string<char_type> command_name, \
::ookii::basic_localized_string_provider<char_type> *string_provider = nullptr, const std::locale &locale = {})
Provides custom localized strings.
Definition: localized_string_provider.h:30
Provides functionality to specify options and arguments to create a new basic_command_line_parser.
Definition: command_line_builder.h:73

A macro to declare the static build() method that the New-Parser.ps1 script will generate, using the specified character type.

When using New-Parser.ps1, the definition of this method will be generated. This macro makes it easy to define a method that matches the exact signature expected.

Parameters
char_typeThe character type to use for strings.

◆ OOKII_GENERATED_METHODS

#define OOKII_GENERATED_METHODS (   type)    OOKII_GENERATED_METHODS_EX(type, ookii::details::default_char_type)

A macro to declare the methods that a struct used with New-Parser.ps1 must have, using the default character type.

This will add a build() method, which creates a ookii::basic_parser_builder, and a static parse() method, which will parse the arguments and handle errors. The New-Parser.ps1 script generates the definition of the build() method; the parse() method is defined by this macro.

The default character type is wchar_t if _UNICODE is defined; otherwise, it's char.

Parameters
typeThe type of the struct or class that contains the arguments.

◆ OOKII_GENERATED_METHODS_EX

#define OOKII_GENERATED_METHODS_EX (   type,
  char_type 
)
Value:
static ::std::optional<type> parse(int argc, const char_type* const argv[], ::ookii::basic_usage_writer<char_type> *usage = nullptr, \
::ookii::basic_localized_string_provider<char_type> *string_provider = nullptr, const std::locale &locale = {}) \
{ \
type args{}; \
auto parser = args.create_builder(name, string_provider, locale).build(); \
if (parser.parse(argc, argv, usage)) \
{ \
return args; \
} \
return {}; \
} \
OOKII_DECLARE_CREATE_BUILDER_METHOD_EX(char_type)
static string_type get_executable_name(int argc, const CharType *const argv[], bool include_extension=false)
Extracts the executable name from the application's arguments.
Definition: command_line_parser.h:754
Creates usage help for the basic_command_line_parser and basic_command_manager classes.
Definition: usage_writer.h:99

A macro to declare the methods that a struct used with New-Parser.ps1 must have, using the specified character type.

This will add a build() method, which creates a ookii::basic_parser_builder, and a static parse() method, which will parse the arguments and handle errors. The New-Parser.ps1 script generates the definition of the build() method; the parse() method is defined by this macro.

Parameters
typeThe type of the struct or class that contains the arguments.
char_typeThe character type to use for strings.