tclap 1.2.1

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

ArgException.h
Go to the documentation of this file.
1 // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2
3 /******************************************************************************
4 *
5 * file: ArgException.h
6 *
7 * Copyright (c) 2003, Michael E. Smoot .
8 * All rights reverved.
9 *
10 * See the file COPYING in the top directory of this distribution for
11 * more information.
12 *
13 * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
20 *
21 *****************************************************************************/
22
23
24 #ifndef TCLAP_ARG_EXCEPTION_H
25 #define TCLAP_ARG_EXCEPTION_H
26
27 #include <string>
28 #include <exception>
29
30 namespace TCLAP {
31
36 class ArgException : public std::exception
37 {
38 public:
39
47 ArgException( const std::string& text = "undefined exception",
48 const std::string& id = "undefined",
49 const std::string& td = "Generic ArgException")
50 : std::exception(),
51 _errorText(text),
52 _argId( id ),
53 _typeDescription(td)
54 { }
55
59 virtual ~ArgException() throw() { }
60
64 std::string error() const { return ( _errorText ); }
65
69 std::string argId() const
70 {
71 if ( _argId == "undefined" )
72 return " ";
73 else
74 return ( "Argument: " + _argId );
75 }
76
80 const char* what() const throw()
81 {
82 static std::string ex;
83 ex = _argId + " -- " + _errorText;
84 return ex.c_str();
85 }
86
91 std::string typeDescription() const
92 {
93 return _typeDescription;
94 }
95
96
97 private:
98
102 std::string _errorText;
103
107 std::string _argId;
108
113 std::string _typeDescription;
114
115 };
116
121 class ArgParseException : public ArgException
122 {
123 public:
130 ArgParseException( const std::string& text = "undefined exception",
131 const std::string& id = "undefined" )
132 : ArgException( text,
133 id,
134 std::string( "Exception found while parsing " ) +
135 std::string( "the value the Arg has been passed." ))
136 { }
137 };
138
143 class CmdLineParseException : public ArgException
144 {
145 public:
152 CmdLineParseException( const std::string& text = "undefined exception",
153 const std::string& id = "undefined" )
154 : ArgException( text,
155 id,
156 std::string( "Exception found when the values ") +
157 std::string( "on the command line do not meet ") +
158 std::string( "the requirements of the defined ") +
159 std::string( "Args." ))
160 { }
161 };
162
167 class SpecificationException : public ArgException
168 {
169 public:
176 SpecificationException( const std::string& text = "undefined exception",
177 const std::string& id = "undefined" )
178 : ArgException( text,
179 id,
180 std::string("Exception found when an Arg object ")+
181 std::string("is improperly defined by the ") +
182 std::string("developer." ))
183 { }
184
185 };
186
187 class ExitException {
188 public:
189 ExitException(int estat) : _estat(estat) {}
190
191 int getExitStatus() const { return _estat; }
192
193 private:
194 int _estat;
195 };
196
197 } // namespace TCLAP
198
199 #endif
200
TCLAP::SpecificationException::SpecificationException
SpecificationException(const std::string &text="undefined exception", const std::string &id="undefined")
Constructor.
Definition: ArgException.h:176
TCLAP::ArgException::what
const char * what() const
Returns the arg id and error text.
Definition: ArgException.h:80
TCLAP::ExitException::getExitStatus
int getExitStatus() const
Definition: ArgException.h:191
TCLAP::ArgException
A simple class that defines and argument exception.
Definition: ArgException.h:36
TCLAP::CmdLineParseException
Thrown from CmdLine when the arguments on the command line are not properly specified, e.g.
Definition: ArgException.h:143
TCLAP::ArgException::~ArgException
virtual ~ArgException()
Destructor.
Definition: ArgException.h:59
TCLAP::ArgException::ArgException
ArgException(const std::string &text="undefined exception", const std::string &id="undefined", const std::string &td="Generic ArgException")
Constructor.
Definition: ArgException.h:47
TCLAP::ExitException::ExitException
ExitException(int estat)
Definition: ArgException.h:189
TCLAP::ExitException
Definition: ArgException.h:187
TCLAP::SpecificationException
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
Definition: ArgException.h:167
TCLAP::ArgParseException::ArgParseException
ArgParseException(const std::string &text="undefined exception", const std::string &id="undefined")
Constructor.
Definition: ArgException.h:130
TCLAP::ArgException::typeDescription
std::string typeDescription() const
Returns the type of the exception.
Definition: ArgException.h:91
TCLAP::ArgException::error
std::string error() const
Returns the error text.
Definition: ArgException.h:64
TCLAP::CmdLineParseException::CmdLineParseException
CmdLineParseException(const std::string &text="undefined exception", const std::string &id="undefined")
Constructor.
Definition: ArgException.h:152
TCLAP::ArgException::argId
std::string argId() const
Returns the argument id.
Definition: ArgException.h:69
TCLAP::ArgParseException
Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...
Definition: ArgException.h:121
TCLAP
Definition: Arg.h:57