How to write a tree structure to disk (VBA with no serialisation)
So I am using VBA (not by choice) to do some fairly non trivial programming and finding it a nightmare. Normally I'd just use serialisation to dump the class/object to disk then read it back in but I cannot do that here, not unless I write my own serialisation function, which is basically what I am asking how to do here.
I have a class
[Node.cls]
Public pictureName As String
Public tagGroup As String
' Collection of Node objects
Public children As New Collection
Public isOverViewScreen As Boolean
' Collections of strings
Public overViewScreenWellNames As New Collection
Public overViewScreenWellType As New Collection
Public overViewScreenOpenPictureName As New Collection
which i开发者_JAVA技巧s basically a node in a tree structure, eg a node with a collection of child nodes which build a tree.
What would be the best way to dump this structure to a flat file and read it in, any hints?
I was thinking I could add a parent link to all of my nodes and just recursively visit the tree in order writing them to a txt file, then read it back in the same way, probably not the most efficient but I have a nice quad core machine here. Is there any simpler or more efficient way to do this?
Wrote a function that recursively visits the tree and dumps the 'nodes' to a flat text file, I then wrote a function that reads each node back in via a state machine that reads the node line by line recreating the tree, took too long, but it seems to work fine.
Thanks everyone who read it anyway.
精彩评论