LibreOffice Module connectivity (master) 1
OBoundParam.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#pragma once
20
21#include <com/sun/star/io/XInputStream.hpp>
22#include <com/sun/star/sdbc/DataType.hpp>
24#include <connectivity/odbc.hxx>
25
26namespace connectivity::odbc
27 {
29 {
30
31 public:
33 : binaryData(nullptr)
34 , paramLength(0)
35 , paramInputStreamLen(0)
36 {
37 }
39 {
40 free(binaryData);
41 }
42
43 // allocBindDataBuffer
44 // Allocates and returns a new bind data buffer of the specified
45 // length
46
47 void* allocBindDataBuffer (sal_Int32 bufLen)
48 {
49 // Reset the input stream and sequence, we are doing a new bind
50 setInputStream (nullptr, 0);
51 aSequence.realloc(0);
52
53 free(binaryData);
54 binaryData = (bufLen > 0) ? malloc(bufLen) : nullptr;
55
56 return binaryData;
57 }
58
59
60 // getBindLengthBuffer
61 // Returns the length buffer to be used when binding to a parameter
62
64 {
65 return paramLength;
66 }
67
68
69 // setInputStream
70 // Sets the input stream for the bound parameter
71
72 void setInputStream(const css::uno::Reference< css::io::XInputStream>& inputStream,
73 sal_Int32 len)
74 {
75 paramInputStream = inputStream;
76 paramInputStreamLen = len;
77 }
78
79 void setSequence(const css::uno::Sequence< sal_Int8 >& _aSequence)
80 {
81 aSequence = _aSequence;
82 }
83
84
85 // getInputStream
86 // Gets the input stream for the bound parameter
87
88 const css::uno::Reference< css::io::XInputStream>& getInputStream () const
89 {
90 return paramInputStream;
91 }
92
93
94 // getInputStreamLen
95 // Gets the input stream length for the bound parameter
96
97 sal_Int32 getInputStreamLen () const
98 {
99 return paramInputStreamLen;
100 }
101
102
103 private:
104
105 // Data attributes
106
107
108 void *binaryData; // Storage area to be used
109 // when binding the parameter
110
111 SQLLEN paramLength; // Storage area to be used
112 // for the bound length of the
113 // parameter. Note that this
114 // data is in native format.
115
116 css::uno::Reference< css::io::XInputStream> paramInputStream;
117 css::uno::Sequence< sal_Int8 > aSequence;
118 // When an input stream is
119 // bound to a parameter, a
120 // reference to the input stream is saved
121 // until not needed anymore.
122
123 sal_Int32 paramInputStreamLen; // Length of input stream
124 };
125
126}
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const css::uno::Reference< css::io::XInputStream > & getInputStream() const
Definition: OBoundParam.hxx:88
css::uno::Reference< css::io::XInputStream > paramInputStream
void * allocBindDataBuffer(sal_Int32 bufLen)
Definition: OBoundParam.hxx:47
void setSequence(const css::uno::Sequence< sal_Int8 > &_aSequence)
Definition: OBoundParam.hxx:79
sal_Int32 getInputStreamLen() const
Definition: OBoundParam.hxx:97
css::uno::Sequence< sal_Int8 > aSequence
void setInputStream(const css::uno::Reference< css::io::XInputStream > &inputStream, sal_Int32 len)
Definition: OBoundParam.hxx:72
#define OOO_DLLPUBLIC_ODBCBASE