OpenASIP 2.2
Loading...
Searching...
No Matches
CmdLineOptions.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file CmdLineOptions.hh
26 *
27 * Declaration of class CmdLineOptions.
28 *
29 * @author Jussi Nykänen 2003 (nykanen-no.spam-cs.tut.fi)
30 * @author Jari Mäntyneva 2006 (jari.mantyneva-no.spam-tut.fi)
31 * @note reviewed 3 December 2003 by jn, kl, ao
32 * @note rating: red
33 */
34
35#ifndef TTA_CMD_LINE_OPTIONS_HH
36#define TTA_CMD_LINE_OPTIONS_HH
37
38#include <map>
39#include <vector>
40#include <string>
41
42#include "CmdLineParser.hh"
43//#include "CmdLineOptionParser.hh"
44#include "Exception.hh"
45#include "Application.hh"
46
48
49/**
50 * Abstract base class for command line parsers.
51 *
52 * Is capable of storing and parsing commmand line options.
53 */
55public:
56 CmdLineOptions(std::string description, std::string version = "");
57 virtual ~CmdLineOptions();
58
59 void parse(char* argv[], int argc);
60 void parse(std::string argv[], int argc);
61 void parse(std::vector<std::string> argv);
62 virtual void printHelp() const;
63 virtual void printVersion() const = 0;
64
65 virtual bool isVerboseSwitchDefined() const;
66 virtual bool isVerboseSpamSwitchDefined() const;
67
68protected:
69 bool optionGiven(std::string key) const;
70private:
71 /// For adding new values to maps.
72 typedef std::map<std::string, CmdLineOptionParser*>::value_type valType;
73 /// For traversing non-const maps.
74 typedef std::map<std::string, CmdLineOptionParser*>::iterator mapIter;
75 /// For traversing const maps.
76 typedef
77 std::map<std::string, CmdLineOptionParser*>::const_iterator constMapIter;
78
79 /// Copying not allowed.
81 /// Assignment not allowed.
83
84 void parseAll();
85
86 /// The name of the program.
87 std::string progName_;
88 /// The description of usage of program.
89 std::string description_;
90 /// The version of the program.
91 std::string version_;
92
93 /// Number of characters reserved for printing short version
94 /// of commandline flag.
95 static const int SHORT_FLAG;
96
97 /// Number of characters reserved for printing long version
98 /// of commandline flag.
99 static const int LONG_FLAG;
100
101 /// Switch for verbose output listing scheduler modules
102 static const std::string VERBOSE_SWITCH;
103
104 /// Switch for verbose output listing spam from scheduler internals
105 static const std::string VERBOSE_SPAM_SWITCH;
106
107};
108
109#endif
static const int LONG_FLAG
Number of characters reserved for printing long version of commandline flag.
CmdLineOptions(const CmdLineOptions &)
Copying not allowed.
std::map< std::string, CmdLineOptionParser * >::const_iterator constMapIter
For traversing const maps.
void parse(char *argv[], int argc)
std::string progName_
The name of the program.
virtual ~CmdLineOptions()
static const std::string VERBOSE_SWITCH
Switch for verbose output listing scheduler modules.
std::map< std::string, CmdLineOptionParser * >::value_type valType
For adding new values to maps.
static const int SHORT_FLAG
Number of characters reserved for printing short version of commandline flag.
std::string version_
The version of the program.
bool optionGiven(std::string key) const
virtual bool isVerboseSwitchDefined() const
CmdLineOptions & operator=(const CmdLineOptions &)
Assignment not allowed.
static const std::string VERBOSE_SPAM_SWITCH
Switch for verbose output listing spam from scheduler internals.
virtual bool isVerboseSpamSwitchDefined() const
virtual void printHelp() const
std::map< std::string, CmdLineOptionParser * >::iterator mapIter
For traversing non-const maps.
virtual void printVersion() const =0
std::string description_
The description of usage of program.