internal void RecursiveLoadFromBuffer(KVTextReader kvr) { bool wasQuoted; bool wasConditional; while (true) { // bool bAccepted = true; // get the key name var name = kvr.ReadToken(out wasQuoted, out wasConditional); if (name is null || name.Length == 0) { throw new InvalidDataException("RecursiveLoadFromBuffer: got EOF or empty keyname"); } if (name.StartsWith("}") && !wasQuoted) // top level closed, stop reading { break; } KeyValue dat = new KeyValue(name); dat.Children = new List <KeyValue>(); this.Children.Add(dat); // get the value string?value = kvr.ReadToken(out wasQuoted, out wasConditional); if (wasConditional && value != null) { // bAccepted = ( value == "[$WIN32]" ); value = kvr.ReadToken(out wasQuoted, out wasConditional); } if (value == null) { throw new Exception("RecursiveLoadFromBuffer: got NULL key"); } if (value.StartsWith("}") && !wasQuoted) { throw new Exception("RecursiveLoadFromBuffer: got } in key"); } if (value.StartsWith("{") && !wasQuoted) { dat.RecursiveLoadFromBuffer(kvr); } else { if (wasConditional) { throw new Exception("RecursiveLoadFromBuffer: got conditional between key and value"); } dat.Value = value; // blahconditionalsdontcare } } }
internal void RecursiveLoadFromBuffer( KVTextReader kvr ) { bool wasQuoted; bool wasConditional; while ( true ) { bool bAccepted = true; // get the key name string name = kvr.ReadToken( out wasQuoted, out wasConditional ); if ( string.IsNullOrEmpty( name ) ) { throw new Exception( "RecursiveLoadFromBuffer: got EOF or empty keyname" ); } if ( name.StartsWith( "}" ) && !wasQuoted ) // top level closed, stop reading break; KeyValue dat = new KeyValue( name ); dat.Children = new List<KeyValue>(); this.Children.Add( dat ); // get the value string value = kvr.ReadToken( out wasQuoted, out wasConditional ); if ( wasConditional && value != null ) { bAccepted = ( value == "[$WIN32]" ); value = kvr.ReadToken( out wasQuoted, out wasConditional ); } if ( value == null ) throw new Exception( "RecursiveLoadFromBuffer: got NULL key" ); if ( value.StartsWith( "}" ) && !wasQuoted ) throw new Exception( "RecursiveLoadFromBuffer: got } in key" ); if ( value.StartsWith( "{" ) && !wasQuoted ) { dat.RecursiveLoadFromBuffer( kvr ); } else { if ( wasConditional ) { throw new Exception( "RecursiveLoadFromBuffer: got conditional between key and value" ); } dat.Value = value; // blahconditionalsdontcare } } }