Hi
I want to build a markdown/groff/troff renderer with a little bit of custom functionality.
I do not like HTML/Javascript, So I am trying to use the FPC graphics stack.
I have this in a file called
TRenderObjects.pas.
unit TRenderObjects;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils;
type
Section = class
text : Array of String;
imgSrc : Array of String;
oper : Array of String;
textFont : String;
textColor : Array of Integer;
textFontVariant : (Bold, Italic, Underline, Strikethrough);
isRendered : Boolean;
end;
ImageBlob = class
// border
borderWidth : Integer;
boderColor : Array of Integer;
end;
implementation
end.
In a second file called
TDocument.pas, i want to have
unit TDocument;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, TRenderObjects;
type
markedDocument = class
// Sections : Array of TRenderObjects.Section;
SectionNodePTR : ^NodeStruct;
NodeStruct : packed record // writing = instead of : in this line and the previous fails with message : expected = found
rendObj : T;
ID : Integer;
Parent : SectionNodePTR;
Children : Array of SectionNodePTR;
end;
public :
var
DocumentTree : NodeStruct;
procedure AppendChild (ChildObj : T);
end;
implementation
end.
I want to define a template of a tree in the class, and then use the append procedure to add either TRenderObjects.Section or TRenderObjects.ImageBlob. That is why I used T as a template Type. But this fails with:
Projekt kompilieren, Ziel: notebook: Exit code 1, Fehler: 7
tdocument.pas(15,19) Error: Identifier not found "T"
tdocument.pas(15,20) Error: Error in type definition
tdocument.pas(17,19) Error: Identifier not found "SectionNodePTR"
tdocument.pas(17,33) Error: Error in type definition
tdocument.pas(18,28) Error: Identifier not found "SectionNodePTR"
tdocument.pas(18,42) Error: Error in type definition
tdocument.pas(21,12) Fatal: Syntax error, "identifier" expected but ":" found
Please let me know how I can create a tree with unspecified types inside a class, initialize it, and then use an overloaded append or delete procedure to modify the tree. Thank you.