mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-28 19:02:54 +02:00
lcl: added TPropStorageXMLConfig.LoadFromStream+SaveToStream
git-svn-id: trunk@39711 -
This commit is contained in:
parent
f3bbfa5d32
commit
d241c00d1f
@ -22,14 +22,17 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LCLProc, Forms, PropertyStorage, XMLConf, DOM,
|
||||
LazConfigStorage;
|
||||
XMLRead, XMLWrite, LazConfigStorage;
|
||||
|
||||
type
|
||||
{ TPropStorageXMLConfig }
|
||||
|
||||
TPropStorageXMLConfig = class(TXMLConfig)
|
||||
Public
|
||||
procedure DeleteSubNodes (const ARootNode: String);
|
||||
procedure DeleteSubNodes(const ARootNode: String);
|
||||
procedure LoadFromStream(s: TStream); virtual;
|
||||
procedure SaveToStream(s: TStream); virtual;
|
||||
property XMLDoc: TXMLDocument read Doc;
|
||||
end;
|
||||
|
||||
{ TCustomXMLPropStorage }
|
||||
@ -93,6 +96,7 @@ type
|
||||
constructor Create(const Filename: string; LoadFromDisk: Boolean); override;
|
||||
constructor Create(TheXMLConfig: TXMLConfig);
|
||||
constructor Create(TheXMLConfig: TXMLConfig; const StartPath: string);
|
||||
constructor Create(s: TStream; const StartPath: string = '');
|
||||
destructor Destroy; override;
|
||||
property XMLConfig: TXMLConfig read FXMLConfig;
|
||||
property FreeXMLConfig: boolean read FFreeXMLConfig write FFreeXMLConfig;
|
||||
@ -141,7 +145,7 @@ end;
|
||||
function TCustomXMLPropStorage.GetXMLFileName: string;
|
||||
begin
|
||||
if (FFileName<>'') then
|
||||
Result:=FFIleName
|
||||
Result:=FFileName
|
||||
else
|
||||
{$ifdef unix}
|
||||
Result:=IncludeTrailingPathDelimiter(GetEnvironmentVariableUTF8('HOME'))
|
||||
@ -215,6 +219,19 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPropStorageXMLConfig.LoadFromStream(s: TStream);
|
||||
var
|
||||
NewDoc: TXMLDocument;
|
||||
begin
|
||||
FreeAndNil(Doc);
|
||||
ReadXMLFile(Doc,s);
|
||||
end;
|
||||
|
||||
procedure TPropStorageXMLConfig.SaveToStream(s: TStream);
|
||||
begin
|
||||
WriteXMLFile(Doc,s);
|
||||
end;
|
||||
|
||||
{ TXMLConfigStorage }
|
||||
|
||||
function TXMLConfigStorage.GetFullPathValue(const APath, ADefault: String
|
||||
@ -288,7 +305,7 @@ end;
|
||||
constructor TXMLConfigStorage.Create(const Filename: string;
|
||||
LoadFromDisk: Boolean);
|
||||
begin
|
||||
FXMLConfig:=TXMLConfig.Create(nil);
|
||||
FXMLConfig:=TPropStorageXMLConfig.Create(nil);
|
||||
FXMLConfig.StartEmpty:=not LoadFromDisk;
|
||||
FXMLConfig.Filename:=Filename;
|
||||
FFreeXMLConfig:=true;
|
||||
@ -308,6 +325,15 @@ begin
|
||||
AppendBasePath(StartPath);
|
||||
end;
|
||||
|
||||
constructor TXMLConfigStorage.Create(s: TStream; const StartPath: string);
|
||||
begin
|
||||
FXMLConfig:=TPropStorageXMLConfig.Create(nil);
|
||||
FFreeXMLConfig:=true;
|
||||
TPropStorageXMLConfig(FXMLConfig).LoadFromStream(s);
|
||||
if StartPath<>'' then
|
||||
AppendBasePath(StartPath);
|
||||
end;
|
||||
|
||||
destructor TXMLConfigStorage.Destroy;
|
||||
begin
|
||||
if FreeXMLConfig then FreeAndNil(FXMLConfig);
|
||||
|
Loading…
Reference in New Issue
Block a user