Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::program_options::basic_command_line_parser< charT > Class Template Reference

Command line parser. More...

#include <parsers.hpp>

Inheritance diagram for boost::program_options::basic_command_line_parser< charT >:
Collaboration diagram for boost::program_options::basic_command_line_parser< charT >:

Public Member Functions

 basic_command_line_parser (const std::vector< std::basic_string< charT > > &args)
 Creates a command line parser for the specified arguments list. More...
 
 basic_command_line_parser (int argc, const charT *const argv[])
 Creates a command line parser for the specified arguments list. More...
 
basic_command_line_parseroptions (const options_description &desc)
 Sets options descriptions to use. More...
 
basic_command_line_parserpositional (const positional_options_description &desc)
 Sets positional options description to use. More...
 
basic_command_line_parserstyle (int)
 Sets the command line style. More...
 
basic_command_line_parserextra_parser (ext_parser)
 Sets the extra parsers. More...
 
basic_parsed_options< charT > run ()
 Parses the options and returns the result of parsing. More...
 
basic_command_line_parserallow_unregistered ()
 Specifies that unregistered options are allowed and should be passed though. More...
 
basic_command_line_parserextra_style_parser (style_parser s)
 

Detailed Description

template<class charT>
class boost::program_options::basic_command_line_parser< charT >

Command line parser.

The class allows one to specify all the information needed for parsing and to parse the command line. It is primarily needed to emulate named function parameters – a regular function with 5 parameters will be hard to use and creating overloads with a smaller nuber of parameters will be confusing.

For the most common case, the function parse_command_line is a better alternative.

There are two typedefs – command_line_parser and wcommand_line_parser, for charT == char and charT == wchar_t cases.

Constructor & Destructor Documentation

template<class charT >
boost::program_options::basic_command_line_parser< charT >::basic_command_line_parser ( const std::vector< std::basic_string< charT > > &  args)

Creates a command line parser for the specified arguments list.

The 'args' parameter should not include program name.

template<class charT >
boost::program_options::basic_command_line_parser< charT >::basic_command_line_parser ( int  argc,
const charT *const  argv[] 
)

Creates a command line parser for the specified arguments list.

The parameters should be the same as passed to 'main'.

Member Function Documentation

template<class charT >
basic_command_line_parser& boost::program_options::basic_command_line_parser< charT >::allow_unregistered ( )

Specifies that unregistered options are allowed and should be passed though.

For each command like token that looks like an option but does not contain a recognized name, an instance of basic_option<charT> will be added to result, with 'unrecognized' field set to 'true'. It's possible to collect all unrecognized options with the 'collect_unrecognized' funciton.

template<class charT >
basic_command_line_parser& boost::program_options::basic_command_line_parser< charT >::extra_parser ( ext_parser  )

Sets the extra parsers.

template<class charT >
basic_command_line_parser& boost::program_options::basic_command_line_parser< charT >::extra_style_parser ( style_parser  s)
template<class charT >
basic_command_line_parser& boost::program_options::basic_command_line_parser< charT >::options ( const options_description desc)

Sets options descriptions to use.

Sets positional options description to use.

template<class charT >
basic_parsed_options<charT> boost::program_options::basic_command_line_parser< charT >::run ( )

Parses the options and returns the result of parsing.

Throws on error.

template<class charT >
basic_command_line_parser& boost::program_options::basic_command_line_parser< charT >::style ( int  )

Sets the command line style.


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