- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

commandline.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
20
21 #ifndef G_MAIN_COMMAND_LINE_H
22 #define G_MAIN_COMMAND_LINE_H
23
24 #include "gdef.h"
25 #include "gsmtp.h"
26 #include "garg.h"
27 #include "configuration.h"
28 #include "output.h"
29 #include "gstrings.h"
30 #include <string>
31
33 namespace Main
34 {
35 class CommandLine ;
36 class CommandLineImp ;
37 }
38
44 class Main::CommandLine
45 {
46 public:
47 static std::string switchSpec( bool is_windows ) ;
49
50 CommandLine( Main::Output & output , const G::Arg & arg , const std::string & spec ,
51 const std::string & version , const std::string & capabilities ) ;
53
54 ~CommandLine() ;
56
57 Configuration cfg() const ;
59
60 bool contains( const std::string & switch_ ) const ;
62
63 bool contains( const char * switch_ ) const ;
65
66 std::string value( const std::string & switch_ ) const ;
68
69 std::string value( const char * switch_ ) const ;
71
72 unsigned int value( const std::string & switch_ , unsigned int default_ ) const ;
74
75 unsigned int value( const char * switch_ , unsigned int default_ ) const ;
77
78 G::Strings value( const std::string & switch_ , const std::string & separators ) const ;
80
81 G::Strings value( const char * switch_ , const char * separators ) const ;
83
84 G::Arg::size_type argc() const ;
86
87 bool hasUsageErrors() const ;
89
90 bool hasSemanticError() const ;
92
93 void showHelp( bool error_stream = false ) const ;
95
96 void showUsageErrors( bool error_stream = true ) const ;
98
99 void showSemanticError( bool error_stream = true ) const ;
101
102 void logSemanticWarnings() const ;
104
105 void showArgcError( bool error_stream = true ) const ;
107
108 void showNoop( bool error_stream = false ) const ;
110
111 void showError( const std::string & reason , bool error_stream = true ) const ;
113
114 void showVersion( bool error_stream = false ) const ;
116
117 void showBanner( bool error_stream = false , const std::string & = std::string() ) const ;
119
120 void showCopyright( bool error_stream = false , const std::string & = std::string() ) const ;
122
123 void showCapabilities( bool error_stream = false , const std::string & = std::string() ) const ;
125
126 private:
127 CommandLine( const CommandLine & ) ; // not implemented
128 void operator=( const CommandLine & ) ; // not implemented
129
130 private:
131 CommandLineImp * m_imp ;
132 } ;
133
134 #endif
Main
Application-level classes.
gstrings.h
output.h
Main::CommandLine::showCopyright
void showCopyright(bool error_stream=false, const std::string &=std::string()) const
Writes a copyright message.
Definition: commandline_full.cpp:695
Main::CommandLine::cfg
Configuration cfg() const
Returns a Configuration object.
Definition: commandline_full.cpp:620
G::Arg::size_type
size_t size_type
Definition: garg.h:49
G::Strings
std::list< std::string > Strings
A std::list of std::strings.
Definition: gstrings.h:39
Main::CommandLine::showCapabilities
void showCapabilities(bool error_stream=false, const std::string &=std::string()) const
Writes a capability line.
Definition: commandline_full.cpp:700
Main::CommandLine::showError
void showError(const std::string &reason, bool error_stream=true) const
Writes a failed message.
Definition: commandline_full.cpp:680
Main::CommandLineImp
A private implementation class used by Main::CommandLine.
Definition: commandline_full.cpp:42
Main::CommandLine::CommandLine
CommandLine(Main::Output &output, const G::Arg &arg, const std::string &spec, const std::string &version, const std::string &capabilities)
Constructor.
Definition: commandline_full.cpp:609
Main::CommandLine::~CommandLine
~CommandLine()
Destructor.
Definition: commandline_full.cpp:615
Main::CommandLine::showBanner
void showBanner(bool error_stream=false, const std::string &=std::string()) const
Writes a startup banner.
Definition: commandline_full.cpp:690
Main::Output
An abstract interface for generating output on a command-line or a GUI.
Definition: output.h:38
Main::CommandLine::logSemanticWarnings
void logSemanticWarnings() const
Emits warnings about conflicting switches.
Definition: commandline_full.cpp:665
garg.h
Main::CommandLine::hasSemanticError
bool hasSemanticError() const
Returns true if the command line has logical errors (eg. conflicting switches).
Definition: commandline_full.cpp:645
Main::CommandLine::showArgcError
void showArgcError(bool error_stream=true) const
Writes a too-many-arguments error message.
Definition: commandline_full.cpp:670
Main::CommandLine::value
std::string value(const std::string &switch_) const
Returns the given switch's string value.
Definition: commandline_full.cpp:630
configuration.h
Main::CommandLine::contains
bool contains(const std::string &switch_) const
Returns true if the command line contained the give switch.
Definition: commandline_full.cpp:625
Main::CommandLine
A class which deals with the command-line interface to the process, both input and output...
Definition: commandline.h:44
Main::CommandLine::showVersion
void showVersion(bool error_stream=false) const
Writes the version number.
Definition: commandline_full.cpp:685
Main::CommandLine::hasUsageErrors
bool hasUsageErrors() const
Returns true if the command line has usage errors (eg. invalid switch).
Definition: commandline_full.cpp:640
Main::CommandLine::showUsageErrors
void showUsageErrors(bool error_stream=true) const
Writes the usage errors.
Definition: commandline_full.cpp:655
G::Arg
A class which holds a represention of the argc/argv command line array, and supports simple command-l...
Definition: garg.h:46
gsmtp.h
Main::CommandLine::showHelp
void showHelp(bool error_stream=false) const
Writes help text.
Definition: commandline_full.cpp:650
Main::CommandLine::showNoop
void showNoop(bool error_stream=false) const
Writes a nothing-to-do message.
Definition: commandline_full.cpp:675
Main::Configuration
An interface for returning application configuration information.
Definition: configuration.h:45
Main::CommandLine::switchSpec
static std::string switchSpec(bool is_windows)
Returns an o/s-specific G::GetOpt switch specification string.
Definition: commandline_full.cpp:604
Main::CommandLine::showSemanticError
void showSemanticError(bool error_stream=true) const
Writes the logic errors.
Definition: commandline_full.cpp:660
Main::CommandLine::argc
G::Arg::size_type argc() const
Returns the number of non-switch arguments on the command line.
Definition: commandline_full.cpp:635