libcoyotl - A Library of C++ Tools

Created by Scott Robert Ladd at Coyote Gulch Productions.


command_line.h
1//---------------------------------------------------------------------
2// Algorithmic Conjurings @ http://www.coyotegulch.com
3//
4// command_line.h (libcoyotl)
5//---------------------------------------------------------------------
6//
7// Copyright 1990-2005 Scott Robert Ladd
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; either version 2 of the License, or
12// (at your option) any later version.
13//
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this program; if not, write to the
21// Free Software Foundation, Inc.
22// 59 Temple Place - Suite 330
23// Boston, MA 02111-1307, USA.
24//
25//-----------------------------------------------------------------------
26//
27// For more information on this software package, please visit
28// Scott's web site, Coyote Gulch Productions, at:
29//
30// http://www.coyotegulch.com
31//
32//-----------------------------------------------------------------------
33
34#if !defined(LIBCOYOTL_COMMAND_LINE_H)
35#define LIBCOYOTL_COMMAND_LINE_H
36
37// Standard C++
38#include <string>
39#include <vector>
40#include <set>
41
42namespace libcoyotl
43{
44 using std::string;
45 using std::vector;
46 using std::set;
47
48 // a very simple command-line parser
50 {
51 public:
52 struct option
53 {
54 string m_name;
55 string m_value;
56
57 option(const string & a_name)
58 : m_name(a_name), m_value("")
59 {
60 // nada
61 }
62 };
63
64 // create a command line parser
65 command_line(int argc, char * argv[], const set<string> & bool_opts);
66
67 // retrieve a list of options
68 const vector<option> & get_options() const
69 {
70 return m_options;
71 }
72
73 // retrieve a list of input values
74 const vector<string> & get_inputs() const
75 {
76 return m_inputs;
77 }
78
79 private:
80 // the set of option names, with associated values
81 vector<option> m_options;
82
83 // the set of inputs -- command line arguments not associated with an option
84 vector<string> m_inputs;
85
86 // a list of boolean options, which have no values
87 const std::set<std::string> & m_bool_opts;
88 };
89
90}
91
92#endif
A STL-compatible array class.
Definition array.h:73
Definition command_line.h:50
Definition command_line.h:53

© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.