Changeset 10802


Ignore:
Timestamp:
05/24/11 17:46:30 (14 years ago)
Author:
tbretz
Message:
Simplified program options handling.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/chatclient.cc

    r10628 r10802  
    11#include <boost/filesystem.hpp>
    22
    3 #include "FACT.h"
    43#include "Configuration.h"
    54#include "ChatClient.h"
     
    8281        vm = conf.Parse(argc, argv);
    8382    }
    84     catch (std::exception &e)
     83#if BOOST_VERSION > 104000
     84    catch (po::multiple_occurrences &e)
    8585    {
    86 #if BOOST_VERSION > 104000
    87         po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e);
    88         if (MO)
    89             cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl;
    90         else
     86        cerr << "Program options invalid due to: " << e.what() << " of '" << e.get_option_name() << "'." << endl;
     87        return -1;
     88    }
    9189#endif
    92             cout << "Error: " << e.what() << endl;
    93         cout << endl;
    94 
     90    catch (exception& e)
     91    {
     92        cerr << "Program options invalid due to: " << e.what() << endl;
    9593        return -1;
    9694    }
    9795
    98     if (conf.HasPrint())
     96    if (conf.HasVersion() || conf.HasPrint())
    9997        return -1;
    100 
    101     if (conf.HasVersion())
    102     {
    103         FACT::PrintVersion(argv[0]);
    104         return -1;
    105     }
    10698
    10799    if (conf.HasHelp())
  • trunk/FACT++/src/chatserv.cc

    r10699 r10802  
    44
    55#include "Dim.h"
    6 #include "FACT.h"
    76#include "EventImp.h"
    87#include "WindowLog.h"
     
    8786    catch (po::multiple_occurrences &e)
    8887    {
    89         cout << "Error: " << e.what() << " of '" << e.get_option_name() << "' option." << endl;
    90         cout << endl;
     88        cerr << "Program options invalid due to: " << e.what() << " of '" << e.get_option_name() << "'." << endl;
    9189        return -1;
    9290    }
    9391#endif
    94     catch (std::exception &e)
     92    catch (exception& e)
    9593    {
    96         cout << "Error: " << e.what() << endl;
    97         cout << endl;
    98 
     94        cerr << "Program options invalid due to: " << e.what() << endl;
    9995        return -1;
    10096    }
    10197
    102     if (conf.HasPrint())
     98    if (conf.HasVersion() || conf.HasPrint())
    10399        return -1;
    104 
    105     if (conf.HasVersion())
    106     {
    107         FACT::PrintVersion(argv[0]);
    108         return -1;
    109     }
    110100
    111101    if (conf.HasHelp())
Note: See TracChangeset for help on using the changeset viewer.