VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmdArgException.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3  *
4  * file: ArgException.h
5  *
6  * Copyright (c) 2003, Michael E. Smoot .
7  * All rights reverved.
8  *
9  * See the file COPYING in the top directory of this distribution for
10  * more information.
11  *
12  * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18  * DEALINGS IN THE SOFTWARE.
19  *
20  *****************************************************************************/
24 
25 
26 #ifndef DtCmdLine_ARG_EXCEPTION_H
27 #define DtCmdLine_ARG_EXCEPTION_H
28 
29 
30 #include <string>
31 #include <exception>
32 
33 #ifdef DtUSE_UTILITIES_NAMESPACE
34 namespace DtUSE_UTILITIES_NAMESPACE
35 {
36 #endif
37 
38 namespace DtCmdLine {
39 
43  class ArgException : public std::exception
44  {
45  public:
46 
52  ArgException( const std::string& text = "undefined exception",
53  const std::string& id = "undefined",
54  const std::string& td = "Generic ArgException")
55  : std::exception(),
56  _errorText(text),
57  _argId( id ),
58  _typeDescription(td)
59  { }
60 
64  virtual ~ArgException() throw()
65  { }
66 
70  std::string error() const
71  { return ( _errorText ); }
72 
76  std::string argId() const
77  {
78  if ( _argId == "undefined" )
79  return " ";
80  else
81  return ( "Argument: " + _argId );
82  }
83 
87  const char* what() const throw()
88  {
89  _ex = _argId + " -- " + _errorText;
90  return _ex.c_str();
91  }
92 
97  std::string typeDescription() const
98  {
99  return _typeDescription;
100  }
101 
102 
103  private:
104 
108  std::string _errorText;
109 
113  std::string _argId;
114 
119  std::string _typeDescription;
120 
124  mutable std::string _ex;
125  };
126 
132  {
133  public:
140  ArgParseException( const std::string& text = "undefined exception",
141  const std::string& id = "undefined" )
142  : ArgException( text,
143  id,
144  std::string( "Exception found while parsing " ) +
145  std::string( "the value the Arg has been passed." ))
146  { }
147  };
148 
154  {
155  public:
162  CmdLineParseException( const std::string& text = "undefined exception",
163  const std::string& id = "undefined" )
164  : ArgException( text,
165  id,
166  std::string( "Exception found when the values ") +
167  std::string( "on the command line do not meet ") +
168  std::string( "the requirements of the defined ") +
169  std::string( "Args." ))
170  { }
171  };
172 
178  {
179  public:
186  SpecificationException( const std::string& text = "undefined exception",
187  const std::string& id = "undefined" )
188  : ArgException( text,
189  id,
190  std::string("Exception found when an Arg object ")+
191  std::string("is improperly defined by the ") +
192  std::string("developer." ))
193  { }
194 
195  };
196 
197 }
198 
199 #ifdef DtUSE_UTILITIES_NAMESPACE
200 }
201 #endif
202 
203 #endif
204 
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
Definition: cmdArgException.h:177
virtual ~ArgException()
Destructor.
Definition: cmdArgException.h:64
std::string typeDescription() const
Returns the type of the exception.
Definition: cmdArgException.h:97
Thrown from CmdLine when the arguments on the command line are not properly specified, e.g.
Definition: cmdArgException.h:153
Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...
Definition: cmdArgException.h:131
std::string argId() const
Returns the argument id.
Definition: cmdArgException.h:76
A simple class that defines and argument exception.
Definition: cmdArgException.h:43
ArgParseException(const std::string &text="undefined exception", const std::string &id="undefined")
Constructor.
Definition: cmdArgException.h:140
std::string _errorText
The text of the exception message.
Definition: cmdArgException.h:108
std::string error() const
Returns the error text.
Definition: cmdArgException.h:70
std::string _argId
The argument related to this exception.
Definition: cmdArgException.h:113
ArgException(const std::string &text="undefined exception", const std::string &id="undefined", const std::string &td="Generic ArgException")
Constructor.
Definition: cmdArgException.h:52
SpecificationException(const std::string &text="undefined exception", const std::string &id="undefined")
Constructor.
Definition: cmdArgException.h:186
std::string _ex
The exception text.
Definition: cmdArgException.h:124
std::string _typeDescription
Describes the type of the exception.
Definition: cmdArgException.h:119
const char * what() const
Returns the arg id and error text.
Definition: cmdArgException.h:87
CmdLineParseException(const std::string &text="undefined exception", const std::string &id="undefined")
Constructor.
Definition: cmdArgException.h:162

Document ID: Generated on Wed Mar 27 02:04:30 EDT 2024 from SVN revision 264570
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)