mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 01:39:31 +02:00
MG: added a faster version of TXMLConfig
git-svn-id: trunk@1796 -
This commit is contained in:
parent
80f0f1d9ed
commit
77fcbcd0dc
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -20,6 +20,10 @@ components/codetools/finddeclarationcache.pas svneol=native#text/pascal
|
||||
components/codetools/finddeclarationtool.pas svneol=native#text/pascal
|
||||
components/codetools/keywordfunclists.pas svneol=native#text/pascal
|
||||
components/codetools/languages/codetools.po svneol=native#text/plain
|
||||
components/codetools/laz_dom.pas svneol=native#text/pascal
|
||||
components/codetools/laz_xmlcfg.pas svneol=native#text/pascal
|
||||
components/codetools/laz_xmlread.pas svneol=native#text/pascal
|
||||
components/codetools/laz_xmlwrite.pas svneol=native#text/pascal
|
||||
components/codetools/linkscanner.pas svneol=native#text/pascal
|
||||
components/codetools/memcheck.pas svneol=native#text/pascal
|
||||
components/codetools/methodjumptool.pas svneol=native#text/pascal
|
||||
|
@ -1,4 +1,23 @@
|
||||
{
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
@ -37,6 +56,8 @@ type
|
||||
public
|
||||
Root: TAVLTreeNode;
|
||||
function Find(Data: Pointer): TAVLTreeNode;
|
||||
function FindKey(Key: Pointer;
|
||||
OnCompareKeyWithData: TListSortCompare): TAVLTreeNode;
|
||||
function FindNearest(Data: Pointer): TAVLTreeNode;
|
||||
function FindSuccessor(ANode: TAVLTreeNode): TAVLTreeNode;
|
||||
function FindPrecessor(ANode: TAVLTreeNode): TAVLTreeNode;
|
||||
@ -613,6 +634,22 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TAVLTree.FindKey(Key: Pointer; OnCompareKeyWithData: TListSortCompare
|
||||
): TAVLTreeNode;
|
||||
var Comp: integer;
|
||||
begin
|
||||
Result:=Root;
|
||||
while (Result<>nil) do begin
|
||||
Comp:=OnCompareKeyWithData(Key,Result.Data);
|
||||
if Comp=0 then exit;
|
||||
if Comp<0 then begin
|
||||
Result:=Result.Left
|
||||
end else begin
|
||||
Result:=Result.Right
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TAVLTree.FindNearest(Data: Pointer): TAVLTreeNode;
|
||||
var Comp: integer;
|
||||
begin
|
||||
@ -1030,6 +1067,7 @@ initialization
|
||||
NodeMemManager:=TAVLTreeNodeMemManager.Create;
|
||||
|
||||
finalization
|
||||
writeln('avl_tree.pas finalization');
|
||||
|
||||
NodeMemManager.Free;
|
||||
NodeMemManager:=nil;
|
||||
|
@ -39,7 +39,7 @@ uses
|
||||
{$IFDEF MEM_CHECK}
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, SourceLog, LinkScanner, AVL_Tree, XMLCfg, FileProcs;
|
||||
Classes, SysUtils, SourceLog, LinkScanner, AVL_Tree, FileProcs, Laz_XMLCfg;
|
||||
|
||||
type
|
||||
TCodeCache = class;
|
||||
|
@ -51,7 +51,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, CodeToolsStrConsts, ExprEval
|
||||
{$ifdef FPC}, XMLCfg{$endif}, AVL_Tree, Process,
|
||||
{$ifdef FPC}, Laz_XMLCfg{$endif}, AVL_Tree, Process,
|
||||
KeywordFuncLists, FileProcs;
|
||||
|
||||
const
|
||||
|
1636
components/codetools/laz_dom.pas
Normal file
1636
components/codetools/laz_dom.pas
Normal file
File diff suppressed because it is too large
Load Diff
266
components/codetools/laz_xmlcfg.pas
Normal file
266
components/codetools/laz_xmlcfg.pas
Normal file
@ -0,0 +1,266 @@
|
||||
{
|
||||
BEWARE !!!
|
||||
This is a TEMPORARY file.
|
||||
As soon as it is moved to the fcl, it will be removed.
|
||||
}
|
||||
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Component Library
|
||||
|
||||
Implementation of TXMLConfig class
|
||||
Copyright (c) 1999 - 2001 by Sebastian Guenther, sg@freepascal.org
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{
|
||||
TXMLConfig enables applications to use XML files for storing their
|
||||
configuration data
|
||||
}
|
||||
|
||||
{$MODE objfpc}
|
||||
{$H+}
|
||||
|
||||
unit Laz_XMLCfg;
|
||||
|
||||
interface
|
||||
|
||||
uses Classes, Laz_DOM, Laz_XMLRead, Laz_XMLWrite;
|
||||
|
||||
type
|
||||
|
||||
{"APath" is the path and name of a value: A XML configuration file is
|
||||
hierachical. "/" is the path delimiter, the part after the last "/"
|
||||
is the name of the value. The path components will be mapped to XML
|
||||
elements, the name will be an element attribute.}
|
||||
|
||||
TXMLConfig = class(TComponent)
|
||||
private
|
||||
FFilename: String;
|
||||
procedure SetFilename(const AFilename: String);
|
||||
protected
|
||||
doc: TXMLDocument;
|
||||
FModified: Boolean;
|
||||
procedure Loaded; override;
|
||||
public
|
||||
constructor Create(const AFilename: String);
|
||||
destructor Destroy; override;
|
||||
procedure Flush; // Writes the XML file
|
||||
function GetValue(const APath, ADefault: String): String;
|
||||
function GetValue(const APath: String; ADefault: Integer): Integer;
|
||||
function GetValue(const APath: String; ADefault: Boolean): Boolean;
|
||||
procedure SetValue(const APath, AValue: String);
|
||||
procedure SetValue(const APath: String; AValue: Integer);
|
||||
procedure SetValue(const APath: String; AValue: Boolean);
|
||||
property Modified: Boolean read FModified;
|
||||
published
|
||||
property Filename: String read FFilename write SetFilename;
|
||||
end;
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
implementation
|
||||
|
||||
uses SysUtils;
|
||||
|
||||
|
||||
constructor TXMLConfig.Create(const AFilename: String);
|
||||
begin
|
||||
inherited Create(nil);
|
||||
SetFilename(AFilename);
|
||||
end;
|
||||
|
||||
destructor TXMLConfig.Destroy;
|
||||
begin
|
||||
if Assigned(doc) then
|
||||
begin
|
||||
Flush;
|
||||
doc.Free;
|
||||
end;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TXMLConfig.Flush;
|
||||
var
|
||||
f: Text;
|
||||
begin
|
||||
if Modified then
|
||||
begin
|
||||
AssignFile(f, Filename);
|
||||
Rewrite(f);
|
||||
try
|
||||
WriteXMLFile(doc, f);
|
||||
finally
|
||||
CloseFile(f);
|
||||
end;
|
||||
FModified := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TXMLConfig.GetValue(const APath, ADefault: String): String;
|
||||
var
|
||||
Node, Child, Attr: TDOMNode;
|
||||
i: Integer;
|
||||
NodePath: String;
|
||||
begin
|
||||
Node := doc.DocumentElement; // MAT: check this
|
||||
NodePath := APath;
|
||||
while True do
|
||||
begin
|
||||
i := Pos('/', NodePath);
|
||||
if i = 0 then
|
||||
break;
|
||||
Child := Node.FindNode(Copy(NodePath, 1, i - 1)); // MAT: check this
|
||||
NodePath := Copy(NodePath, i + 1, Length(NodePath));
|
||||
if not Assigned(Child) then
|
||||
begin
|
||||
Result := ADefault;
|
||||
exit;
|
||||
end;
|
||||
Node := Child;
|
||||
end;
|
||||
Attr := Node.Attributes.GetNamedItem(NodePath); // MAT: check this
|
||||
if Assigned(Attr) then
|
||||
Result := Attr.NodeValue
|
||||
else
|
||||
Result := ADefault;
|
||||
end;
|
||||
|
||||
function TXMLConfig.GetValue(const APath: String; ADefault: Integer): Integer;
|
||||
begin
|
||||
Result := StrToInt(GetValue(APath, IntToStr(ADefault)));
|
||||
end;
|
||||
|
||||
function TXMLConfig.GetValue(const APath: String; ADefault: Boolean): Boolean;
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
if ADefault then
|
||||
s := 'True'
|
||||
else
|
||||
s := 'False';
|
||||
|
||||
s := GetValue(APath, s);
|
||||
|
||||
if UpperCase(s) = 'TRUE' then
|
||||
Result := True
|
||||
else if UpperCase(s) = 'FALSE' then
|
||||
Result := False
|
||||
else
|
||||
Result := ADefault;
|
||||
end;
|
||||
|
||||
procedure TXMLConfig.SetValue(const APath, AValue: String);
|
||||
var
|
||||
Node, Child: TDOMNode;
|
||||
i: Integer;
|
||||
NodeName, NodePath: String;
|
||||
begin
|
||||
Node := Doc.DocumentElement;
|
||||
NodePath := APath;
|
||||
while True do
|
||||
begin
|
||||
i := Pos('/', NodePath);
|
||||
if i = 0 then
|
||||
break;
|
||||
NodeName := Copy(NodePath, 1, i - 1);
|
||||
NodePath := Copy(NodePath, i + 1, Length(NodePath));
|
||||
Child := Node.FindNode(NodeName);
|
||||
if not Assigned(Child) then
|
||||
begin
|
||||
Child := Doc.CreateElement(NodeName);
|
||||
Node.AppendChild(Child);
|
||||
end;
|
||||
Node := Child;
|
||||
end;
|
||||
|
||||
if (not Assigned(TDOMElement(Node).GetAttributeNode(NodePath))) or
|
||||
(TDOMElement(Node)[NodePath] <> AValue) then
|
||||
begin
|
||||
TDOMElement(Node)[NodePath] := AValue;
|
||||
FModified := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TXMLConfig.SetValue(const APath: String; AValue: Integer);
|
||||
begin
|
||||
SetValue(APath, IntToStr(AValue));
|
||||
end;
|
||||
|
||||
procedure TXMLConfig.SetValue(const APath: String; AValue: Boolean);
|
||||
begin
|
||||
if AValue then
|
||||
SetValue(APath, 'True')
|
||||
else
|
||||
SetValue(APath, 'False');
|
||||
end;
|
||||
|
||||
procedure TXMLConfig.Loaded;
|
||||
begin
|
||||
inherited Loaded;
|
||||
if Length(Filename) > 0 then
|
||||
SetFilename(Filename); // Load the XML config file
|
||||
end;
|
||||
|
||||
procedure TXMLConfig.SetFilename(const AFilename: String);
|
||||
var
|
||||
f: File;
|
||||
cfg: TDOMElement;
|
||||
begin
|
||||
FFilename := AFilename;
|
||||
|
||||
if csLoading in ComponentState then
|
||||
exit;
|
||||
|
||||
if Assigned(doc) then
|
||||
begin
|
||||
Flush;
|
||||
doc.Free;
|
||||
end;
|
||||
|
||||
AssignFile(f, AFileName);
|
||||
{$I-}
|
||||
Reset(f, 1);
|
||||
{$I+}
|
||||
if IOResult = 0 then
|
||||
try
|
||||
ReadXMLFile(doc, f);
|
||||
finally
|
||||
CloseFile(f);
|
||||
end;
|
||||
|
||||
if not Assigned(doc) then
|
||||
doc := TXMLDocument.Create;
|
||||
|
||||
cfg :=TDOMElement(doc.FindNode('CONFIG'));
|
||||
if not Assigned(cfg) then begin
|
||||
cfg := doc.CreateElement('CONFIG');
|
||||
doc.AppendChild(cfg);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2002/07/30 06:24:06 lazarus
|
||||
MG: added a faster version of TXMLConfig
|
||||
|
||||
Revision 1.4 2001/04/10 23:22:05 peter
|
||||
* merged fixes
|
||||
|
||||
Revision 1.3 2000/07/29 14:52:24 sg
|
||||
* Modified the copyright notice to remove ambiguities
|
||||
|
||||
Revision 1.2 2000/07/13 11:33:07 michael
|
||||
+ removed logs
|
||||
|
||||
}
|
1142
components/codetools/laz_xmlread.pas
Normal file
1142
components/codetools/laz_xmlread.pas
Normal file
File diff suppressed because it is too large
Load Diff
449
components/codetools/laz_xmlwrite.pas
Normal file
449
components/codetools/laz_xmlwrite.pas
Normal file
@ -0,0 +1,449 @@
|
||||
{
|
||||
BEWARE !!!
|
||||
This is a TEMPORARY file.
|
||||
As soon as it is moved to the fcl, it will be removed.
|
||||
}
|
||||
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Component Library
|
||||
|
||||
XML writing routines
|
||||
Copyright (c) 1999-2000 by Sebastian Guenther, sg@freepascal.org
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
|
||||
unit Laz_XMLWrite;
|
||||
|
||||
{$MODE objfpc}
|
||||
{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses Classes, Laz_DOM;
|
||||
|
||||
procedure WriteXMLFile(doc: TXMLDocument; const AFileName: String);
|
||||
procedure WriteXMLFile(doc: TXMLDocument; var AFile: Text);
|
||||
procedure WriteXMLFile(doc: TXMLDocument; var AStream: TStream);
|
||||
|
||||
procedure WriteXML(Element: TDOMElement; const AFileName: String);
|
||||
procedure WriteXML(Element: TDOMElement; var AFile: Text);
|
||||
procedure WriteXML(Element: TDOMElement; var AStream: TStream);
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
implementation
|
||||
|
||||
uses SysUtils;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Writers for the different node types
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
procedure WriteElement(node: TDOMNode); forward;
|
||||
procedure WriteAttribute(node: TDOMNode); forward;
|
||||
procedure WriteText(node: TDOMNode); forward;
|
||||
procedure WriteCDATA(node: TDOMNode); forward;
|
||||
procedure WriteEntityRef(node: TDOMNode); forward;
|
||||
procedure WriteEntity(node: TDOMNode); forward;
|
||||
procedure WritePI(node: TDOMNode); forward;
|
||||
procedure WriteComment(node: TDOMNode); forward;
|
||||
procedure WriteDocument(node: TDOMNode); forward;
|
||||
procedure WriteDocumentType(node: TDOMNode); forward;
|
||||
procedure WriteDocumentFragment(node: TDOMNode); forward;
|
||||
procedure WriteNotation(node: TDOMNode); forward;
|
||||
|
||||
|
||||
type
|
||||
TWriteNodeProc = procedure(node: TDOMNode);
|
||||
|
||||
const
|
||||
WriteProcs: array[ELEMENT_NODE..NOTATION_NODE] of TWriteNodeProc =
|
||||
(@WriteElement, @WriteAttribute, @WriteText, @WriteCDATA, @WriteEntityRef,
|
||||
@WriteEntity, @WritePI, @WriteComment, @WriteDocument, @WriteDocumentType,
|
||||
@WriteDocumentFragment, @WriteNotation);
|
||||
|
||||
procedure WriteNode(node: TDOMNode);
|
||||
begin
|
||||
WriteProcs[node.NodeType](node);
|
||||
end;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Text file and TStream support
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
type
|
||||
TOutputProc = procedure(s: String);
|
||||
|
||||
var
|
||||
f: ^Text;
|
||||
stream: TStream;
|
||||
wrt, wrtln: TOutputProc;
|
||||
InsideTextNode: Boolean;
|
||||
|
||||
|
||||
procedure Text_Write(s: String);
|
||||
begin
|
||||
Write(f^, s);
|
||||
end;
|
||||
|
||||
procedure Text_WriteLn(s: String);
|
||||
begin
|
||||
WriteLn(f^, s);
|
||||
end;
|
||||
|
||||
procedure Stream_Write(s: String);
|
||||
begin
|
||||
if Length(s) > 0 then
|
||||
stream.Write(s[1], Length(s));
|
||||
end;
|
||||
|
||||
procedure Stream_WriteLn(s: String);
|
||||
begin
|
||||
if Length(s) > 0 then
|
||||
stream.Write(s[1], Length(s));
|
||||
stream.WriteByte(10);
|
||||
end;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Indent handling
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
var
|
||||
Indent: String;
|
||||
|
||||
|
||||
procedure IncIndent;
|
||||
begin
|
||||
Indent := Indent + ' ';
|
||||
end;
|
||||
|
||||
procedure DecIndent;
|
||||
begin
|
||||
if Length(Indent) >= 2 then
|
||||
SetLength(Indent, Length(Indent) - 2);
|
||||
end;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// String conversion
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
type
|
||||
TCharacters = set of Char;
|
||||
TSpecialCharCallback = procedure(c: Char);
|
||||
|
||||
const
|
||||
AttrSpecialChars = ['"', '&'];
|
||||
TextSpecialChars = ['<', '>', '&'];
|
||||
|
||||
|
||||
procedure ConvWrite(const s: String; const SpecialChars: TCharacters;
|
||||
const SpecialCharCallback: TSpecialCharCallback);
|
||||
var
|
||||
StartPos, EndPos: Integer;
|
||||
begin
|
||||
StartPos := 1;
|
||||
EndPos := 1;
|
||||
while EndPos <= Length(s) do
|
||||
begin
|
||||
if s[EndPos] in SpecialChars then
|
||||
begin
|
||||
wrt(Copy(s, StartPos, EndPos - StartPos));
|
||||
SpecialCharCallback(s[EndPos]);
|
||||
StartPos := EndPos + 1;
|
||||
end;
|
||||
Inc(EndPos);
|
||||
end;
|
||||
if EndPos > StartPos then
|
||||
wrt(Copy(s, StartPos, EndPos - StartPos));
|
||||
end;
|
||||
|
||||
procedure AttrSpecialCharCallback(c: Char);
|
||||
begin
|
||||
if c = '"' then
|
||||
wrt('"')
|
||||
else if c = '&' then
|
||||
wrt('&')
|
||||
else
|
||||
wrt(c);
|
||||
end;
|
||||
|
||||
procedure TextnodeSpecialCharCallback(c: Char);
|
||||
begin
|
||||
if c = '<' then
|
||||
wrt('<')
|
||||
else if c = '>' then
|
||||
wrt('>')
|
||||
else if c = '&' then
|
||||
wrt('&')
|
||||
else
|
||||
wrt(c);
|
||||
end;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Node writers implementations
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
procedure WriteElement(node: TDOMNode);
|
||||
var
|
||||
i: Integer;
|
||||
attr, child: TDOMNode;
|
||||
SavedInsideTextNode: Boolean;
|
||||
s: String;
|
||||
begin
|
||||
if not InsideTextNode then
|
||||
wrt(Indent);
|
||||
wrt('<' + node.NodeName);
|
||||
for i := 0 to node.Attributes.Length - 1 do
|
||||
begin
|
||||
attr := node.Attributes.Item[i];
|
||||
wrt(' ' + attr.NodeName + '=');
|
||||
s := attr.NodeValue;
|
||||
// !!!: Replace special characters in "s" such as '&', '<', '>'
|
||||
wrt('"');
|
||||
ConvWrite(s, AttrSpecialChars, @AttrSpecialCharCallback);
|
||||
wrt('"');
|
||||
end;
|
||||
Child := node.FirstChild;
|
||||
if Child = nil then
|
||||
if InsideTextNode then
|
||||
wrt('/>')
|
||||
else
|
||||
wrtln('/>')
|
||||
else
|
||||
begin
|
||||
SavedInsideTextNode := InsideTextNode;
|
||||
if InsideTextNode or Child.InheritsFrom(TDOMText) then
|
||||
wrt('>')
|
||||
else
|
||||
wrtln('>');
|
||||
IncIndent;
|
||||
repeat
|
||||
if Child.InheritsFrom(TDOMText) then
|
||||
InsideTextNode := True;
|
||||
WriteNode(Child);
|
||||
Child := Child.NextSibling;
|
||||
until child = nil;
|
||||
DecIndent;
|
||||
if not InsideTextNode then
|
||||
wrt(Indent);
|
||||
InsideTextNode := SavedInsideTextNode;
|
||||
s := '</' + node.NodeName + '>';
|
||||
if InsideTextNode then
|
||||
wrt(s)
|
||||
else
|
||||
wrtln(s);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure WriteAttribute(node: TDOMNode);
|
||||
begin
|
||||
WriteLn('WriteAttribute');
|
||||
if node=nil then ;
|
||||
end;
|
||||
|
||||
procedure WriteText(node: TDOMNode);
|
||||
begin
|
||||
ConvWrite(node.NodeValue, TextSpecialChars, @TextnodeSpecialCharCallback);
|
||||
if node=nil then ;
|
||||
end;
|
||||
|
||||
procedure WriteCDATA(node: TDOMNode);
|
||||
begin
|
||||
if InsideTextNode then
|
||||
wrt('<![CDATA[' + node.NodeValue + ']]>')
|
||||
else
|
||||
wrtln(Indent + '<![CDATA[' + node.NodeValue + ']]>')
|
||||
end;
|
||||
|
||||
procedure WriteEntityRef(node: TDOMNode);
|
||||
begin
|
||||
wrt('&' + node.NodeName + ';');
|
||||
end;
|
||||
|
||||
procedure WriteEntity(node: TDOMNode);
|
||||
begin
|
||||
WriteLn('WriteEntity');
|
||||
if node=nil then ;
|
||||
end;
|
||||
|
||||
procedure WritePI(node: TDOMNode);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
s := '<!' + TDOMProcessingInstruction(node).Target + ' ' +
|
||||
TDOMProcessingInstruction(node).Data + '>';
|
||||
if InsideTextNode then
|
||||
wrt(s)
|
||||
else
|
||||
wrtln(Indent + s);
|
||||
end;
|
||||
|
||||
procedure WriteComment(node: TDOMNode);
|
||||
begin
|
||||
if InsideTextNode then
|
||||
wrt('<!--' + node.NodeValue + '-->')
|
||||
else
|
||||
wrtln(Indent + '<!--' + node.NodeValue + '-->')
|
||||
end;
|
||||
|
||||
procedure WriteDocument(node: TDOMNode);
|
||||
begin
|
||||
WriteLn('WriteDocument');
|
||||
if node=nil then ;
|
||||
end;
|
||||
|
||||
procedure WriteDocumentType(node: TDOMNode);
|
||||
begin
|
||||
WriteLn('WriteDocumentType');
|
||||
if node=nil then ;
|
||||
end;
|
||||
|
||||
procedure WriteDocumentFragment(node: TDOMNode);
|
||||
begin
|
||||
WriteLn('WriteDocumentFragment');
|
||||
if node=nil then ;
|
||||
end;
|
||||
|
||||
procedure WriteNotation(node: TDOMNode);
|
||||
begin
|
||||
WriteLn('WriteNotation');
|
||||
if node=nil then ;
|
||||
end;
|
||||
|
||||
|
||||
procedure InitWriter;
|
||||
begin
|
||||
InsideTextNode := False;
|
||||
end;
|
||||
|
||||
procedure RootWriter(doc: TXMLDocument);
|
||||
var
|
||||
Child: TDOMNode;
|
||||
begin
|
||||
InitWriter;
|
||||
wrt('<?xml version="');
|
||||
if Length(doc.XMLVersion) > 0 then
|
||||
wrt(doc.XMLVersion)
|
||||
else
|
||||
wrt('1.0');
|
||||
wrt('"');
|
||||
if Length(doc.Encoding) > 0 then
|
||||
wrt(' encoding="' + doc.Encoding + '"');
|
||||
wrtln('?>');
|
||||
|
||||
if Length(doc.StylesheetType) > 0 then
|
||||
// !!!: Can't handle with HRefs which contain special chars (" and so on)
|
||||
wrtln(Format('<?xml-stylesheet type="%s" href="%s"?>',
|
||||
[doc.StylesheetType, doc.StylesheetHRef]));
|
||||
|
||||
indent := '';
|
||||
|
||||
child := doc.FirstChild;
|
||||
while Assigned(Child) do
|
||||
begin
|
||||
WriteNode(Child);
|
||||
Child := Child.NextSibling;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Interface implementation
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
procedure WriteXMLFile(doc: TXMLDocument; const AFileName: String);
|
||||
begin
|
||||
Stream := TFileStream.Create(AFileName, fmCreate);
|
||||
wrt := @Stream_Write;
|
||||
wrtln := @Stream_WriteLn;
|
||||
RootWriter(doc);
|
||||
Stream.Free;
|
||||
end;
|
||||
|
||||
procedure WriteXMLFile(doc: TXMLDocument; var AFile: Text);
|
||||
begin
|
||||
f := @AFile;
|
||||
wrt := @Text_Write;
|
||||
wrtln := @Text_WriteLn;
|
||||
RootWriter(doc);
|
||||
end;
|
||||
|
||||
procedure WriteXMLFile(doc: TXMLDocument; var AStream: TStream);
|
||||
begin
|
||||
Stream := AStream;
|
||||
wrt := @Stream_Write;
|
||||
wrtln := @Stream_WriteLn;
|
||||
RootWriter(doc);
|
||||
end;
|
||||
|
||||
|
||||
procedure WriteXML(Element: TDOMElement; const AFileName: String);
|
||||
begin
|
||||
Stream := TFileStream.Create(AFileName, fmCreate);
|
||||
wrt := @Stream_Write;
|
||||
wrtln := @Stream_WriteLn;
|
||||
InitWriter;
|
||||
WriteNode(Element);
|
||||
Stream.Free;
|
||||
end;
|
||||
|
||||
procedure WriteXML(Element: TDOMElement; var AFile: Text);
|
||||
begin
|
||||
f := @AFile;
|
||||
wrt := @Text_Write;
|
||||
wrtln := @Text_WriteLn;
|
||||
InitWriter;
|
||||
WriteNode(Element);
|
||||
end;
|
||||
|
||||
procedure WriteXML(Element: TDOMElement; var AStream: TStream);
|
||||
begin
|
||||
stream := AStream;
|
||||
wrt := @Stream_Write;
|
||||
wrtln := @Stream_WriteLn;
|
||||
InitWriter;
|
||||
WriteNode(Element);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2002/07/30 06:24:06 lazarus
|
||||
MG: added a faster version of TXMLConfig
|
||||
|
||||
Revision 1.6 2001/06/07 14:38:44 jonas
|
||||
* fixed wrong procvar syntax (patches from Peter)
|
||||
|
||||
Revision 1.5 2000/10/03 20:16:31 sg
|
||||
* Now writes Processing Instructions and a stylesheet link, if set
|
||||
|
||||
Revision 1.4 2000/07/29 14:52:25 sg
|
||||
* Modified the copyright notice to remove ambiguities
|
||||
|
||||
Revision 1.3 2000/07/25 09:20:08 sg
|
||||
* Fixed some small bugs
|
||||
- some methods where 'virtual' instead of 'override' in dom.pp
|
||||
- corrections regaring wether NodeName or NodeValue is used, for
|
||||
some node types (Entity, EntityReference)
|
||||
|
||||
Revision 1.2 2000/07/13 11:33:08 michael
|
||||
+ removed logs
|
||||
|
||||
}
|
@ -41,7 +41,7 @@ interface
|
||||
uses
|
||||
Forms, SysUtils, Buttons, Classes, Graphics, GraphType, StdCtrls, LCLType,
|
||||
LCLLinux, LMessages, Controls, ComCtrls, ExtCtrls, PropEdits, TypInfo,
|
||||
Messages, LResources, XMLCfg, Menus, Dialogs;
|
||||
Messages, LResources, Laz_XMLCfg, Menus, Dialogs;
|
||||
|
||||
{$DEFINE ClientRectBugFix}
|
||||
|
||||
|
@ -2011,7 +2011,7 @@ procedure TForm1.SelectFont(Sender : TObject);
|
||||
begin
|
||||
If FontDialog1.Execute then
|
||||
begin
|
||||
lblWhatFont.Caption := 'Font.Name: '+FontDialog1.FontName;
|
||||
lblWhatFont.Caption := 'Font.Name: '+FontDialog1.Font.Name;
|
||||
end;
|
||||
end;
|
||||
//++++++++++++++++++++++++++++++++ TForm ++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -2881,6 +2881,9 @@ begin
|
||||
end;
|
||||
{
|
||||
$Log$
|
||||
Revision 1.8 2002/07/30 06:24:06 lazarus
|
||||
MG: added a faster version of TXMLConfig
|
||||
|
||||
Revision 1.7 2002/05/10 06:57:50 lazarus
|
||||
MG: updated licenses
|
||||
|
||||
|
@ -35,7 +35,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, StdCtrls, ExtCtrls, Buttons, LResources,
|
||||
XMLCfg, ExtToolDialog, ExtToolEditDlg, TransferMacros, LazConf;
|
||||
Laz_XMLCfg, ExtToolDialog, ExtToolEditDlg, TransferMacros, LazConf;
|
||||
|
||||
type
|
||||
TMakeMode = (mmNone, mmBuild, mmCleanBuild);
|
||||
|
@ -45,7 +45,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLLinux, Forms, Controls, Buttons, StdCtrls, ComCtrls,
|
||||
ExtCtrls, Menus, LResources, Graphics, Dialogs, ImgList, SynEdit, XMLCfg,
|
||||
ExtCtrls, Menus, LResources, Graphics, Dialogs, ImgList, SynEdit, Laz_XMLCfg,
|
||||
DefineTemplates, CodeToolManager, CodeToolsOptions, CodeToolsDefPreview,
|
||||
TransferMacros, InputFileDialog;
|
||||
|
||||
|
@ -36,7 +36,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, IDEProcs, LazConf, LResources, Forms, Controls, Buttons,
|
||||
ExtCtrls, StdCtrls, ComCtrls, Dialogs, XMLCfg, CodeToolManager,
|
||||
ExtCtrls, StdCtrls, ComCtrls, Dialogs, Laz_XMLCfg, CodeToolManager,
|
||||
DefineTemplates, SourceChanger, EditDefineTree, SynEdit;
|
||||
|
||||
type
|
||||
|
@ -42,14 +42,14 @@ interface
|
||||
|
||||
uses
|
||||
Forms, Classes, SysUtils, ComCtrls, Buttons, StdCtrls, ExtCtrls, LazConf,
|
||||
XMLCfg, FileCtrl, Dialogs, Controls, PathEditorDlg, IDEProcs;
|
||||
Laz_XMLCfg, FileCtrl, Dialogs, Controls, PathEditorDlg, IDEProcs;
|
||||
|
||||
type
|
||||
{ Compiler Options object used to hold the compiler options }
|
||||
TCompilerOptions = class(TObject)
|
||||
private
|
||||
fOptionsString: String;
|
||||
xmlcfg: TXMLConfig;
|
||||
xmlconfig: TXMLConfig;
|
||||
|
||||
fProjectFile: String;
|
||||
fTargetFilename: string;
|
||||
@ -139,7 +139,7 @@ type
|
||||
|
||||
property ProjectFile: String read fProjectFile write fProjectFile;
|
||||
property TargetFilename: String read fTargetFilename write fTargetFilename;
|
||||
property XMLConfigFile: TXMLConfig read xmlcfg write xmlcfg;
|
||||
property XMLConfigFile: TXMLConfig read xmlconfig write xmlconfig;
|
||||
property Loaded: Boolean read fLoaded write fLoaded;
|
||||
|
||||
property Style: Integer read fStyle write fStyle;
|
||||
|
@ -51,7 +51,7 @@ uses
|
||||
{$else}
|
||||
mwCustomEdit, mwPasSyn, mwHighlighter,
|
||||
{$endif}
|
||||
XMLCfg, CodeTemplateDialog, KeyMapping, InputHistory;
|
||||
Laz_XMLCfg, CodeTemplateDialog, KeyMapping, InputHistory;
|
||||
|
||||
type
|
||||
{$ifdef NEW_EDITOR_SYNEDIT}
|
||||
|
@ -37,7 +37,7 @@ uses
|
||||
{$IFDEF IDE_MEM_CHECK}
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, Forms, Controls, Buttons, GraphType, Graphics, XMLCfg,
|
||||
Classes, SysUtils, Forms, Controls, Buttons, GraphType, Graphics, Laz_XMLCfg,
|
||||
ObjectInspector, ExtCtrls, StdCtrls, EditorOptions, LResources, LazConf,
|
||||
Dialogs, ExtToolDialog, IDEProcs, IDEOptionDefs, InputHistory;
|
||||
|
||||
|
@ -40,8 +40,8 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, LCLType, Controls, Forms, Buttons, StdCtrls, ComCtrls,
|
||||
Dialogs, ExtCtrls, LResources, XMLCfg, ExtToolEditDlg, Process, KeyMapping,
|
||||
TransferMacros, IDEProcs, OutputFilter;
|
||||
Dialogs, ExtCtrls, LResources, Laz_XMLCfg, ExtToolEditDlg, Process,
|
||||
KeyMapping, TransferMacros, IDEProcs, OutputFilter;
|
||||
|
||||
const
|
||||
MaxExtTools = ecExtToolLast-ecExtToolFirst+1;
|
||||
|
@ -43,7 +43,7 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, LCLType, Controls, Forms, Buttons, StdCtrls, ComCtrls,
|
||||
Dialogs, ExtCtrls, LResources, XMLCfg, KeyMapping, TransferMacros;
|
||||
Dialogs, ExtCtrls, LResources, Laz_XMLCfg, KeyMapping, TransferMacros;
|
||||
|
||||
{ The xml format version:
|
||||
When the format changes (new values, changed formats) we can distinguish old
|
||||
|
@ -33,7 +33,7 @@ unit IDEOptionDefs;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, XMLCfg, Forms, Controls, StdCtrls, Buttons;
|
||||
Classes, SysUtils, Laz_XMLCfg, Forms, Controls, StdCtrls, Buttons;
|
||||
|
||||
const
|
||||
DefaultMainIDEName = 'MainIDE';
|
||||
|
@ -30,7 +30,7 @@ unit IDEProcs;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, XMLCfg, GetText;
|
||||
Classes, SysUtils, Laz_XMLCfg, GetText;
|
||||
|
||||
//
|
||||
const
|
||||
|
@ -31,7 +31,7 @@ unit InputHistory;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, IDEProcs, XMLCfg, LazConf, Dialogs;
|
||||
Classes, SysUtils, IDEProcs, Laz_XMLCfg, LazConf, Dialogs;
|
||||
|
||||
type
|
||||
TFileDialogSettings = record
|
||||
|
@ -36,7 +36,7 @@ interface
|
||||
uses
|
||||
LCLLinux, LCLType,
|
||||
Forms, Classes, SysUtils, Buttons, LResources, StdCtrls, Controls,
|
||||
SynEdit, SynEditKeyCmds, XMLCfg, Dialogs;
|
||||
SynEdit, SynEditKeyCmds, Laz_XMLCfg, Dialogs;
|
||||
|
||||
const
|
||||
{ editor commands constants. see syneditkeycmds.pp for more
|
||||
|
@ -51,7 +51,7 @@ uses
|
||||
MsgView,
|
||||
FindReplaceDialog,
|
||||
FindInFilesDlg,
|
||||
aboutfrm;
|
||||
IDEProcs;
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
@ -77,12 +77,18 @@ begin
|
||||
Application.Run;
|
||||
SplashForm.Free;
|
||||
|
||||
writeln('LAZARUS END');
|
||||
writeln('LAZARUS END - cleaning up ...');
|
||||
|
||||
// free the forms, so that they are freed before the finalization sections
|
||||
FreeThenNil(MainIDE);
|
||||
end.
|
||||
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.36 2002/07/30 06:24:04 lazarus
|
||||
MG: added a faster version of TXMLConfig
|
||||
|
||||
Revision 1.35 2002/06/09 07:08:41 lazarus
|
||||
MG: fixed window jumping
|
||||
|
||||
|
@ -30,7 +30,7 @@ unit MiscOptions;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BuildLazDialog, LazConf, IDEProcs, XMLCfg;
|
||||
Classes, SysUtils, BuildLazDialog, LazConf, IDEProcs, Laz_XMLCfg;
|
||||
|
||||
type
|
||||
TMiscellaneousOptions = class
|
||||
|
@ -42,7 +42,7 @@ unit Project;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLLinux, LCLType, XMLCfg, LazConf, CompilerOptions,
|
||||
Classes, SysUtils, LCLLinux, LCLType, Laz_XMLCfg, LazConf, CompilerOptions,
|
||||
FileCtrl, CodeToolManager, CodeCache, Forms, Controls, EditorOptions, Dialogs,
|
||||
IDEProcs, RunParamsOpts, ProjectDefs, EditDefineTree, DefineTemplates;
|
||||
|
||||
@ -1458,6 +1458,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.67 2002/07/30 06:24:04 lazarus
|
||||
MG: added a faster version of TXMLConfig
|
||||
|
||||
Revision 1.66 2002/07/06 06:37:06 lazarus
|
||||
MG: added Revert
|
||||
|
||||
|
@ -37,7 +37,7 @@ unit ProjectDefs;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, XMLCfg, IDEProcs;
|
||||
Classes, SysUtils, Laz_XMLCfg, IDEProcs;
|
||||
|
||||
type
|
||||
TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object;
|
||||
|
@ -48,7 +48,7 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, Controls, Forms, Buttons, StdCtrls, ComCtrls, Dialogs,
|
||||
ExtCtrls, LResources, XMLCfg, DOS, IDEProcs, SysVarUserOverrideDlg,
|
||||
ExtCtrls, LResources, Laz_XMLCfg, DOS, IDEProcs, SysVarUserOverrideDlg,
|
||||
InputHistory;
|
||||
|
||||
{ The xml format version:
|
||||
|
@ -37,7 +37,7 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, Controls, Forms, Buttons, StdCtrls, ComCtrls, Dialogs,
|
||||
ExtCtrls, LResources, XMLCfg, DOS, IDEProcs;
|
||||
ExtCtrls, LResources, Laz_XMLCfg, DOS, IDEProcs;
|
||||
|
||||
type
|
||||
TSysVarUserOverrideDialog = class(TForm)
|
||||
|
Loading…
Reference in New Issue
Block a user