Branch data Line data Source code
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 : : #ifndef _CONNECTIVITY_OBOUNPARAM_HXX_
20 : : #define _CONNECTIVITY_OBOUNPARAM_HXX_
21 : :
22 : : #include <com/sun/star/io/XInputStream.hpp>
23 : : #include "odbc/odbcbasedllapi.hxx"
24 : :
25 : : namespace connectivity
26 : : {
27 : : namespace odbc
28 : : {
29 : : class OOO_DLLPUBLIC_ODBCBASE OBoundParam
30 : : {
31 : :
32 : : public:
33 : 0 : OBoundParam()
34 : 0 : {
35 : 0 : paramLength = NULL;
36 : 0 : binaryData = NULL;
37 : 0 : pA1=0;
38 : 0 : pA2=0;
39 : 0 : pB1=0;
40 : 0 : pB2=0;
41 : 0 : pC1=0;
42 : 0 : pC2=0;
43 : 0 : pS1=0;
44 : 0 : pS2=0;
45 : 0 : }
46 : 0 : ~OBoundParam()
47 : 0 : {
48 : 0 : delete [] binaryData;
49 : 0 : delete [] paramLength;
50 : 0 : }
51 : : //--------------------------------------------------------------------
52 : : // initialize
53 : : // Perform an necessary initialization
54 : : //--------------------------------------------------------------------
55 : 0 : void initialize ()
56 : : {
57 : : // Allocate storage for the length. Note - the length is
58 : : // stored in native format, and will have to be converted
59 : : // to a Java sal_Int32. The jdbcodbc 'C' bridge provides an
60 : : // interface to do this.
61 : :
62 : 0 : paramLength = new sal_Int8[sizeof(SQLLEN)];
63 : 0 : }
64 : :
65 : : //--------------------------------------------------------------------
66 : : // allocBindDataBuffer
67 : : // Allocates and returns a new bind data buffer of the specified
68 : : // length
69 : : //--------------------------------------------------------------------
70 : 0 : sal_Int8* allocBindDataBuffer (sal_Int32 bufLen)
71 : : {
72 : 0 : if ( binaryData )
73 : 0 : delete [] binaryData;
74 : 0 : binaryData = new sal_Int8[bufLen];
75 : :
76 : : // Reset the input stream, we are doing a new bind
77 : 0 : setInputStream (NULL, 0);
78 : :
79 : 0 : return binaryData;
80 : : }
81 : :
82 : : //--------------------------------------------------------------------
83 : : // getBindDataBuffer
84 : : // Returns the data buffer to be used when binding to a parameter
85 : : //--------------------------------------------------------------------
86 : : sal_Int8* getBindDataBuffer ()
87 : : {
88 : : return binaryData;
89 : : }
90 : :
91 : : //--------------------------------------------------------------------
92 : : // getBindLengthBuffer
93 : : // Returns the length buffer to be used when binding to a parameter
94 : : //--------------------------------------------------------------------
95 : 0 : sal_Int8* getBindLengthBuffer ()
96 : : {
97 : 0 : return paramLength;
98 : : }
99 : :
100 : : //--------------------------------------------------------------------
101 : : // setInputStream
102 : : // Sets the input stream for the bound parameter
103 : : //--------------------------------------------------------------------
104 : 0 : void setInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& inputStream,
105 : : sal_Int32 len)
106 : : {
107 : 0 : paramInputStream = inputStream;
108 : 0 : paramInputStreamLen = len;
109 : 0 : }
110 : :
111 : 0 : void setSequence(const ::com::sun::star::uno::Sequence< sal_Int8 >& _aSequence)
112 : : {
113 : 0 : aSequence = _aSequence;
114 : 0 : }
115 : :
116 : : //--------------------------------------------------------------------
117 : : // getInputStream
118 : : // Gets the input stream for the bound parameter
119 : : //--------------------------------------------------------------------
120 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream ()
121 : : {
122 : 0 : return paramInputStream;
123 : : }
124 : :
125 : : //--------------------------------------------------------------------
126 : : // getInputStreamLen
127 : : // Gets the input stream length for the bound parameter
128 : : //--------------------------------------------------------------------
129 : 0 : sal_Int32 getInputStreamLen ()
130 : : {
131 : 0 : return paramInputStreamLen;
132 : : }
133 : :
134 : : //--------------------------------------------------------------------
135 : : // setSqlType
136 : : // Sets the Java sql type used to register an OUT parameter
137 : : //--------------------------------------------------------------------
138 : :
139 : : void setSqlType(sal_Int32 type)
140 : : {
141 : : sqlType = type;
142 : : }
143 : :
144 : : //--------------------------------------------------------------------
145 : : // getSqlType
146 : : // Gets the Java sql type used to register an OUT parameter
147 : : //--------------------------------------------------------------------
148 : :
149 : : sal_Int32 getSqlType ()
150 : : {
151 : : return sqlType;
152 : : }
153 : :
154 : : //--------------------------------------------------------------------
155 : : // setOutputParameter
156 : : // Sets the flag indicating if this is an OUTPUT parameter
157 : : //--------------------------------------------------------------------
158 : :
159 : : void setOutputParameter (sal_Bool output)
160 : : {
161 : : outputParameter = output;
162 : : }
163 : :
164 : : //--------------------------------------------------------------------
165 : : // isOutputParameter
166 : : // Gets the OUTPUT parameter flag
167 : : //--------------------------------------------------------------------
168 : :
169 : : sal_Bool isOutputParameter ()
170 : : {
171 : : return outputParameter;
172 : : }
173 : :
174 : : protected:
175 : : //====================================================================
176 : : // Data attributes
177 : : //====================================================================
178 : :
179 : : sal_Int8* binaryData; // Storage area to be used
180 : : // when binding the parameter
181 : :
182 : : sal_Int8* paramLength; // Storage area to be used
183 : : // for the bound length of the
184 : : // parameter. Note that this
185 : : // data is in native format.
186 : :
187 : : ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream;
188 : : ::com::sun::star::uno::Sequence< sal_Int8 > aSequence;
189 : : // When an input stream is
190 : : // bound to a parameter, the
191 : : // input stream is saved
192 : : // until needed.
193 : :
194 : : sal_Int32 paramInputStreamLen; // Length of input stream
195 : :
196 : : sal_Int32 sqlType; // Java SQL type used to
197 : : // register an OUT parameter
198 : :
199 : : sal_Bool outputParameter; // true for OUTPUT parameters
200 : :
201 : :
202 : : sal_Int32 pA1; //pointers
203 : : sal_Int32 pA2;
204 : : sal_Int32 pB1;
205 : : sal_Int32 pB2;
206 : : sal_Int32 pC1;
207 : : sal_Int32 pC2;
208 : : sal_Int32 pS1;
209 : : sal_Int32 pS2;// reserved for strings(UTFChars)
210 : : };
211 : : }
212 : : }
213 : : #endif // _CONNECTIVITY_OBOUNPARAM_HXX_
214 : :
215 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|