version // NODE
{
number 8.2
}
morphBinaryFile grizzly.pmd // NODE
figureResFile Grizzly.obj // NODE
actor BODY:3 // NODE
{
}
actor BODY:3 // NODE
{
name BODY
on
bend 1
dynamicsLock 0
hidden 0
addToMenu 1
castsShadow 1
includeInDepthCue 1
useZBuffer 1
parent UNIVERSE
creaseAngle 80
channels // NODE
{
groups // NODE
{
groupNode Transform // NODE
{
parmNode Scale
parmNode xScale
parmNode yScale
parmNode zScale
parmNode Twist
parmNode Bend
parmNode Side-Side
parmNode xTran
parmNode yTran
parmNode zTran
}
groupNode Other // NODE
{
parmNode Roar
}
}
}
}
Help needed for parsing algorithm
I'm trying to find a clever way to parse the following text file (well, a part of it) so that it would be organized in nodes (i'd like to end up with a c# treeview).
As you can see each node section is included in a {} block. But since the file structure expands to several levels of recursion, I failed to find a way to build some code that would, for example, create an array where, for each text line, would store the parent node.
I'm really stuck so any help is greatly appreciated.
Recursion is one easy way of solving your problem...
[Edited by - sirGustav on April 14, 2010 12:03:43 AM]
void Node::read(){ string line = readline().trim(); if( line == "}" ) return; if( line == "{" ) { Node node = new Node(this); // set parent node.read(); // recursive call add(node); } else { add(new Attribute(line)); }}
[Edited by - sirGustav on April 14, 2010 12:03:43 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement