X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/8c6fa3fbaccc22127280bf77a48fab5a3ee0716e..46b0747592074017ff0ea4b33d4a7194235886e5:/libs/ibpp/_ibs.cpp diff --git a/libs/ibpp/_ibs.cpp b/libs/ibpp/_ibs.cpp new file mode 100644 index 00000000..25e66bc9 --- /dev/null +++ b/libs/ibpp/_ibs.cpp @@ -0,0 +1,109 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// File : $Id: _ibs.cpp,v 1.2 2009/03/19 20:00:27 faust Exp $ +// Subject : IBPP, internal Status class implementation +// +/////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright 2000-2006 T.I.P. Group S.A. and the IBPP Team (www.ibpp.org) +// +// The contents of this file are subject to the IBPP License (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at http://www.ibpp.org or in the 'license.txt' +// file which must have been distributed along with this file. +// +// This software, distributed under the License, is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +/////////////////////////////////////////////////////////////////////////////// +// +// COMMENTS +// * Tabulations should be set every four characters when editing this file. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifdef _MSC_VER +#pragma warning(disable: 4786 4996) +#ifndef _DEBUG +#pragma warning(disable: 4702) +#endif +#endif + +#include "_ibpp.h" + +#ifdef HAS_HDRSTOP +#pragma hdrstop +#endif + +#include + +using namespace ibpp_internals; + +int IBS::SqlCode() const +{ + return (int)(*gds.Call()->m_sqlcode)(&mVector[0]); +} + +const char* IBS::ErrorMessage() const +{ + char msg[1024]; + ISC_LONG sqlcode; + + if (! mMessage.empty()) return mMessage.c_str(); // If message compiled, returns it + + // Compiles the message (SQL part) + std::ostringstream message; + sqlcode = (*gds.Call()->m_sqlcode)(mVector); + if (sqlcode != -999) + { + (*gds.Call()->m_sql_interprete)((short)sqlcode, msg, sizeof(msg)); + message<< _("SQL Message : ")<< sqlcode<< "\n"<< msg<< "\n\n"; + } + + message<< _("Engine Code : ")<< EngineCode()<< "\n"; + + // Compiles the message (Engine part) + ISC_STATUS* error = &mVector[0]; + try { (*gds.Call()->m_interprete)(msg, &error); } + catch(...) { msg[0] = '\0'; } + message<< _("Engine Message :")<< "\n"<< msg; + try + { + while ((*gds.Call()->m_interprete)(msg, &error)) + message<< "\n"<< msg; + } + catch (...) { } + + message<< "\n"; + mMessage = message.str(); + return mMessage.c_str(); +} + +void IBS::Reset() +{ + for (int i = 0; i < 20; i++) mVector[i] = 0; + mMessage.erase(); +} + +IBS::IBS() +{ + Reset(); +} + +IBS::~IBS() +{ +} + +/** Copy Constructor +*/ + +IBS::IBS(IBS& copied) +{ + memcpy(mVector, copied.mVector, sizeof(mVector)); +} + +// +// EOF +//