bool Arguments::Construct(char * data, int size) { String::Construct(data,size); StringParser parser; parser.Assign(*this); bool error = false; while ( !error && !parser.Eof() ) { if (parser.Is('-')) { parser.Next(); if (parser.Is('-')) parser.Next(); Path * path = new Path(); Append(path); if (parser.ParseWord()) { if (parser.Eof() || parser.SkipWhitespace()) { Path * name = new Path(); Path * value = new Path(); path->Append(name); path->Append(value); name->Assign(parser.Token); if (!parser.Is('-')) { parser.Mark(); while (!parser.Eof() && !parser.IsWhitespace()) parser.Next(); parser.Trap(); if (!parser.Token.IsEmpty()) value->Assign(parser.Token); } } else { error = true; } } else { error = true; } } else { parser.Mark(); while (!parser.Eof() && !parser.IsWhitespace()) parser.Next(); parser.Trap(); if (!parser.Token.IsEmpty()) { Path * path = new Path(); path->Assign(parser.Token); Append(path); } } if ( !error && !parser.Eof() && !parser.SkipWhitespace() && !parser.Is('-')) error = true; } if (error) { Release(false); OutputError("Arguments::Construct - Invalid token in arguments at column %d.",parser.Column()); return false; } else { return true; } }
bool Configuration::Load(char * data, int size) { TextFileStream textFileStream(data,size); TokenizerStream streamIterator(textFileStream); streamIterator.Separators.Append(new Path("\r")); streamIterator.Separators.Append(new Path("\n")); System::Section * section = 0; Iterand< Reason::Structure::Mapped<String,String> > iterand; bool continued=false; for (streamIterator.Forward();streamIterator.Has();streamIterator.Move()) { StringParser parser; parser.Assign(*streamIterator()); parser.ParseWhitespace(); if (continued) { parser.Mark(); while (!parser.Eof() && !parser.Is("\\")) parser.Next(); parser.Trap(); continued = (parser.Is("\\"))?true:false; iterand().Value().Append(parser.Token); } else if (parser.Is("#") || parser.Is("!") || parser.Is(";") || parser.Is("//")) { } else if (parser.Is("[")) { parser.Mark(); while (!parser.Eof() && !parser.Is("]")) parser.Next(); parser.Trap(); if (parser.Is("]")) { if (section) Sections.Append(section); section = new System::Section(); section->Name = parser.Token; parser.Next(); } else { OutputError("Properties::Load","Missing \"]\" after section name, line %d column %d\n",parser.Line(),parser.Column()); } } else if (!parser.Eof()) { parser.Mark(); while (!parser.Eof() && !parser.IsWhitespace() && !parser.Is("=")) parser.Next(); parser.Trap(); Substring name(parser.Token); if (parser.Is("=")) { parser.Next(); parser.Mark(); while (!parser.Eof() && !parser.Is("\\")) parser.Next(); parser.Trap(); continued = (parser.Is("\\"))?true:false; Substring value(parser.Token); if (!section) { section = new System::Section(); } iterand = section->Properties.Insert(name,value); } else { OutputError("Configuration::Load","Missing \"=\" after attribute name, line %d column %d\n",parser.Line(),parser.Column()); } } } if (section) Sections.Append(section); return true; }