Skip to content

Commit 68f5c93

Browse files
author
delphidabbler
committed
Remove ability to import user data from TCodeImporter
Made minimal changes to calling code to support change in TCodeImporter's interface.
1 parent 934c5bb commit 68f5c93

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

Src/UCodeImportExport.pas

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ TCodeImporter = class(TNoPublicConstructObject)
6868
strict private
6969
/// <summary>Version of file being imported.</summary>
7070
fVersion: Integer;
71-
/// <summary>Information about user who created export.</summary>
72-
fUserInfo: TUserInfo;
7371
/// <summary>List of snippets read from XML.</summary>
7472
fSnippetInfo: TSnippetInfoList;
7573
/// <summary>Extended XML document object.</summary>
@@ -91,14 +89,12 @@ TCodeImporter = class(TNoPublicConstructObject)
9189
public
9290
/// <summary>Destroys object.</summary>
9391
destructor Destroy; override;
94-
/// <summary>Imports snippets and optional user data from XML.</summary>
95-
/// <param name="UserInfo">TUserInfo [out] Receives user information. Set
96-
/// to null if no user information was available.</param>
92+
/// <summary>Imports snippets from XML.</summary>
9793
/// <param name="SnippetInfo">TSnippetInfoList [out] Receives information
9894
/// about each imported snippet.</param>
9995
/// <param name="Data">TBytes [in] Byte array containing XML data.</param>
100-
class procedure ImportData(out UserInfo: TUserInfo;
101-
out SnippetInfo: TSnippetInfoList; const Data: TBytes);
96+
class procedure ImportData(out SnippetInfo: TSnippetInfoList;
97+
const Data: TBytes);
10298
end;
10399

104100
type
@@ -469,7 +465,6 @@ procedure TCodeImporter.Execute(const Data: TBytes);
469465
// Error message
470466
sParseError = 'Import file has an invalid format';
471467
var
472-
UserNode: IXMLNode; // node containing any user info
473468
SnippetNodes: IXMLSimpleNodeList; // list of snippet nodes
474469
SnippetNode: IXMLNode; // each snippet node in list
475470
Idx: Integer; // loops thru snippet node list
@@ -482,21 +477,6 @@ procedure TCodeImporter.Execute(const Data: TBytes);
482477
// Validate loaded document and get version number
483478
fVersion := ValidateDoc;
484479

485-
// Get user info
486-
UserNode := fXMLDoc.FindNode(cExportRootNode + '\' + cUserInfoNode);
487-
if Assigned(UserNode) then
488-
begin
489-
fUserInfo.Details.Name := TXMLDocHelper.GetSubTagText(
490-
fXMLDoc, UserNode, cUserNameNode
491-
);
492-
fUserInfo.Details.Email := TXMLDocHelper.GetSubTagText(
493-
fXMLDoc, UserNode, cUserEmailNode
494-
);
495-
fUserInfo.Comments := TXMLDocHelper.GetSubTagText(
496-
fXMLDoc, UserNode, cUserCommentsNode
497-
);
498-
end;
499-
500480
// Read in all snippets
501481
SnippetNodes := GetAllSnippetNodes;
502482
SetLength(fSnippetInfo, SnippetNodes.Count);
@@ -574,15 +554,14 @@ function TCodeImporter.GetAllSnippetNodes: IXMLSimpleNodeList;
574554
Result := fXMLDoc.FindChildNodes(SnippetsNode, cSnippetNode);
575555
end;
576556

577-
class procedure TCodeImporter.ImportData(out UserInfo: TUserInfo;
578-
out SnippetInfo: TSnippetInfoList; const Data: TBytes);
557+
class procedure TCodeImporter.ImportData(out SnippetInfo: TSnippetInfoList;
558+
const Data: TBytes);
579559
var
580560
Idx: Integer; // loops through all imported snippets
581561
begin
582562
with InternalCreate do
583563
try
584564
Execute(Data);
585-
UserInfo.Assign(fUserInfo);
586565
SetLength(SnippetInfo, Length(fSnippetInfo));
587566
for Idx := Low(fSnippetInfo) to High(fSnippetInfo) do
588567
SnippetInfo[Idx].Assign(fSnippetInfo[Idx]);
@@ -599,7 +578,6 @@ constructor TCodeImporter.InternalCreate;
599578
fXMLDoc := TXMLDocHelper.CreateXMLDoc;
600579
// Initialise fields that receive imported data
601580
SetLength(fSnippetInfo, 0);
602-
fUserInfo.Init;
603581
end;
604582

605583
function TCodeImporter.ValidateDoc: Integer;

Src/UCodeImportMgr.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ procedure TCodeImportMgr.Import(const FileName: string);
214214
fImportInfoList.Clear;
215215
try
216216
Data := TFileIO.ReadAllBytes(FileName);
217-
TCodeImporter.ImportData(fUserInfo, fSnippetInfoList, Data);
217+
TCodeImporter.ImportData(fSnippetInfoList, Data);
218218
except
219219
on E: EStreamError do
220220
raise ECodeImportMgr.Create(E);

0 commit comments

Comments
 (0)