Changeset 20 for trunk/DbEngines/UEngineXML.pas
- Timestamp:
- Mar 23, 2018, 1:59:25 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DbEngines/UEngineXML.pas
r17 r20 12 12 { TDatabaseXML } 13 13 14 TDatabaseXML = class(TD atabaseClient)14 TDatabaseXML = class(TDbClient) 15 15 private 16 function GetFileName: string; 16 FFileName: string; 17 Tables: TTables; 17 18 procedure LoadNodeRecord(Row: TRecord; Node: TDOMNode); 18 19 procedure SaveNodeRecord(Row: TRecord; Node: TDOMNode); … … 30 31 procedure SaveToFile(FileName: string); 31 32 function GetNextPart(var Text: string): string; 33 protected 32 34 public 33 35 procedure Query(DbRows: TDbRows; Text: string); override; 36 procedure LoadTables(Tables: TTables); override; 34 37 procedure Load; override; 35 38 procedure Save; override; 36 property FileName: string read GetFileName; 39 constructor Create; override; 40 destructor Destroy; override; 41 property FileName: string read FFileName write FFileName; 42 end; 43 44 { TDbConnectParamsXml } 45 46 TDbConnectParamsXml = class(TDbConnectParams) 47 protected 48 function GetConnectionString: string; override; 49 procedure SetConnectionString(AValue: string); override; 50 public 51 FileName: string; 37 52 end; 38 53 … … 46 61 SWrongFileFormat = 'Wrong file format'; 47 62 48 { TDatabaseXML } 49 50 function TDatabaseXML.GetFileName: string; 63 { TDbConnectParamsXml } 64 65 function TDbConnectParamsXml.GetConnectionString: string; 66 begin 67 Result := 'file:///' + FileName; 68 end; 69 70 procedure TDbConnectParamsXml.SetConnectionString(AValue: string); 51 71 var 52 72 URL: TURL; … … 54 74 URL := TURL.Create; 55 75 try 56 URL.AsString := Database.ConnectionString;57 if URL.Scheme <> 'file'then76 URL.AsString := AValue; 77 if (URL.Scheme <> 'file') and (AValue <> '') then 58 78 raise Exception.Create('Wrong connection string. Required file scheme.'); 59 60 Result := URL.Path 79 FileName := Copy(URL.Path, 2, Length(URL.Path)); 61 80 finally 62 81 URL.Free; 63 82 end; 64 83 end; 84 85 { TDatabaseXML } 65 86 66 87 procedure TDatabaseXML.LoadNodeRecord(Row: TRecord; Node: TDOMNode); … … 137 158 begin 138 159 Field.Name := ReadString(Node, 'Name', ''); 139 Field.DataType := Field.Table.D atabase.Engine.DataTypes.FindByType(TFieldType(ReadInteger(Node, 'Type', 0)));160 Field.DataType := Field.Table.DbClient.ClientType.DataTypes.FindByType(TFieldType(ReadInteger(Node, 'Type', 0))); 140 161 Field.TextBefore := ReadString(Node, 'TextBefore', ''); 141 162 Field.TextAfter := ReadString(Node, 'TextAfter', ''); … … 219 240 while Assigned(Node2) and (Node2.NodeName = 'Table') do begin 220 241 NewTable := TTable.Create; 221 NewTable.D atabase := Tables.Database;242 NewTable.DbClient := Tables.DbClient; 222 243 LoadNodeTable(NewTable, Node2); 223 244 Tables.Add(NewTable); … … 252 273 NewNode := FindNode('Tables'); 253 274 if Assigned(NewNode) then 254 LoadNodeTables( Database.Tables, NewNode);275 LoadNodeTables(Tables, NewNode); 255 276 end; 256 277 finally … … 273 294 NewNode := OwnerDocument.CreateElement('Tables'); 274 295 AppendChild(NewNode); 275 SaveNodeTables( Database.Tables, NewNode);296 SaveNodeTables(Tables, NewNode); 276 297 end; 277 298 ForceDirectories(ExtractFileDir(FileName)); … … 310 331 TableName := GetNextPart(Text); 311 332 end else raise Exception.Create('No table specified with FROM'); 312 Table := Database.Tables.SearchByName(TableName);333 Table := Tables.SearchByName(TableName); 313 334 if Assigned(Table) then begin 314 335 DbRows.Count := 0; … … 330 351 end; 331 352 353 procedure TDatabaseXML.LoadTables(Tables: TTables); 354 begin 355 inherited; 356 357 end; 358 332 359 procedure TDatabaseXML.Load; 333 360 begin … … 341 368 end; 342 369 370 constructor TDatabaseXML.Create; 371 begin 372 Tables := TTables.Create; 373 inherited Create; 374 end; 375 376 destructor TDatabaseXML.Destroy; 377 begin 378 Tables.Free; 379 inherited Destroy; 380 end; 381 343 382 344 383 end.
Note:
See TracChangeset
for help on using the changeset viewer.