Пример #1
0
void ModelManager :: AddModelFromFile( const string & fname, ModelMode mm ) {
	ALib::XMLTreeParser parser;
	std::auto_ptr <ALib::XMLElement> e ( parser.ParseFile( fname ) );
	if ( e.get() == 0 ) {
		throw Exception( "XML parser error: " + parser.ErrorMsg()
							+ " at line " + ALib::Str( parser.ErrorLine()) );
	}

	if ( e.get()->Name() != DMKROOT_TAG ) {
		throw Exception( "Expected tag " + ALib::SQuote( DMKROOT_TAG )
							+ " but found "
							+ ALib::SQuote( e.get()->Name()));
	}

	int incs = 0;
	while( ProcessInclude( e.get() ) ) {
		if ( ++incs > MAX_INC ) {
			throw Exception( "Too many includes" );
		}
	}

	ModelBuilder builder;
	std::auto_ptr <Model> m( builder.Build( e.get() ) );

	AddModel( m.get(), mm );
	m.release();
}
Пример #2
0
void ModelManager :: ReplaceFromFile( ALib::XMLElement * e,
										const string & fname ) {
//	ALib::XMLElement * p = new ALib::XMLElement( "counter" );
//	e->Replace( p );
	ALib::XMLTreeParser parser;
	ALib::XMLElement * p = parser.ParseFile( fname );
	if ( p == 0 ) {
		throw Exception( "XML parser error: during include " + parser.ErrorMsg() );
	}
	e->Replace( p );
}
Пример #3
0
int ReadXMLCommand :: Execute( ALib::CommandLine & cmd ) {

	IOManager io( cmd );

	for ( unsigned int i = 0; i < io.InStreamCount(); i++ ) {
		ALib::XMLTreeParser tp;
		std::auto_ptr<ALib::XMLElement>	safe_root(
					tp.ParseStream( io.In(i) )
		);

		ALib::XMLElement * root = safe_root.get();

		if ( root == 0 ) {
			CSVTHROW( "XML error '" << tp.ErrorMsg()
						<< "' in " << io.InFileName( i )
						<< " at line " << tp.ErrorLine()
			);
		}

		TableToCSV( root, io, i );
	}

	return 0;
}