1 {*********************************************************}
3 { Zeos Database Objects }
4 { Blob streams classes }
6 { Originally written by Sergey Seroukhov }
8 {*********************************************************}
10 {@********************************************************}
11 { Copyright (c) 1999-2012 Zeos Development Group }
13 { License Agreement: }
15 { This library is distributed in the hope that it will be }
16 { useful, but WITHOUT ANY WARRANTY; without even the }
17 { implied warranty of MERCHANTABILITY or FITNESS FOR }
18 { A PARTICULAR PURPOSE. See the GNU Lesser General }
19 { Public License for more details. }
21 { The source code of the ZEOS Libraries and packages are }
22 { distributed under the Library GNU General Public }
23 { License (see the file COPYING / COPYING.ZEOS) }
24 { with the following modification: }
25 { As a special exception, the copyright holders of this }
26 { library give you permission to link this library with }
27 { independent modules to produce an executable, }
28 { regardless of the license terms of these independent }
29 { modules, and to copy and distribute the resulting }
30 { executable under terms of your choice, provided that }
31 { you also meet, for each linked independent module, }
32 { the terms and conditions of the license of that module. }
33 { An independent module is a module which is not derived }
34 { from or based on this library. If you modify this }
35 { library, you may extend this exception to your version }
36 { of the library, but you are not obligated to do so. }
37 { If you do not wish to do so, delete this exception }
38 { statement from your version. }
41 { The project web site is located on: }
42 { http://zeos.firmos.at (FORUM) }
43 { http://sourceforge.net/p/zeoslib/tickets/ (BUGTRACKER)}
44 { svn://svn.code.sf.net/p/zeoslib/code-0/trunk (SVN) }
46 { http://www.sourceforge.net/projects/zeoslib. }
49 { Zeos Development Group. }
50 {********************************************************@}
58 uses Classes, SysUtils, {$IFDEF MSEgui}mclasses, mdb{$ELSE}DB{$ENDIF},
59 {$IFDEF WITH_WIDESTRUTILS}WideStrUtils, {$ENDIF}
60 ZDbcIntfs, ZCompatibility;
63 {** Implements a class for blobs stream. }
64 TZBlobStream = class(TMemoryStream)
68 FMode: TBlobStreamMode;
69 FConSettings: PZConSettings;
71 property Blob: IZBlob read FBlob write FBlob;
72 property Mode: TBlobStreamMode read FMode write FMode;
74 constructor Create(Field: TBlobField; Blob: IZBlob; Mode: TBlobStreamMode;
75 ConSettings: PZConSettings);
76 destructor Destroy; override;
86 Constructs this object and assignes the main properties.
89 constructor TZBlobStream.Create(Field: TBlobField; Blob: IZBlob;
90 Mode: TBlobStreamMode; ConSettings: PZConSettings);
99 FConSettings := ConSettings;
100 if (Mode in [bmRead, bmReadWrite]) and not Blob.IsEmpty then
102 TempStream := Blob.GetStream;
104 TempStream.Position := 0;
105 CopyFrom(TempStream, TempStream.Size);
113 type THackedDataset = class(TDataset);
116 Destroys this object and cleanups the memory.
118 destructor TZBlobStream.Destroy;
119 {$IFDEF WITH_WIDEMEMO}
124 if Mode in [bmWrite, bmReadWrite] then
126 if Assigned(Self.Memory) then
128 {$IFDEF WITH_WIDEMEMO}
129 if FField.DataType = ftWideMemo then
131 TempStream := GetValidatedUnicodeStream(Memory, Cardinal(Size),
132 FConSettings, False);
133 Blob.SetStream(TempStream, True);
143 if Assigned(FField.Dataset) then
144 THackedDataset(FField.DataSet).DataEvent(deFieldChange, ULong(FField));
146 ApplicationHandleException(Self);