Reputation: 21
I am parsing text files and populating a TVirtualStringTree with Keywords which is used to navigate the text files. I like some advice on structuring the database.
I have 2 arrays of records which hold Level 0 and level 1 data which populates the corresponding levels in the Tree. The text file can reference other text files, these need to be similarly parsed and added into the Tree. This file nesting can continue to any depth.
Level 0 records hold child count and keys into Level 1 records. Image shows top file referencing ADC.inc which references ADCdefs.inc all of which can be expanded into the same tree.
In order to parse the nested files the parser needs to be recursive.
I have created a class holding the Level0 and Level1 data records and its heirachical order for each text file I encounter and hold these classes in an object list. I haven't yet written the code for updating the Virtual String Tree.
Before I get too deep into this is there a better way of doing this.
Upvotes: 0
Views: 136
Reputation: 15548
What I believe you are looking for is a Trie data structure, but it can be as simple as a TStringList where each object associated with a string is another TStringList, or an Array where each item contains another array (along with other data). Or, you can use any other list that can contain objects/records that can hold more lists.
Upvotes: 0