Esempio n. 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();
}
Esempio n. 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 );
}