]> git.stg.codes - stg.git/blob - stglibs/ibpp.lib/_ibs.cpp
Merge branch 'stg-2.409-radius'
[stg.git] / stglibs / ibpp.lib / _ibs.cpp
1 ///////////////////////////////////////////////////////////////////////////////\r
2 //\r
3 //      File    : $Id: _ibs.cpp,v 1.2 2009/03/19 20:00:27 faust Exp $\r
4 //      Subject : IBPP, internal Status class implementation\r
5 //\r
6 ///////////////////////////////////////////////////////////////////////////////\r
7 //\r
8 //      (C) Copyright 2000-2006 T.I.P. Group S.A. and the IBPP Team (www.ibpp.org)\r
9 //\r
10 //      The contents of this file are subject to the IBPP License (the "License");\r
11 //      you may not use this file except in compliance with the License.  You may\r
12 //      obtain a copy of the License at http://www.ibpp.org or in the 'license.txt'\r
13 //      file which must have been distributed along with this file.\r
14 //\r
15 //      This software, distributed under the License, is distributed on an "AS IS"\r
16 //      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the\r
17 //      License for the specific language governing rights and limitations\r
18 //      under the License.\r
19 //\r
20 ///////////////////////////////////////////////////////////////////////////////\r
21 //\r
22 //      COMMENTS\r
23 //      * Tabulations should be set every four characters when editing this file.\r
24 //\r
25 ///////////////////////////////////////////////////////////////////////////////\r
26 \r
27 #ifdef _MSC_VER\r
28 #pragma warning(disable: 4786 4996)\r
29 #ifndef _DEBUG\r
30 #pragma warning(disable: 4702)\r
31 #endif\r
32 #endif\r
33 \r
34 #include "_ibpp.h"\r
35 \r
36 #ifdef HAS_HDRSTOP\r
37 #pragma hdrstop\r
38 #endif\r
39 \r
40 #include <cstring>\r
41 \r
42 using namespace ibpp_internals;\r
43 \r
44 int IBS::SqlCode() const\r
45 {\r
46         return (int)(*gds.Call()->m_sqlcode)(&mVector[0]);\r
47 }\r
48 \r
49 const char* IBS::ErrorMessage() const\r
50 {\r
51         char msg[1024];\r
52         ISC_LONG sqlcode;\r
53 \r
54         if (! mMessage.empty()) return mMessage.c_str();        // If message compiled, returns it\r
55 \r
56         // Compiles the message (SQL part)\r
57         std::ostringstream message;\r
58         sqlcode = (*gds.Call()->m_sqlcode)(mVector);\r
59         if (sqlcode != -999)\r
60         {\r
61                 (*gds.Call()->m_sql_interprete)((short)sqlcode, msg, sizeof(msg));\r
62                 message<< _("SQL Message : ")<< sqlcode<< "\n"<< msg<< "\n\n";\r
63         }\r
64 \r
65         message<< _("Engine Code    : ")<< EngineCode()<< "\n";\r
66 \r
67         // Compiles the message (Engine part)\r
68         ISC_STATUS* error = &mVector[0];\r
69         try { (*gds.Call()->m_interprete)(msg, &error); }\r
70         catch(...) { msg[0] = '\0'; }\r
71         message<< _("Engine Message :")<< "\n"<< msg;\r
72         try\r
73         {\r
74                 while ((*gds.Call()->m_interprete)(msg, &error))\r
75                         message<< "\n"<< msg;\r
76         }\r
77         catch (...) { }\r
78 \r
79         message<< "\n";\r
80         mMessage = message.str();\r
81         return mMessage.c_str();\r
82 }\r
83 \r
84 void IBS::Reset()\r
85 {\r
86         for (int i = 0; i < 20; i++) mVector[i] = 0;\r
87         mMessage.erase();\r
88 }\r
89 \r
90 IBS::IBS()\r
91 {\r
92         Reset();\r
93 }\r
94 \r
95 IBS::~IBS()\r
96 {\r
97 }\r
98 \r
99 /** Copy Constructor\r
100 */\r
101 \r
102 IBS::IBS(IBS& copied)\r
103 {\r
104         memcpy(mVector, copied.mVector, sizeof(mVector));\r
105 }\r
106 \r
107 //\r
108 //      EOF\r
109 //\r