void Bank::save( const string& p, bool saveCurrent, bool backup ) { string path = p.empty() ? path_ : p; if( path.empty() ) return; if( saveCurrent ) saveCurrentProgram(); if( backup ) makeBackup(); Document doc; Declaration* declaration = new Declaration( "1.0", "", "no" ); doc.LinkEndChild( declaration ); Element* bankElement = new Element( "Bank" ); bankElement->SetAttribute( "name", name_ ); bankElement->SetAttribute( "program", programNum_ ); for( UINT32 i=0; i<size(); i++ ) { Program* program = at( i ); if( program->empty() == false ) { Element* programElement = writeProgram( program ); bankElement->LinkEndChild( programElement ); } } doc.LinkEndChild( bankElement ); try { doc.SaveFile( path ); path_ = path; } catch( const exception& e ) { TRACE( e.what() ); } doc.Clear(); }