Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | introduced new aForceWideString optional parameter for ticket [2970335e40] |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
61d5bf3b2dabc71b398bd771c15f7e9c |
User & Date: | abouchez 2013-04-19 06:30:29 |
2013-04-20
| ||
11:16 | introduce new TRC4 object for RC4 encryption algorithm (this implementation should be faster than other Delphi versions around, especially at key initialization) check-in: 4962cf790c user: ab tags: trunk | |
2013-04-19
| ||
06:30 | introduced new aForceWideString optional parameter for ticket [2970335e40] check-in: 61d5bf3b2d user: abouchez tags: trunk | |
06:30 | added TSQLTable.GetSynUnicode() method check-in: c753608d75 user: abouchez tags: trunk | |
Changes to SQLite3/mORMotVCL.pas.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 .. 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 ... 133 134 135 136 137 138 139 140 141 142 143 144 145 146 ... 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 ... 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
Version 1.17 - first public release, corresponding to Synopse mORMot Framework 1.17 Version 1.18 - renamed SQLite3VCL.pas to mORMotVCL.pas - fixed ticket [9de8be5d9e] with some types like TEnumeration or TTimeLog } {$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER interface ................................................................................ {$endif} SynCommons, mORmot, DB, DBClient; /// convert a TSQLTable result into a VCL DataSet // - current implementation will return a TClientDataSet instance, created from // the supplied TSQLTable content (a more optimized version may appear later) // - for better speed with Delphi older than Delphi 2009 Update 3, it is // recommended to use http://andy.jgknet.de/blog/bugfix-units/midas-speed-fix-12 function TSQLTableToDataSet(aOwner: TComponent; aTable: TSQLTable; aClient: TSQLRest=nil): TDataSet; /// convert a JSON result into a VCL DataSet // - current implementation will return a TClientDataSet instance, created from // the supplied TSQLTable content (a more optimized version may appear later) // - for better speed with Delphi older than Delphi 2009 Update 3, it is // recommended to use http://andy.jgknet.de/blog/bugfix-units/midas-speed-fix-12 function JSONToDataSet(aOwner: TComponent; const aJSON: RawUTF8; aClient: TSQLRest=nil): TDataSet; implementation function JSONToDataSet(aOwner: TComponent; const aJSON: RawUTF8; aClient: TSQLRest): TDataSet; var T: TSQLTableJSON; begin T := TSQLTableJSON.Create([],'',aJSON); try result := TSQLTableToDataSet(aOwner,T,aClient); finally T.Free; end; end; var GlobalDataSetCount: integer; function TSQLTableToDataSet(aOwner: TComponent; aTable: TSQLTable; aClient: TSQLRest): TDataSet; var F,i: integer; aFieldName: string; Types: array of record SQLType: TSQLFieldType; EnumType: Pointer; end; begin ................................................................................ Add(aFieldName,ftString,64); sftRecord: Add(aFieldName,ftString,64); sftDateTime, sftTimeLog, sftModTime, sftCreateTime: Add(aFieldName,ftDateTime); sftBlob: Add(aFieldName,ftBlob,(aTable.FieldLengthMax(F,true)*3) shr 2); else Add(aFieldName,ftString,aTable.FieldLengthMax(F,true)); end; end; end; TClientDataSet(result).CreateDataSet; TClientDataSet(result).LogChanges := false; // speed up ................................................................................ for F := 0 to result.FieldCount-1 do if aTable.Get(i,F)=nil then result.Fields[F].Clear else case Types[F].SQLType of sftBoolean: result.Fields[F].AsBoolean := aTable.GetAsInteger(i,F)<>0; sftInteger: // handle Int64 values directly (result.Fields[F] as TLargeintField).AsLargeInt := GetInt64(aTable.Get(i,F)); sftFloat, sftCurrency: result.Fields[F].AsFloat := GetExtended(aTable.Get(i,F)); sftID: result.Fields[F].AsInteger := aTable.GetAsInteger(i,F); sftEnumerate, sftSet: if Types[F].EnumType=nil then result.Fields[F].AsInteger := aTable.GetAsInteger(i,F) else ................................................................................ sftBlob: {$ifdef UNICODE} result.Fields[F].AsBytes := aTable.GetBytes(i,F); {$else} result.Fields[F].AsString := aTable.GetBlob(i,F); {$endif} sftUTF8Text: result.Fields[F].AsString := aTable.GetS(i,F); else result.Fields[F].AsVariant := aTable.GetVariant(i,F,aClient); end; result.Post; end; result.First; except |
> > > | > > > | > | > | > | > > > > > > > | > > > > | |
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 .. 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 ... 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 ... 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 ... 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
Version 1.17 - first public release, corresponding to Synopse mORMot Framework 1.17 Version 1.18 - renamed SQLite3VCL.pas to mORMotVCL.pas - fixed ticket [9de8be5d9e] with some types like TEnumeration or TTimeLog - introduced new aForceWideString optional parameter for ticket [2970335e40] } {$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER interface ................................................................................ {$endif} SynCommons, mORmot, DB, DBClient; /// convert a TSQLTable result into a VCL DataSet // - current implementation will return a TClientDataSet instance, created from // the supplied TSQLTable content (a more optimized version may appear later) // - with non-Unicode version of Delphi, you can set aForceWideString to // force the use of WideString fields instead of AnsiString, if needed // - for better speed with Delphi older than Delphi 2009 Update 3, it is // recommended to use http://andy.jgknet.de/blog/bugfix-units/midas-speed-fix-12 function TSQLTableToDataSet(aOwner: TComponent; aTable: TSQLTable; aClient: TSQLRest=nil {$ifndef UNICODE}; aForceWideString: boolean=false{$endif}): TDataSet; /// convert a JSON result into a VCL DataSet // - current implementation will return a TClientDataSet instance, created from // the supplied TSQLTable content (a more optimized version may appear later) // - with non-Unicode version of Delphi, you can set aForceWideString to // force the use of WideString fields instead of AnsiString, if needed // - for better speed with Delphi older than Delphi 2009 Update 3, it is // recommended to use http://andy.jgknet.de/blog/bugfix-units/midas-speed-fix-12 function JSONToDataSet(aOwner: TComponent; const aJSON: RawUTF8; aClient: TSQLRest=nil {$ifndef UNICODE}; aForceWideString: boolean=false{$endif}): TDataSet; implementation function JSONToDataSet(aOwner: TComponent; const aJSON: RawUTF8; aClient: TSQLRest {$ifndef UNICODE}; aForceWideString: boolean{$endif}): TDataSet; var T: TSQLTableJSON; begin T := TSQLTableJSON.Create([],'',aJSON); try result := TSQLTableToDataSet(aOwner,T,aClient {$ifndef UNICODE},aForceWideString{$endif}); finally T.Free; end; end; var GlobalDataSetCount: integer; function TSQLTableToDataSet(aOwner: TComponent; aTable: TSQLTable; aClient: TSQLRest {$ifndef UNICODE}; aForceWideString: boolean{$endif}): TDataSet; var F,i: integer; aFieldName: string; Types: array of record SQLType: TSQLFieldType; EnumType: Pointer; end; begin ................................................................................ Add(aFieldName,ftString,64); sftRecord: Add(aFieldName,ftString,64); sftDateTime, sftTimeLog, sftModTime, sftCreateTime: Add(aFieldName,ftDateTime); sftBlob: Add(aFieldName,ftBlob,(aTable.FieldLengthMax(F,true)*3) shr 2); sftUTF8Text: {$ifndef UNICODE} if aForceWideString then Add(aFieldName,ftWideString,aTable.FieldLengthMax(F,true)) else {$endif} Add(aFieldName,ftString,aTable.FieldLengthMax(F,true)); else Add(aFieldName,ftString,aTable.FieldLengthMax(F,true)); end; end; end; TClientDataSet(result).CreateDataSet; TClientDataSet(result).LogChanges := false; // speed up ................................................................................ for F := 0 to result.FieldCount-1 do if aTable.Get(i,F)=nil then result.Fields[F].Clear else case Types[F].SQLType of sftBoolean: result.Fields[F].AsBoolean := aTable.GetAsInteger(i,F)<>0; sftInteger: // handle Int64 values directly (result.Fields[F] as TLargeintField).Value := GetInt64(aTable.Get(i,F)); sftFloat, sftCurrency: result.Fields[F].AsFloat := GetExtended(aTable.Get(i,F)); sftID: result.Fields[F].AsInteger := aTable.GetAsInteger(i,F); sftEnumerate, sftSet: if Types[F].EnumType=nil then result.Fields[F].AsInteger := aTable.GetAsInteger(i,F) else ................................................................................ sftBlob: {$ifdef UNICODE} result.Fields[F].AsBytes := aTable.GetBytes(i,F); {$else} result.Fields[F].AsString := aTable.GetBlob(i,F); {$endif} sftUTF8Text: {$ifndef UNICODE} if aForceWideString then (result.Fields[F] as TWideStringField).Value := aTable.GetSynUnicode(i,F) else {$endif} result.Fields[F].AsString := aTable.GetS(i,F); else result.Fields[F].AsVariant := aTable.GetVariant(i,F,aClient); end; result.Post; end; result.First; except |