Changeset 125 in SHVCSoftware for trunk/source/Lib/TAppCommon
- Timestamp:
- 16 Apr 2013, 06:39:31 (12 years ago)
- Location:
- trunk/source/Lib/TAppCommon
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TAppCommon/program_options_lite.cpp
r2 r125 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 2, ITU/ISO/IEC6 * Copyright (c) 2010-2013, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * -
trunk/source/Lib/TAppCommon/program_options_lite.h
r2 r125 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 2, ITU/ISO/IEC6 * Copyright (c) 2010-2013, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 36 36 #include <list> 37 37 #include <map> 38 #include "TLibCommon/TypeDef.h"39 38 40 39 //! \ingroup TAppCommon … … 48 47 struct Options; 49 48 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 50 63 void doHelp(std::ostream& out, Options& opts, unsigned columns = 80); 51 64 unsigned parseGNU(Options& opts, unsigned argc, const char* argv[]); … … 103 116 { 104 117 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 } 106 127 } 107 128 … … 208 229 if(pos != std::string::npos) 209 230 cNameBuffer.resize(pos); 210 231 211 232 parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescriptionBuffer )); 212 233 }
Note: See TracChangeset for help on using the changeset viewer.