1 ///////////////////////////////////////////////////////////////////////////////
\r
3 // File : $Id: _rb.cpp,v 1.2 2009/03/19 20:00:27 faust Exp $
\r
4 // Subject : IBPP, internal RB class implementation
\r
6 ///////////////////////////////////////////////////////////////////////////////
\r
8 // (C) Copyright 2000-2006 T.I.P. Group S.A. and the IBPP Team (www.ibpp.org)
\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
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
20 ///////////////////////////////////////////////////////////////////////////////
\r
23 // * RB == Result Block/Buffer, see Interbase 6.0 C-API
\r
24 // * Tabulations should be set every four characters when editing this file.
\r
26 ///////////////////////////////////////////////////////////////////////////////
\r
29 #pragma warning(disable: 4786 4996)
\r
31 #pragma warning(disable: 4702)
\r
43 using namespace ibpp_internals;
\r
45 char* RB::FindToken(char token)
\r
49 while (*p != isc_info_end)
\r
53 if (*p == token) return p;
\r
54 len = (*gds.Call()->m_vax_integer)(p+1, 2);
\r
61 char* RB::FindToken(char token, char subtoken)
\r
65 while (*p != isc_info_end)
\r
71 // Found token, now find subtoken
\r
72 int inlen = (*gds.Call()->m_vax_integer)(p+1, 2);
\r
76 if (*p == subtoken) return p;
\r
77 len = (*gds.Call()->m_vax_integer)(p+1, 2);
\r
83 len = (*gds.Call()->m_vax_integer)(p+1, 2);
\r
90 int RB::GetValue(char token)
\r
94 char* p = FindToken(token);
\r
97 throw LogicExceptionImpl("RB::GetValue", _("Token not found."));
\r
99 len = (*gds.Call()->m_vax_integer)(p+1, 2);
\r
100 if (len == 0) value = 0;
\r
101 else value = (*gds.Call()->m_vax_integer)(p+3, (short)len);
\r
106 int RB::GetCountValue(char token)
\r
108 // Specifically used on tokens like isc_info_insert_count and the like
\r
109 // which return detailed counts per relation. We sum up the values.
\r
112 char* p = FindToken(token);
\r
115 throw LogicExceptionImpl("RB::GetCountValue", _("Token not found."));
\r
117 // len is the number of bytes in the following array
\r
118 len = (*gds.Call()->m_vax_integer)(p+1, 2);
\r
123 // Each array item is 6 bytes : 2 bytes for the relation_id which
\r
124 // we skip, and 4 bytes for the count value which we sum up accross
\r
126 value += (*gds.Call()->m_vax_integer)(p+2, 4);
\r
134 int RB::GetValue(char token, char subtoken)
\r
138 char* p = FindToken(token, subtoken);
\r
141 throw LogicExceptionImpl("RB::GetValue", _("Token/Subtoken not found."));
\r
143 len = (*gds.Call()->m_vax_integer)(p+1, 2);
\r
144 if (len == 0) value = 0;
\r
145 else value = (*gds.Call()->m_vax_integer)(p+3, (short)len);
\r
150 bool RB::GetBool(char token)
\r
153 char* p = FindToken(token);
\r
156 throw LogicExceptionImpl("RB::GetBool", _("Token not found."));
\r
158 value = (*gds.Call()->m_vax_integer)(p+1, 4);
\r
160 return value == 0 ? false : true;
\r
163 int RB::GetString(char token, std::string& data)
\r
166 char* p = FindToken(token);
\r
169 throw LogicExceptionImpl("RB::GetString", _("Token not found."));
\r
171 len = (*gds.Call()->m_vax_integer)(p+1, 2);
\r
172 data = std::string(p+3, len);
\r
179 mBuffer = new char [mSize];
\r
180 memset(mBuffer, 255, mSize);
\r
186 mBuffer = new char [1024];
\r
187 memset(mBuffer, 255, mSize);
\r
193 mBuffer = new char [Size];
\r
194 memset(mBuffer, 255, mSize);
\r
199 try { delete [] mBuffer; }
\r