bp -> open (OPT_BankName, B_WRITE);
bp -> open (OPT_BankName);
int main (int argc, char ** argv){  int exitcode = EXIT_SUCCESS;  long int cnts = 0;                  // messages seen  long int cnta = 0;                  // objects appended  long int cntd = 0;                  // objects deleted  long int cntr = 0;                  // objects replaced  Message_t msg;                      // current message  NCode_t ncode;                      // current NCode  char act;                           // action enumeration  ifstream msgfile;                   // the message file stream  BankSet_t bnks;                     // all the banks  UniversalSet_t objs;                // all the objects  Bank_t * bp;                        // current bank  Universal_t * op;                   // current object  //-- Parse the command line arguments  ParseArgs (argc, argv);  //-- Output the current time and bank directory  cerr << "START DATE: " << Date( ) << endl;  cerr << "Bank is: " << OPT_BankName << endl;  //-- BEGIN: MAIN EXCEPTION CATCH  try {    //-- If OPT_ForceCreate, blast away existing banks    if ( OPT_ForceCreate )      for ( BankSet_t::iterator i = bnks . begin( ); i != bnks . end( ); ++ i )        if ( i -> exists (OPT_BankName) )          {            i -> open (OPT_BankName, B_WRITE);            i -> destroy ( );          }    //-- Compress RED and SEQ if option is turned on    if ( OPT_Compress )      {        ((Read_t &)objs [Read_t::NCODE]) . compress( );        ((Sequence_t &)objs [Sequence_t::NCODE]) . compress( );      }    //-- Open the message file    msgfile . open (OPT_MessageName . c_str( ));    msgfile . seekg (0, ios::end);    ProgressDots_t dots (msgfile . tellg( ), 50);    msgfile . seekg (0, ios::beg);    if ( ! msgfile )      AMOS_THROW_IO ("Could not open message file " + OPT_MessageName);    cerr << "    0%                                            100%" << endl         << "AFG ";    //-- Read the message file    while ( msg . read (msgfile) )      {        cnts ++;        dots . update (msgfile . tellg( ));        ncode = msg . getMessageCode( );        if ( ! objs . exists (ncode) )          {            cerr << "ERROR: Unrecognized message type" << endl                 << "  unknown message type '" << Decode (ncode)                 << "' ignored" << endl;            exitcode = EXIT_FAILURE;            continue;          }        bp = & (bnks [ncode]);        op = & (objs [ncode]);        if ( op -> isFlagA( ) )          continue; // skip objects missing a bank        //-- Parse the message        try {          op -> readMessage (msg);        }        catch (const Exception_t & e) {          cerr << "ERROR: " << e . what( ) << endl               << "  could not parse '" << Decode (ncode)               << "' message with iid:"               << (msg . exists (F_IID) ? msg . getField (F_IID) : "NULL")               << ", message ignored" << endl;          exitcode = EXIT_FAILURE;          continue;        }        //-- Open the bank if necessary        try {          if ( ! bp -> isOpen( ) )            {              if ( ! bp -> exists (OPT_BankName) )                bp -> create (OPT_BankName, B_WRITE);              else                bp -> open (OPT_BankName, B_WRITE);            }        }        catch (const Exception_t & e) {          cerr << "ERROR: " << e . what( ) << endl               << "  could not open '" << Decode (ncode)               << "' bank, all messages ignored" << endl;          op -> setFlagA (true);          exitcode = EXIT_FAILURE;          continue;        }        //-- Get the message action code        act = msg . exists (F_ACTION) ? msg [F_ACTION] [0] : E_ADD;        //-- Perform the appropriate action on the bank        try {          switch (act)            {            case E_ADD:              //-- Append a new object to the bank              bp -> append (*op);              cnta ++;              break;            case E_DELETE:              //-- Flag an existing object for removal from the bank              if ( op -> getIID( ) != NULL_ID )                bp -> remove (op -> getIID( ));              else if ( ! op -> getEID( ) . empty( ) )                bp -> remove (op -> getEID( ) . c_str( ));              else                AMOS_THROW_ARGUMENT ("Cannot remove object w/o IID or EID");              cntd ++;              break;            case E_REPLACE:              //-- Replace an existing object in the bank              if ( op -> getIID( ) != NULL_ID )                bp -> replace (op -> getIID( ), *op);              else if ( ! op -> getEID( ) . empty( ) )                bp -> replace (op -> getEID( ) . c_str( ), *op);              else                AMOS_THROW_ARGUMENT ("Cannot replace object w/o IID or EID");              cntr ++;              break;            default:              AMOS_THROW_IO ((string)"Unrecognized action field " + act);            }        }        catch (const IOException_t & e) {          cerr << "ERROR: " << e . what( ) << endl               << "  could not commit '" << Decode (ncode)               << "' message with iid:"               << (msg . exists (F_IID) ? msg . getField (F_IID) : "NULL")               << " to bank, message ignored" << endl;          exitcode = EXIT_FAILURE;          continue;        }        catch (const ArgumentException_t & e) {          cerr << "ERROR: " << e . what( ) << endl               << "  ID conflict caused by '" << Decode (ncode)               << "' message with iid:"               << (msg . exists (F_IID) ? msg . getField (F_IID) : "NULL")               << ", message ignored" << endl;          exitcode = EXIT_FAILURE;          continue;        }      }    dots . end( );    bnks . closeAll( );  }  catch (const Exception_t & e) {    cerr << "FATAL: " << e . what( ) << endl         << "  there has been a fatal error, abort" << endl;    exitcode = EXIT_FAILURE;  }  //-- END: MAIN EXCEPTION CATCH  msgfile . close( );  //-- Output the end time  cerr << "Messages read: " << cnts << endl       << "Objects added: " << cnta << endl       << "Objects deleted: " << cntd << endl       << "Objects replaced: " << cntr << endl       << "END DATE:   " << Date( ) << endl;  return exitcode;}