1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title>Class template basic_command_line_parser</title> |
---|
5 | <link rel="stylesheet" href="boostbook.css" type="text/css"> |
---|
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> |
---|
7 | <link rel="start" href="index.html" title="The Boost C++ Libraries"> |
---|
8 | <link rel="up" href="program_options/reference.html#id2348797" title="Header <boost/program_options/parsers.hpp>"> |
---|
9 | <link rel="prev" href="id2381437-bb.html" title="Class basic_parsed_options<wchar_t>"> |
---|
10 | <link rel="next" href="id2348892.html" title="Type collect_unrecognized_mode"> |
---|
11 | </head> |
---|
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
---|
13 | <table cellpadding="2" width="100%"> |
---|
14 | <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td> |
---|
15 | <td align="center"><a href="../../index.htm">Home</a></td> |
---|
16 | <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> |
---|
17 | <td align="center"><a href="../../people/people.htm">People</a></td> |
---|
18 | <td align="center"><a href="../../more/faq.htm">FAQ</a></td> |
---|
19 | <td align="center"><a href="../../more/index.htm">More</a></td> |
---|
20 | </table> |
---|
21 | <hr> |
---|
22 | <div class="spirit-nav"> |
---|
23 | <a accesskey="p" href="id2381437-bb.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="program_options/reference.html#id2348797"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="id2348892.html"><img src="images/next.png" alt="Next"></a> |
---|
24 | </div> |
---|
25 | <div class="refentry" lang="en"> |
---|
26 | <a name="basic_command_line_parser"></a><div class="titlepage"></div> |
---|
27 | <div class="refnamediv"> |
---|
28 | <h2><span class="refentrytitle">Class template basic_command_line_parser</span></h2> |
---|
29 | <p>boost::program_options::basic_command_line_parser — </p> |
---|
30 | </div> |
---|
31 | <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> |
---|
32 | <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> charT> |
---|
33 | <span class="bold"><strong>class</strong></span> basic_command_line_parser { |
---|
34 | <span class="bold"><strong>public</strong></span>: |
---|
35 | <span class="emphasis"><em>// <a href="basic_command_line_parser.html#basic_command_line_parserconstruct-copy-destruct">construct/copy/destruct</a></em></span> |
---|
36 | <a href="basic_command_line_parser.html#id2360299-bb">basic_command_line_parser</a>(<span class="bold"><strong>const</strong></span> std::vector< std::basic_string< charT > > &); |
---|
37 | <a href="basic_command_line_parser.html#id2395534-bb">basic_command_line_parser</a>(<span class="bold"><strong>int</strong></span>, charT *); |
---|
38 | |
---|
39 | <span class="emphasis"><em>// <a href="basic_command_line_parser.html#id2359403-bb">public member functions</a></em></span> |
---|
40 | <span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a href="basic_command_line_parser.html#id2359408-bb">options</a>(<span class="bold"><strong>const</strong></span> <a href="options_description.html" title="Class options_description">options_description</a> &) ; |
---|
41 | <span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> |
---|
42 | <a href="basic_command_line_parser.html#id2442218-bb">positional</a>(<span class="bold"><strong>const</strong></span> <a href="id2525902.html" title="Class positional_options_description">positional_options_description</a> &) ; |
---|
43 | <span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a href="basic_command_line_parser.html#id2425682-bb">style</a>(<span class="bold"><strong>int</strong></span>) ; |
---|
44 | <span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a href="basic_command_line_parser.html#id2395244-bb">extra_parser</a>(ext_parser) ; |
---|
45 | <span class="type"><a href="basic_parsed_options.html" title="Class template basic_parsed_options">basic_parsed_options</a>< charT ></span> <a href="basic_command_line_parser.html#id2354252-bb">run</a>() ; |
---|
46 | <span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a href="basic_command_line_parser.html#id2491704-bb">allow_unregistered</a>() ; |
---|
47 | <span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a href="basic_command_line_parser.html#id2360273-bb">extra_style_parser</a>(style_parser) ; |
---|
48 | };</pre></div> |
---|
49 | <div class="refsect1" lang="en"> |
---|
50 | <a name="id2723808"></a><h2>Description</h2> |
---|
51 | <p>Command line parser.</p> |
---|
52 | <p>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.</p> |
---|
53 | <p>For the most common case, the function parse_command_line is a better alternative.</p> |
---|
54 | <p>There are two typedefs -- command_line_parser and wcommand_line_parser, for charT == char and charT == wchar_t cases. </p> |
---|
55 | <div class="refsect2" lang="en"> |
---|
56 | <a name="id2723829"></a><h3> |
---|
57 | <a name="basic_command_line_parserconstruct-copy-destruct"></a><code class="computeroutput">basic_command_line_parser</code> construct/copy/destruct</h3> |
---|
58 | <div class="orderedlist"><ol type="1"> |
---|
59 | <li> |
---|
60 | <pre class="literallayout"><a name="id2360299-bb"></a>basic_command_line_parser(<span class="bold"><strong>const</strong></span> std::vector< std::basic_string< charT > > & args);</pre> |
---|
61 | <p>Creates a command line parser for the specified arguments list. The 'args' parameter should not include program name. </p> |
---|
62 | </li> |
---|
63 | <li> |
---|
64 | <pre class="literallayout"><a name="id2395534-bb"></a>basic_command_line_parser(<span class="bold"><strong>int</strong></span> argc, charT * argv);</pre> |
---|
65 | <p>Creates a command line parser for the specified arguments list. The parameters should be the same as passed to 'main'. </p> |
---|
66 | </li> |
---|
67 | </ol></div> |
---|
68 | </div> |
---|
69 | <div class="refsect2" lang="en"> |
---|
70 | <a name="id2723900"></a><h3> |
---|
71 | <a name="id2359403-bb"></a><code class="computeroutput">basic_command_line_parser</code> public member functions</h3> |
---|
72 | <div class="orderedlist"><ol type="1"> |
---|
73 | <li> |
---|
74 | <pre class="literallayout"><span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a name="id2359408-bb"></a>options(<span class="bold"><strong>const</strong></span> <a href="options_description.html" title="Class options_description">options_description</a> & desc) ;</pre> |
---|
75 | <p>Sets options descriptions to use. </p> |
---|
76 | </li> |
---|
77 | <li> |
---|
78 | <pre class="literallayout"><span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> |
---|
79 | <a name="id2442218-bb"></a>positional(<span class="bold"><strong>const</strong></span> <a href="id2525902.html" title="Class positional_options_description">positional_options_description</a> & desc) ;</pre> |
---|
80 | <p>Sets positional options description to use. </p> |
---|
81 | </li> |
---|
82 | <li> |
---|
83 | <pre class="literallayout"><span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a name="id2425682-bb"></a>style(<span class="bold"><strong>int</strong></span> ) ;</pre> |
---|
84 | <p>Sets the command line style. </p> |
---|
85 | </li> |
---|
86 | <li> |
---|
87 | <pre class="literallayout"><span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a name="id2395244-bb"></a>extra_parser(ext_parser ) ;</pre> |
---|
88 | <p>Sets the extra parsers. </p> |
---|
89 | </li> |
---|
90 | <li> |
---|
91 | <pre class="literallayout"><span class="type"><a href="basic_parsed_options.html" title="Class template basic_parsed_options">basic_parsed_options</a>< charT ></span> <a name="id2354252-bb"></a>run() ;</pre> |
---|
92 | <p>Parses the options and returns the result of parsing. Throws on error. </p> |
---|
93 | </li> |
---|
94 | <li> |
---|
95 | <pre class="literallayout"><span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a name="id2491704-bb"></a>allow_unregistered() ;</pre> |
---|
96 | <p>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. </p> |
---|
97 | </li> |
---|
98 | <li><pre class="literallayout"><span class="type"><a href="basic_command_line_parser.html" title="Class template basic_command_line_parser">basic_command_line_parser</a> &</span> <a name="id2360273-bb"></a>extra_style_parser(style_parser s) ;</pre></li> |
---|
99 | </ol></div> |
---|
100 | </div> |
---|
101 | </div> |
---|
102 | </div> |
---|
103 | <table width="100%"><tr> |
---|
104 | <td align="left"></td> |
---|
105 | <td align="right"><small>Copyright © 2002-2004 Vladimir Prus</small></td> |
---|
106 | </tr></table> |
---|
107 | <hr> |
---|
108 | <div class="spirit-nav"> |
---|
109 | <a accesskey="p" href="id2381437-bb.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="program_options/reference.html#id2348797"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="id2348892.html"><img src="images/next.png" alt="Next"></a> |
---|
110 | </div> |
---|
111 | </body> |
---|
112 | </html> |
---|