LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
cmd_line_parser.h
Go to the documentation of this file.
1// -*-c++-*-
2
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa AKIYAMA
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
31
32#ifndef RCSC_PARAM_CMD_LINE_PARSER_H
33#define RCSC_PARAM_CMD_LINE_PARSER_H
34
36
37#include <list>
38#include <vector>
39#include <string>
40#include <ostream>
41
42namespace rcsc {
43
49 : public ParamParser {
50private:
51
53 std::list< std::string > M_args;
54
56 std::vector< std::string > M_positional_options;
57
59 std::vector< std::string > M_parsed_option_names;
60
61 // not used
62 CmdLineParser() = delete;
63public:
64
70 CmdLineParser( const int argc,
71 const char * const * argv );
72
77 explicit
78 CmdLineParser( const std::list< std::string > & args );
79
85 bool parse( ParamMap & param_map ) override;
86
87private:
88
92 void parsePositional();
93
94public:
95
100 const std::list< std::string > & args() const
101 {
102 return M_args;
103 }
104
109 bool failed() const
110 {
111 return M_args.size() != M_positional_options.size();
112 }
113
118 const std::vector< std::string > & positionalOptions() const
119 {
120 return M_positional_options;
121 }
122
127 const std::vector< std::string > & parsedOptionNames() const
128 {
129 return M_parsed_option_names;
130 }
131
137 std::size_t count( const std::string & option_name ) const;
138
144 std::ostream & print( std::ostream & os ) const;
145
152 std::ostream & printOptionNameArgs( std::ostream & os,
153 const char sep ) const;
154
155};
156
157}
158
159#endif
command line parser
Definition: cmd_line_parser.h:49
CmdLineParser(const std::list< std::string > &args)
construct with original command line arguments
bool parse(ParamMap &param_map) override
analyze arguments and results are stored to parameter map
std::ostream & printOptionNameArgs(std::ostream &os, const char sep) const
put the remained argments stated with '-'.
CmdLineParser(const int argc, const char *const *argv)
construct with original command line arguments
std::ostream & print(std::ostream &os) const
put the stored arguments to the output stream
const std::vector< std::string > & positionalOptions() const
get the positional arguments
Definition: cmd_line_parser.h:118
const std::vector< std::string > & parsedOptionNames() const
get the parsed option names
Definition: cmd_line_parser.h:127
std::size_t count(const std::string &option_name) const
get the number of the parsed option name
bool failed() const
check if all arguments are successfully parsed.
Definition: cmd_line_parser.h:109
const std::list< std::string > & args() const
get the stored arguments
Definition: cmd_line_parser.h:100
parameter container
Definition: param_map.h:484
abstract parameter paraser class
Definition: param_parser.h:43
abstract parameter parser Header File