2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-12 22:04:38 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2014-04-18 18:41:08 +02:00
|
|
|
#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OBOUNDPARAM_HXX
|
|
|
|
#define INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OBOUNDPARAM_HXX
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
2012-10-26 18:57:34 +02:00
|
|
|
#include <com/sun/star/sdbc/DataType.hpp>
|
2008-12-30 13:32:01 +00:00
|
|
|
#include "odbc/odbcbasedllapi.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
namespace connectivity
|
|
|
|
{
|
|
|
|
namespace odbc
|
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
class OOO_DLLPUBLIC_ODBCBASE OBoundParam
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
OBoundParam()
|
2012-10-26 18:57:34 +02:00
|
|
|
: binaryData(NULL)
|
2014-02-01 14:15:01 -06:00
|
|
|
, paramLength(0)
|
2012-10-26 18:57:34 +02:00
|
|
|
, paramInputStreamLen(0)
|
|
|
|
, sqlType(::com::sun::star::sdbc::DataType::SQLNULL)
|
|
|
|
, outputParameter(false)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
}
|
2001-07-05 10:05:34 +00:00
|
|
|
~OBoundParam()
|
|
|
|
{
|
2012-10-26 18:57:34 +02:00
|
|
|
free(binaryData);
|
2001-07-05 10:05:34 +00:00
|
|
|
}
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// allocBindDataBuffer
|
|
|
|
// Allocates and returns a new bind data buffer of the specified
|
|
|
|
// length
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2012-10-26 18:57:34 +02:00
|
|
|
void* allocBindDataBuffer (sal_Int32 bufLen)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2012-10-26 18:57:34 +02:00
|
|
|
// Reset the input stream and sequence, we are doing a new bind
|
2000-09-18 15:18:56 +00:00
|
|
|
setInputStream (NULL, 0);
|
2012-10-26 18:57:34 +02:00
|
|
|
aSequence.realloc(0);
|
|
|
|
|
|
|
|
free(binaryData);
|
|
|
|
binaryData = (bufLen > 0) ? malloc(bufLen) : NULL;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
return binaryData;
|
|
|
|
}
|
|
|
|
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// getBindDataBuffer
|
|
|
|
// Returns the data buffer to be used when binding to a parameter
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2012-10-26 18:57:34 +02:00
|
|
|
void* getBindDataBuffer ()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
return binaryData;
|
|
|
|
}
|
|
|
|
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// getBindLengthBuffer
|
|
|
|
// Returns the length buffer to be used when binding to a parameter
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
SQLLEN& getBindLengthBuffer ()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
return paramLength;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// setInputStream
|
|
|
|
// Sets the input stream for the bound parameter
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
void setInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& inputStream,
|
|
|
|
sal_Int32 len)
|
|
|
|
{
|
|
|
|
paramInputStream = inputStream;
|
|
|
|
paramInputStreamLen = len;
|
|
|
|
}
|
|
|
|
|
2009-10-29 12:00:17 +01:00
|
|
|
void setSequence(const ::com::sun::star::uno::Sequence< sal_Int8 >& _aSequence)
|
|
|
|
{
|
|
|
|
aSequence = _aSequence;
|
|
|
|
}
|
|
|
|
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// getInputStream
|
|
|
|
// Gets the input stream for the bound parameter
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream ()
|
|
|
|
{
|
|
|
|
return paramInputStream;
|
|
|
|
}
|
|
|
|
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// getInputStreamLen
|
|
|
|
// Gets the input stream length for the bound parameter
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
sal_Int32 getInputStreamLen ()
|
|
|
|
{
|
|
|
|
return paramInputStreamLen;
|
|
|
|
}
|
|
|
|
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// setSqlType
|
|
|
|
// Sets the Java sql type used to register an OUT parameter
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
void setSqlType(sal_Int32 type)
|
|
|
|
{
|
|
|
|
sqlType = type;
|
|
|
|
}
|
|
|
|
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// getSqlType
|
|
|
|
// Gets the Java sql type used to register an OUT parameter
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
sal_Int32 getSqlType ()
|
|
|
|
{
|
|
|
|
return sqlType;
|
|
|
|
}
|
|
|
|
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// setOutputParameter
|
|
|
|
// Sets the flag indicating if this is an OUTPUT parameter
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2014-04-16 09:14:24 +02:00
|
|
|
void setOutputParameter (bool output)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
outputParameter = output;
|
|
|
|
}
|
|
|
|
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// isOutputParameter
|
|
|
|
// Gets the OUTPUT parameter flag
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2014-04-16 09:14:24 +02:00
|
|
|
bool isOutputParameter ()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
return outputParameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// Data attributes
|
2014-02-25 17:59:09 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2012-10-26 18:57:34 +02:00
|
|
|
void *binaryData; // Storage area to be used
|
|
|
|
// when binding the parameter
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2012-10-26 18:57:34 +02:00
|
|
|
SQLLEN paramLength; // Storage area to be used
|
|
|
|
// for the bound length of the
|
|
|
|
// parameter. Note that this
|
|
|
|
// data is in native format.
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream;
|
2009-10-29 12:00:17 +01:00
|
|
|
::com::sun::star::uno::Sequence< sal_Int8 > aSequence;
|
2000-09-18 15:18:56 +00:00
|
|
|
// When an input stream is
|
2012-10-26 18:57:34 +02:00
|
|
|
// bound to a parameter, a
|
|
|
|
// reference to the input stream is saved
|
|
|
|
// until not needed anymore.
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
sal_Int32 paramInputStreamLen; // Length of input stream
|
|
|
|
|
|
|
|
sal_Int32 sqlType; // Java SQL type used to
|
|
|
|
// register an OUT parameter
|
|
|
|
|
2014-04-16 09:14:24 +02:00
|
|
|
bool outputParameter; // true for OUTPUT parameters
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2014-04-18 18:41:08 +02:00
|
|
|
#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OBOUNDPARAM_HXX
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2010-10-27 13:11:31 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|