I am reading in a file format that has "layers" and can have layers with in layers. Nested layers. Only certain types of layers can be nested and I have the ability to check for that during my repeat when reading in the layers.
Layers are enclosed with "{ }" brackets.
I have a great function that iterates and keeps track of nested layers and converting to XML and maintaining the nesting for display purposes in a field. I am also placing the layers inside an array by counting the number of layers and indexing, but... having trouble figuring out how to handle nested layers inside the array.
As you can see below there can be any number of sub layers nested very very deep. No limit to the nesting. I need a way to store that info in the array so I can retrieve it later for writing the file back out to either XML or to the original file format. I already have the file converted perfectly to XML with nested layers and it works great. However I found the array handling much easier to code for processing and only use the XML for display purposes in a field. One of the problems is that the XML is WAY to big to include all the data so I have to put in only the top level items and break it into smaller chunks or it chokes RR and crashes.
There are 4 "layer types" that are groups. When processing the layer data I "know" what the layer type is so I can trap that info. I just don't know the best way to store this data. The layer portions of the file format is 90% of the data. It can be HUGE so I need to avoid using any line counting for repeat loops.
To make things "easier" sub layers of group layers ALWAYS follow the group layer and are indented with tabs. Each set of sub layers is indented with extra tabs.
Code: Select all
{
Layer 1 --group type layer
lots and lots of text for each layer inside brackets
{
sub Layer 1
sub layer of Layer 1
}
{
sub Layer 2 -- sub layer of Layer 1 -- also a group type layer
{
sub Layer 1-- sub layer of sub Layer 2
}
{
sub Layer 2 -- sub layer of sub Layer 2
}
}
}
{
Layer 2
lots and lots of text for each layer inside brackets
}
{
Layer 3
lots and lots of text for each layer inside brackets
}
Code: Select all
layers[1 ]-- this is a group layer and includes any number of following layers "inside" it.
layers[2] -- sub layer of Layer 1
layers[3] -- this is a sub layer of Layer 1 and also has sub layers
layers[4] -- this is a sub layer of Layer 3 which is a sub layer of Layer 1 above it.
layers[5] -- this is a sub layer of the above layer which is a sub layer of the layer above it.
...