--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// File : $Id: _dpb.cpp,v 1.2 2009/03/19 20:00:27 faust Exp $\r
+// Subject : IBPP, internal DPB class implementation\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// (C) Copyright 2000-2006 T.I.P. Group S.A. and the IBPP Team (www.ibpp.org)\r
+//\r
+// The contents of this file are subject to the IBPP License (the "License");\r
+// you may not use this file except in compliance with the License. You may\r
+// obtain a copy of the License at http://www.ibpp.org or in the 'license.txt'\r
+// file which must have been distributed along with this file.\r
+//\r
+// This software, distributed under the License, is distributed on an "AS IS"\r
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\r
+// License for the specific language governing rights and limitations\r
+// under the License.\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// COMMENTS\r
+// * DPB == Database Parameter Block/Buffer, see Interbase 6.0 C-API\r
+// * Tabulations should be set every four characters when editing this file.\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifdef _MSC_VER\r
+#pragma warning(disable: 4786 4996)\r
+#ifndef _DEBUG\r
+#pragma warning(disable: 4702)\r
+#endif\r
+#endif\r
+\r
+#include "_ibpp.h"\r
+\r
+#ifdef HAS_HDRSTOP\r
+#pragma hdrstop\r
+#endif\r
+\r
+#include <cstring>\r
+\r
+using namespace ibpp_internals;\r
+\r
+const int DPB::BUFFERINCR = 128;\r
+\r
+void DPB::Grow(int needed)\r
+{\r
+ if (mBuffer == 0) ++needed; // Initial alloc will require one more byte\r
+ if ((mSize + needed) > mAlloc)\r
+ {\r
+ // We need to grow the buffer. We use increments of BUFFERINCR bytes.\r
+ needed = (needed / BUFFERINCR + 1) * BUFFERINCR;\r
+ char* newbuffer = new char[mAlloc + needed];\r
+ if (mBuffer == 0)\r
+ {\r
+ // Initial allocation, initialize the version tag\r
+ newbuffer[0] = isc_dpb_version1;\r
+ mSize = 1;\r
+ }\r
+ else\r
+ {\r
+ // Move the old buffer content to the new one\r
+ memcpy(newbuffer, mBuffer, mSize);\r
+ delete [] mBuffer;\r
+ }\r
+ mBuffer = newbuffer;\r
+ mAlloc += needed;\r
+ }\r
+}\r
+\r
+void DPB::Insert(char type, const char* data)\r
+{\r
+ int len = (int)strlen(data);\r
+ Grow(len + 2);\r
+ mBuffer[mSize++] = type;\r
+ mBuffer[mSize++] = char(len);\r
+ strncpy(&mBuffer[mSize], data, len);\r
+ mSize += len;\r
+}\r
+\r
+void DPB::Insert(char type, int16_t data)\r
+{\r
+ Grow(2 + 2);\r
+ mBuffer[mSize++] = type;\r
+ mBuffer[mSize++] = char(2);\r
+ *(int16_t*)&mBuffer[mSize] = int16_t((*gds.Call()->m_vax_integer)((char*)&data, 2));\r
+ mSize += 2;\r
+}\r
+\r
+void DPB::Insert(char type, bool data)\r
+{\r
+ Grow(2 + 1);\r
+ mBuffer[mSize++] = type;\r
+ mBuffer[mSize++] = char(1);\r
+ mBuffer[mSize++] = char(data ? 1 : 0);\r
+}\r
+\r
+void DPB::Insert(char type, char data)\r
+{\r
+ Grow(2 + 1);\r
+ mBuffer[mSize++] = type;\r
+ mBuffer[mSize++] = char(1);\r
+ mBuffer[mSize++] = data;\r
+}\r
+\r
+void DPB::Reset()\r
+{\r
+ if (mAlloc != 0)\r
+ {\r
+ delete [] mBuffer;\r
+ mBuffer = 0;\r
+ mSize = 0;\r
+ mAlloc = 0;\r
+ }\r
+}\r
+\r
+//\r
+// EOF\r
+//\r