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 :
10 : #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_BLOB_HXX
11 : #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_BLOB_HXX
12 :
13 : #include <ibase.h>
14 :
15 : #include <cppuhelper/compbase2.hxx>
16 :
17 : #include <com/sun/star/io/XInputStream.hpp>
18 : #include <com/sun/star/sdbc/XBlob.hpp>
19 :
20 : namespace connectivity
21 : {
22 : namespace firebird
23 : {
24 : typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XBlob,
25 : ::com::sun::star::io::XInputStream >
26 : Blob_BASE;
27 :
28 0 : class Blob :
29 : public Blob_BASE
30 : {
31 : protected:
32 : ::osl::Mutex m_aMutex;
33 :
34 : isc_db_handle* m_pDatabaseHandle;
35 : isc_tr_handle* m_pTransactionHandle;
36 : // We store our own copy of the blob id as typically the statement
37 : // manages it's own blob id, and blobs are independent of a statement
38 : // in firebird.
39 : ISC_QUAD m_blobID;
40 : isc_blob_handle m_blobHandle;
41 :
42 : bool m_bBlobOpened;
43 : sal_Int64 m_nBlobLength;
44 : sal_Int64 m_nBlobPosition;
45 :
46 : ISC_STATUS_ARRAY m_statusVector;
47 :
48 : void ensureBlobIsOpened()
49 : throw(::com::sun::star::sdbc::SQLException);
50 : /**
51 : * Closes the blob and cleans up resources -- can be used to reset
52 : * the blob if we e.g. want to read from the beginning again.
53 : */
54 : void closeBlob()
55 : throw(::com::sun::star::sdbc::SQLException);
56 :
57 : public:
58 : Blob(isc_db_handle* pDatabaseHandle,
59 : isc_tr_handle* pTransactionHandle,
60 : ISC_QUAD& aBlobID);
61 :
62 : // ---- XBlob ----------------------------------------------------
63 : virtual sal_Int64 SAL_CALL
64 : length()
65 : throw(::com::sun::star::sdbc::SQLException,
66 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
67 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
68 : getBytes(sal_Int64 aPosition, sal_Int32 aLength)
69 : throw(::com::sun::star::sdbc::SQLException,
70 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL
72 : getBinaryStream()
73 : throw(::com::sun::star::sdbc::SQLException,
74 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
75 : virtual sal_Int64 SAL_CALL
76 : position(const ::com::sun::star::uno::Sequence< sal_Int8 >& rPattern,
77 : sal_Int64 aStart)
78 : throw(::com::sun::star::sdbc::SQLException,
79 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 : virtual sal_Int64 SAL_CALL
81 : positionOfBlob(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& rPattern,
82 : sal_Int64 aStart)
83 : throw(::com::sun::star::sdbc::SQLException,
84 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 :
86 : // ---- XInputStream ----------------------------------------------
87 : virtual sal_Int32 SAL_CALL
88 : readBytes(::com::sun::star::uno::Sequence< sal_Int8 >& rDataOut,
89 : sal_Int32 nBytes)
90 : throw(::com::sun::star::io::NotConnectedException,
91 : ::com::sun::star::io::BufferSizeExceededException,
92 : ::com::sun::star::io::IOException,
93 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 : virtual sal_Int32 SAL_CALL
95 : readSomeBytes(::com::sun::star::uno::Sequence< sal_Int8 >& rDataOut,
96 : sal_Int32 nMaximumBytes)
97 : throw(::com::sun::star::io::NotConnectedException,
98 : ::com::sun::star::io::BufferSizeExceededException,
99 : ::com::sun::star::io::IOException,
100 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 : virtual void SAL_CALL
102 : skipBytes(sal_Int32 nBytes)
103 : throw(::com::sun::star::io::NotConnectedException,
104 : ::com::sun::star::io::BufferSizeExceededException,
105 : ::com::sun::star::io::IOException,
106 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 : virtual sal_Int32 SAL_CALL
108 : available()
109 : throw(::com::sun::star::io::NotConnectedException,
110 : ::com::sun::star::io::IOException,
111 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : virtual void SAL_CALL
113 : closeInput()
114 : throw(::com::sun::star::io::NotConnectedException,
115 : ::com::sun::star::io::IOException,
116 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 :
118 : // ---- OComponentHelper ------------------------------------------
119 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
120 : };
121 : }
122 :
123 : }
124 :
125 : #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_BLOB_HXX
126 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|