GeoTessCPP  2.2
Software to facilitate storage and retrieval of 3D information about the Earth.
GeoTessException.h
Go to the documentation of this file.
1 //- ****************************************************************************
2 //-
3 //- Copyright 2009 Sandia Corporation. Under the terms of Contract
4 //- DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
5 //- retains certain rights in this software.
6 //-
7 //- BSD Open Source License.
8 //- All rights reserved.
9 //-
10 //- Redistribution and use in source and binary forms, with or without
11 //- modification, are permitted provided that the following conditions are met:
12 //-
13 //- * Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //- * Redistributions in binary form must reproduce the above copyright
16 //- notice, this list of conditions and the following disclaimer in the
17 //- documentation and/or other materials provided with the distribution.
18 //- * Neither the name of Sandia National Laboratories nor the names of its
19 //- contributors may be used to endorse or promote products derived from
20 //- this software without specific prior written permission.
21 //-
22 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 //- POSSIBILITY OF SUCH DAMAGE.
33 //-
34 //- ****************************************************************************
35 
36 #ifndef GEOTESSException_H
37 #define GEOTESSException_H
38 
39 // **** _SYSTEM INCLUDES_ ******************************************************
40 
41 #include <sstream>
42 
43 // **** _LOCAL INCLUDES_ *******************************************************
44 
45 #include "CPPUtils.h"
46 #include "GeoTessUtils.h"
47 
48 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
49 
50 namespace geotess
51 {
52 
53 // **** _FORWARD REFERENCES_ ***************************************************
54 
55 // **** _CLASS DEFINITION_ *****************************************************
56 
66 {
67 public:
68 
72  string emessage;
73 
77  int ecode;
78 
82  GeoTessException(std::string message, int code)
83  : emessage(message), ecode(code)
84  {
85  }
86 
93  GeoTessException(ostringstream& os, const string& file, int line, int code)
94  : emessage(""), ecode(code)
95  {
96  os << "OS: " << CPPUtils::getOpSys() << ", Version: "
97  << GeoTessUtils::getVersion() << ", File: " << file
98  << ", Line: " << line << endl << endl;
99  emessage = os.str();
100  }
101 
108  GeoTessException(const string& msg, const string& file, int line, int code)
109  : emessage(""), ecode(code)
110  {
111  emessage = msg + "\nOS: " + CPPUtils::getOpSys() + ", Version: "
112  + GeoTessUtils::getVersion() + ", File: " + file + ", Line: "
113  + CPPUtils::itos(line) + "\n\n";
114  }
115 
120  {
121  }
122 
126  static void appendInfo(ostringstream& os, const string& file, int line)
127  {
128  os << "Version: " << GeoTessUtils::getVersion() << ", File: " << file
129  << ", Line: " << line << endl << endl;
130  }
131 
135  static void appendInfo(string& msg, const string& file, int line)
136  {
137  msg += "\nVersion: " + GeoTessUtils::getVersion() + ", File: " + file
138  + ", Line: " + CPPUtils::itos(line) + "\n\n";
139  }
140 
141 };
142 // end class GeoTessException
143 
144 }// end geotess namespace
145 
146 #endif // GEOTESSException_H
Definition: ArrayReuse.h:55
virtual ~GeoTessException()
Destructor.
Definition: GeoTessException.h:119
GeoTessException(ostringstream &os, const string &file, int line, int code)
Standard Constructor taking a partially defined string stream, which contains the basic error message...
Definition: GeoTessException.h:93
static void appendInfo(ostringstream &os, const string &file, int line)
Appends version, file, and line number information to the input string stream.
Definition: GeoTessException.h:126
GeoTessException(const string &msg, const string &file, int line, int code)
Standard Constructor taking a partially defined string stream, which contains the basic error message...
Definition: GeoTessException.h:108
string emessage
Definition: GeoTessException.h:72
An exception class for all GeoTess objects.
Definition: GeoTessException.h:65
static const string getOpSys()
Returns the operating system type.
GeoTessException(std::string message, int code)
Parameterized constructor specifying the error message to be displayed.
Definition: GeoTessException.h:82
int ecode
Public error code set to one of the error constantants defined in this file.
Definition: GeoTessException.h:77
static string getVersion()
The current GeoTess version.
Definition: GeoTessUtils.h:125
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
static void appendInfo(string &msg, const string &file, int line)
Appends version, file, and line number information to the input string stream.
Definition: GeoTessException.h:135
static string itos(int i, const string &frmt="%d")
Static functions that returns the input integer, float, double, or boolean, as a string.