bool ReadDataNode (DataItem item, List<string> lines, int lastLine, string prefix, ref int lineNum)
{
string s = lines [lineNum].Trim (' ','\t');
if (s.Length == 0) {
lineNum++;
return true;
}
// Check if the line belongs to the current item
if (prefix.Length > 0) {
if (!s.StartsWith (prefix + "."))
return false;
s = s.Substring (prefix.Length + 1);
} else {
if (s.StartsWith ("$"))
return false;
}
int i = s.IndexOf ('=');
if (i == -1) {
lineNum++;
return true;
}
string name = s.Substring (0, i).Trim (' ','\t');
if (name.Length == 0) {
lineNum++;
return true;
}
string value = s.Substring (i+1).Trim (' ','\t');
if (value.StartsWith ("$")) {
// New item
DataItem child = new DataItem ();
child.Name = name;
lineNum++;
while (lineNum <= lastLine) {
if (!ReadDataNode (child, lines, lastLine, value, ref lineNum))
break;
}
item.ItemData.Add (child);
}
else {
value = DecodeString (value);
DataValue val = new DataValue (name, value);
item.ItemData.Add (val);
lineNum++;
}
return true;
}