Changeset 21 for trunk/DbEngines/UEngineXML.pas
- Timestamp:
- Mar 23, 2018, 3:06:47 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DbEngines/UEngineXML.pas
r20 r21 30 30 procedure LoadFromFile(FileName: string); 31 31 procedure SaveToFile(FileName: string); 32 function GetNextPart(var Text: string ): string;32 function GetNextPart(var Text: string; Separator: string = ' '): string; 33 33 protected 34 34 public 35 procedure Query( DbRows: TDbRows; Text: string); override;35 procedure Query(Text: string; DbRows: TDbRows = nil); override; 36 36 procedure LoadTables(Tables: TTables); override; 37 37 procedure Load; override; … … 158 158 begin 159 159 Field.Name := ReadString(Node, 'Name', ''); 160 Field.DataType := Field.Table.DbClient.ClientType.DataTypes. FindByType(TFieldType(ReadInteger(Node, 'Type', 0)));160 Field.DataType := Field.Table.DbClient.ClientType.DataTypes.SearchByType(TFieldType(ReadInteger(Node, 'Type', 0))); 161 161 Field.TextBefore := ReadString(Node, 'TextBefore', ''); 162 162 Field.TextAfter := ReadString(Node, 'TextAfter', ''); … … 296 296 SaveNodeTables(Tables, NewNode); 297 297 end; 298 ForceDirectories(ExtractFileDir(FileName)); 298 if Pos(DirectorySeparator, FileName) > 0 then 299 ForceDirectories(ExtractFileDir(FileName)); 299 300 WriteXMLFile(Doc, FileName); 300 301 finally … … 303 304 end; 304 305 305 function TDatabaseXML.GetNextPart(var Text: string ): string;306 begin 307 if Pos( ' ', Text) > 0 then begin308 Result := Trim(Copy(Text, 1, Pos( ' ', Text) - 1));309 Delete(Text, 1, Pos( ' ', Text));306 function TDatabaseXML.GetNextPart(var Text: string; Separator: string = ' '): string; 307 begin 308 if Pos(Separator, Text) > 0 then begin 309 Result := Trim(Copy(Text, 1, Pos(Separator, Text) - Length(Separator))); 310 Delete(Text, 1, Pos(Separator, Text)); 310 311 end else begin 311 312 Result := Text; … … 314 315 end; 315 316 316 procedure TDatabaseXML.Query( DbRows: TDbRows; Text: string);317 procedure TDatabaseXML.Query(Text: string; DbRows: TDbRows = nil); 317 318 var 318 319 Command: string; … … 348 349 end else raise Exception.Create('Unsupported columns ' + Columns + ' specification'); 349 350 end else raise Exception.Create('Table ' + TableName + ' not found.'); 350 end else raise Exception.Create('Unsupported SQL command ' + Command); 351 end else 352 if Command = 'CREATE' then begin 353 Command := GetNextPart(Text); 354 if Command = 'TABLE' then begin 355 TableName := GetNextPart(Text); 356 Table := TTable.Create; 357 Table.Name := TableName; 358 Table.DbClient := Self; 359 Tables.Add(Table);; 360 end else raise Exception.Create('TABLE keyword expected'); 361 end else 362 if Command = 'DROP' then begin 363 Command := GetNextPart(Text); 364 if Command = 'TABLE' then begin 365 TableName := GetNextPart(Text); 366 Table := Tables.SearchByName(TableName); 367 if Assigned(Table) then Tables.Remove(Table) 368 else raise Exception.Create('Table ' + TableName + ' not found'); 369 end else raise Exception.Create('TABLE keyword expected'); 370 end else 371 raise Exception.Create('Unsupported SQL command ' + Command); 351 372 end; 352 373 353 374 procedure TDatabaseXML.LoadTables(Tables: TTables); 354 375 begin 355 inherited; 356 376 Tables.Assign(Self.Tables); 357 377 end; 358 378 359 379 procedure TDatabaseXML.Load; 360 380 begin 381 FileName := TDbConnectParamsXml(ConnectProfile.Params).FileName; 361 382 if FileExists(FileName) then 362 383 LoadFromFile(FileName);
Note:
See TracChangeset
for help on using the changeset viewer.