Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

Exception.h

Go to the documentation of this file.
00001 // SRM SDK Release 4.4.0 - December 7, 2009
00002 
00003 // - SRM spec. 4.4
00004 
00005 /*
00006  *                             NOTICE
00007  * 
00008  * This software is provided openly and freely for use in representing and
00009  * interchanging environmental data & databases.
00010  * 
00011  * This software was developed for use by the United States Government with
00012  * unlimited rights.  The software was developed under contract
00013  * DASG60-02-D-0006 TO-193 by Science Applications International Corporation.
00014  * The software is unclassified and is deemed as Distribution A, approved
00015  * for Public Release.
00016  * 
00017  * Use by others is permitted only upon the ACCEPTANCE OF THE TERMS AND
00018  * CONDITIONS, AS STIPULATED UNDER THE FOLLOWING PROVISIONS:
00019  * 
00020  *    1. Recipient may make unlimited copies of this software and give
00021  *       copies to other persons or entities as long as the copies contain
00022  *       this NOTICE, and as long as the same copyright notices that
00023  *       appear on, or in, this software remain.
00024  * 
00025  *    2. Trademarks. All trademarks belong to their respective trademark
00026  *       holders.  Third-Party applications/software/information are
00027  *       copyrighted by their respective owners.
00028  * 
00029  *    3. Recipient agrees to forfeit all intellectual property and
00030  *       ownership rights for any version created from the modification
00031  *       or adaptation of this software, including versions created from
00032  *       the translation and/or reverse engineering of the software design.
00033  * 
00034  *    4. Transfer.  Recipient may not sell, rent, lease, or sublicense
00035  *       this software.  Recipient may, however enable another person
00036  *       or entity the rights to use this software, provided that this
00037  *       AGREEMENT and NOTICE is furnished along with the software and
00038  *       /or software system utilizing this software.
00039  * 
00040  *       All revisions, modifications, created by the Recipient, to this
00041  *       software and/or related technical data shall be forwarded by the
00042  *       Recipient to the Government at the following address:
00043  * 
00044  *         SMDC
00045  *         Attention SEDRIS (TO193) TPOC
00046  *         P.O. Box 1500
00047  *         Hunstville, AL  35807-3801
00048  * 
00049  *         or via electronic mail to:  [email protected]
00050  * 
00051  *    5. No Warranty. This software is being delivered to you AS IS
00052  *       and there is no warranty, EXPRESS or IMPLIED, as to its use
00053  *       or performance.
00054  * 
00055  *       The RECIPIENT ASSUMES ALL RISKS, KNOWN AND UNKNOWN, OF USING
00056  *       THIS SOFTWARE.  The DEVELOPER EXPRESSLY DISCLAIMS, and the
00057  *       RECIPIENT WAIVES, ANY and ALL PERFORMANCE OR RESULTS YOU MAY
00058  *       OBTAIN BY USING THIS SOFTWARE OR DOCUMENTATION.  THERE IS
00059  *       NO WARRANTY, EXPRESS OR, IMPLIED, AS TO NON-INFRINGEMENT OF
00060  *       THIRD PARTY RIGHTS, MERCHANTABILITY, OR FITNESS FOR ANY
00061  *       PARTICULAR PURPOSE.  IN NO EVENT WILL THE DEVELOPER, THE
00062  *       UNITED STATES GOVERNMENT OR ANYONE ELSE ASSOCIATED WITH THE
00063  *       DEVELOPMENT OF THIS SOFTWARE BE HELD LIABLE FOR ANY CONSEQUENTIAL,
00064  *       INCIDENTAL OR SPECIAL DAMAGES, INCLUDING ANY LOST PROFITS
00065  *       OR LOST SAVINGS WHATSOEVER.
00066  */
00067 
00068 // SRM_OTHERS_GOES_HERE
00069 
00070 // $Id: Exception.h,v 1.5 2006/02/13 19:09:21 shend Exp $/*
00071 
00077 #ifndef _Exception_h
00078 #define _Exception_h
00079 
00080 #if !defined(_WIN32)
00081 #define EXPORT_SRM_CPP_DLL
00082 #elif defined(BUILD_SRM_CPP) /* SRM CPP Case */
00083 #if !defined(EXPORT_SRM_CPP_DLL)
00084 #if defined(_LIB)
00085 #define EXPORT_SRM_CPP_DLL
00086 #elif defined(_USRDLL)
00087 #define EXPORT_SRM_CPP_DLL __declspec(dllexport)
00088 #else
00089 #define EXPORT_SRM_CPP_DLL __declspec(dllimport)
00090 #endif
00091 #endif
00092 #else /* SRM C Case */
00093 #define EXPORT_SRM_CPP_DLL
00094 #endif /* _WIN32 && EXPORT_DLL */
00095 
00096 #include "srm_types.h"
00097 
00104 namespace srm
00105 {
00106 
00112 class EXPORT_SRM_CPP_DLL Exception
00113 {
00114 public:
00115 
00116     enum {
00118         MAX_EXCEPTION_STR_LEN = 2000
00119     };
00120 
00122     Exception( SRM_Status_Code code );
00124     Exception( SRM_Status_Code code, const char *what );
00126     Exception( const Exception &other );
00128     virtual ~Exception() {}
00129 
00131     Exception &operator =( const Exception &other );
00132 
00134     virtual void setCodeAndWhat( SRM_Status_Code code, const char *what )
00135     {
00136         int i=0;
00137         _code = code;
00138         while (what && *what && i < MAX_EXCEPTION_STR_LEN)
00139             _what[i] = *what, i++, what++;
00140         _what[i] = 0;
00141     }
00142 
00144     virtual SRM_Status_Code getCode() const { return _code; }
00146     virtual const char *getWhat() const { return _what; }
00147 
00148 protected:
00149 
00150     SRM_Status_Code _code; 
00151     char _what[MAX_EXCEPTION_STR_LEN+1]; 
00152 };
00153 
00154 
00156 
00157 inline Exception::Exception( SRM_Status_Code code )
00158 {
00159     setCodeAndWhat(code, "No details");
00160 }
00161 
00162 
00163 inline Exception::Exception( SRM_Status_Code code, const char *what )
00164 {
00165     setCodeAndWhat(code, what);
00166 }
00167 
00168 
00169 inline Exception::Exception( const Exception &other )
00170 {
00171     setCodeAndWhat(other.getCode(), other.getWhat());
00172 }
00173 
00174 
00175 inline Exception &Exception::operator =( const Exception &other )
00176 {
00177     setCodeAndWhat(other.getCode(), other.getWhat());
00178     return *this;
00179 }
00180 
00181 
00182 } // namespace srm
00183 
00184 #endif // _Exception_h

Spatial Reference Model C++ API Version 4.4 - December 7, 2009
Copyright © 2009 SEDRIS Docs by Doxygen 1.3.2