Ookii.CommandLine for C++  2.0.0
Public Types | Public Member Functions | List of all members
ookii::basic_command_with_custom_parsing< CharType, Traits, Alloc > Class Template Referenceabstract

Abstract base class for subcommands that do their own argument parsing. More...

#include <ookii/subcommand.h>

Inheritance diagram for ookii::basic_command_with_custom_parsing< CharType, Traits, Alloc >:
Inheritance graph
[legend]
Collaboration diagram for ookii::basic_command_with_custom_parsing< CharType, Traits, Alloc >:
Collaboration graph
[legend]

Public Types

using command_manager_type = basic_command_manager< CharType, Traits, Alloc >
 The concrete type of basic_command_manager used.
 
using usage_writer_type = basic_usage_writer< CharType, Traits, Alloc >
 The concrete type of basic_usage_writer used.
 
- Public Types inherited from ookii::basic_command< CharType, std::char_traits< CharType >, std::allocator< CharType > >
using builder_type = basic_parser_builder< CharType, std::char_traits< CharType >, std::allocator< CharType > >
 The concrete type of basic_parser_builder used.
 

Public Member Functions

virtual bool parse (std::span< const CharType *const > args, const command_manager_type &manager, usage_writer_type *usage)=0
 Parses the arguments for the command. More...
 
- Public Member Functions inherited from ookii::basic_command< CharType, std::char_traits< CharType >, std::allocator< CharType > >
 basic_command ()=default
 Initializes a new instance of the basic_command class.
 
 basic_command (builder_type &)
 Initializes a new instance of the basic_command class. More...
 
virtual ~basic_command ()=default
 Default destructor.
 
virtual int run ()=0
 Runs the command, after argument parsing was successful. More...
 

Detailed Description

template<typename CharType, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
class ookii::basic_command_with_custom_parsing< CharType, Traits, Alloc >

Abstract base class for subcommands that do their own argument parsing.

Template Parameters
CharTypeThe character type used for arguments and other strings.
TraitsThe character traits to use for strings. Defaults to std::char_traits<CharType>.
AllocThe allocator to use for strings. Defaults to std::allocator<CharType>.

Unlike commands that derive directly from the basic_command class, commands that derive from the basic_command_with_custom_parsing class are not created with the basic_command_line_parser class. Instead, they must have a public constructor with no parameters, and must parse the arguments manually by implementing the parse() method.

Several typedefs for common character types are provided:

Type Definition
ookii::command_with_custom_parsing ookii::basic_command_with_custom_parsing<char>
ookii::wcommand_with_custom_parsing ookii::basic_command_with_custom_parsing<wchar_t>

Member Function Documentation

◆ parse()

template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
virtual bool ookii::basic_command_with_custom_parsing< CharType, Traits, Alloc >::parse ( std::span< const CharType *const >  args,
const command_manager_type manager,
usage_writer_type usage 
)
pure virtual

Parses the arguments for the command.

Parameters
argsA span containing the arguments for the command.
managerThe command manager this command was created with.
usageThe usage writer that was passed to basic_command_manager::create_command().
Returns
true if parsing was successful; otherwise, false.

The documentation for this class was generated from the following file: