00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef OPENRJ_INCL_OPENRJ_STL_HPP_OPENRJ
00048 #define OPENRJ_INCL_OPENRJ_STL_HPP_OPENRJ
00049
00050
00051
00052
00053
00054 #ifndef OPENRJ_DOCUMENTATION_SKIP_SECTION
00055 # define OPENRJ_VER_OPENRJ_STL_HPP_OPENRJ_MAJOR 1
00056 # define OPENRJ_VER_OPENRJ_STL_HPP_OPENRJ_MINOR 4
00057 # define OPENRJ_VER_OPENRJ_STL_HPP_OPENRJ_REVISION 2
00058 # define OPENRJ_VER_OPENRJ_STL_HPP_OPENRJ_EDIT 19
00059 #endif
00060
00061
00062
00063
00064
00065 #include <openrj/openrj.h>
00066 #include <openrj/openrj_assert.h>
00067
00068 #ifdef OPENRJ_DOCUMENTATION_SKIP_SECTION
00069 # include <openrj/stl/openrjfwd.hpp>
00070 #endif
00071
00072
00073 #if defined(ORJ_NO_EXCEPTIONS)
00074 # error The Open-RJ STL mapping is not compilable in the absence of exceptions
00075 #endif
00076
00077 #include <stlsoft/stlsoft.h>
00078
00079 #if !defined(_STLSOFT_VER_1_9_1)
00080 # error STLSoft version 1.9.1 or greater required. (www.stlsoft.org/downloads.html)
00081 #endif
00082
00083 #include <stlsoft/conversion/integer_to_string.hpp>
00084
00085 #include <exception>
00086 #if defined(OPENRJ_USE_CUSTOM_STRING)
00087 # include OPENRJ_CUSTOM_STRING_INCLUDE
00088 #else
00089 # include <string>
00090 #endif
00091
00092 #include <string.h>
00093
00094
00095
00096
00097
00098 #ifdef __BORLANDC__
00099 # pragma warn -8027
00100 #endif
00101
00102
00103
00104
00105
00106 namespace openrj
00107 {
00108 namespace stl
00109 {
00110
00111
00112
00113
00114
00116 #if defined(OPENRJ_USE_CUSTOM_STRING)
00117 typedef OPENRJ_CUSTOM_STRING_TYPE string_t;
00118 #else
00119 typedef std::string string_t;
00120 #endif
00121
00122
00123
00124
00125
00127 class database_exception
00128 : public std::exception
00129 {
00132 public:
00133 typedef std::exception parent_class_type;
00134 typedef database_exception class_type;
00136
00139 public:
00141 database_exception(ORJRC rc, ORJError const &error)
00142 : m_rc(rc)
00143 , m_error(error)
00144 , m_message(create_message_(rc, error))
00145 {}
00146 #ifdef STLSOFT_COMPILER_IS_GCC
00147 virtual ~database_exception() throw()
00148 {}
00149 #endif
00151
00154 public:
00156 ORJRC rc() const
00157 {
00158 return m_rc;
00159 }
00161 ORJError const &error() const
00162 {
00163 return m_error;
00164 }
00165
00167 virtual char const *what() const throw()
00168 {
00169 return (ORJ_RC_PARSEERROR == m_rc) ? m_message.c_str() : ORJ_GetErrorStringA(m_rc);
00170 }
00172
00175 private:
00176 static string_t create_message_(ORJRC rc, ORJError const &error)
00177 {
00178 string_t s;
00179
00180 if(ORJ_RC_PARSEERROR == rc)
00181 {
00182 char message[201];
00183 char sz1[21];
00184 char sz2[21];
00185
00186
00187
00188 ::strcpy(message, "' at line ");
00189 ::strcat(message, ::stlsoft::integer_to_string(&sz1[0], stlsoft_num_elements(sz1), error.invalidLine));
00190 ::strcat(message, " column ");
00191 ::strcat(message, ::stlsoft::integer_to_string(&sz2[0], stlsoft_num_elements(sz2), error.invalidColumn));
00192
00193 s = "Parse error '";
00194 s += ORJ_GetParseErrorStringA(error.parseError);
00195 s += message;
00196 }
00197
00198 return s;
00199 }
00201
00204 private:
00205 ORJRC m_rc;
00206 ORJError m_error;
00207 const string_t m_message;
00209
00210
00211 private:
00212 class_type &operator =(class_type const &);
00213 };
00214
00215
00216
00217
00218
00219 }
00220 }
00221
00222
00223
00224 #endif
00225
00226