1 ///////////////////////////////////////////////////////////////////////////////
\r
3 // File : $Id: _tpb.cpp,v 1.2 2009/03/19 20:00:28 faust Exp $
\r
4 // Subject : IBPP, internal TPB 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 // * TPB == Transaction Parameter 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 const int TPB::BUFFERINCR = 128;
\r
47 void TPB::Grow(int needed)
\r
49 if (mBuffer == 0) ++needed; // Initial alloc will require one more byte
\r
50 if ((mSize + needed) > mAlloc)
\r
52 // We need to grow the buffer. We use increments of BUFFERINCR bytes.
\r
53 needed = (needed / BUFFERINCR + 1) * BUFFERINCR;
\r
54 char* newbuffer = new char[mAlloc + needed];
\r
57 // Initial allocation, initialize the version tag
\r
58 newbuffer[0] = isc_tpb_version3;
\r
63 // Move the old buffer content to the new one
\r
64 memcpy(newbuffer, mBuffer, mSize);
\r
67 mBuffer = newbuffer;
\r
72 void TPB::Insert(char item)
\r
75 mBuffer[mSize++] = item;
\r
78 void TPB::Insert(const std::string& data)
\r
80 int len = (int)data.length();
\r
82 mBuffer[mSize++] = (char)len;
\r
83 strncpy(&mBuffer[mSize], data.c_str(), len);
\r