Changeset 125 in SHVCSoftware for trunk/source/Lib/TAppCommon


Ignore:
Timestamp:
16 Apr 2013, 06:39:31 (12 years ago)
Author:
seregin
Message:

copy from HM-10.0-dev-SHM

Location:
trunk/source/Lib/TAppCommon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TAppCommon/program_options_lite.cpp

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • trunk/source/Lib/TAppCommon/program_options_lite.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3636#include <list>
    3737#include <map>
    38 #include "TLibCommon/TypeDef.h"
    3938
    4039//! \ingroup TAppCommon
     
    4847    struct Options;
    4948   
     49    struct ParseFailure : public std::exception
     50    {
     51      ParseFailure(std::string arg0, std::string val0) throw()
     52      : arg(arg0), val(val0)
     53      {}
     54
     55      ~ParseFailure() throw() {};
     56
     57      std::string arg;
     58      std::string val;
     59
     60      const char* what() const throw() { return "Option Parse Failure"; }
     61    };
     62
    5063    void doHelp(std::ostream& out, Options& opts, unsigned columns = 80);
    5164    unsigned parseGNU(Options& opts, unsigned argc, const char* argv[]);
     
    103116    {
    104117      std::istringstream arg_ss (arg,std::istringstream::in);
    105       arg_ss >> opt_storage;
     118      arg_ss.exceptions(std::ios::failbit);
     119      try
     120      {
     121        arg_ss >> opt_storage;
     122      }
     123      catch (...)
     124      {
     125        throw ParseFailure(opt_string, arg);
     126      }
    106127    }
    107128   
     
    208229          if(pos != std::string::npos)
    209230            cNameBuffer.resize(pos);
    210 
     231     
    211232          parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescriptionBuffer ));
    212233        }
Note: See TracChangeset for help on using the changeset viewer.