VR-Link API Documentation for HLA 1516
 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  std::string 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 
121  };
122 
128  {
129  public:
136  ArgParseException( const std::string& text = "undefined exception",
137  const std::string& id = "undefined" )
138  : ArgException( text,
139  id,
140  std::string( "Exception found while parsing " ) +
141  std::string( "the value the Arg has been passed." ))
142  { }
143  };
144 
150  {
151  public:
158  CmdLineParseException( const std::string& text = "undefined exception",
159  const std::string& id = "undefined" )
160  : ArgException( text,
161  id,
162  std::string( "Exception found when the values ") +
163  std::string( "on the command line do not meet ") +
164  std::string( "the requirements of the defined ") +
165  std::string( "Args." ))
166  { }
167  };
168 
174  {
175  public:
182  SpecificationException( const std::string& text = "undefined exception",
183  const std::string& id = "undefined" )
184  : ArgException( text,
185  id,
186  std::string("Exception found when an Arg object ")+
187  std::string("is improperly defined by the ") +
188  std::string("developer." ))
189  { }
190 
191  };
192 
193 }
194 
195 #ifdef DtUSE_UTILITIES_NAMESPACE
196 }
197 #endif
198 
199 #endif
200 

Document ID: Generated on Tue Mar 1 02:56:17 EST 2016 from SVN revision 162687
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)