Using LEMON_ASSERT instead of LogicError()
authoralpar
Tue, 13 Mar 2007 15:35:56 +0000
changeset 2407fb2052c94ebd
parent 2406 0ffc78641b34
child 2408 467ca6d16556
Using LEMON_ASSERT instead of LogicError()
lemon/arg_parser.h
     1.1 --- a/lemon/arg_parser.h	Tue Mar 13 12:33:40 2007 +0000
     1.2 +++ b/lemon/arg_parser.h	Tue Mar 13 15:35:56 2007 +0000
     1.3 @@ -310,37 +310,41 @@
     1.4        operator bool() 
     1.5        {
     1.6  	Opts::iterator i = _parser._opts.find(_name);
     1.7 -	if(i==_parser._opts.end()) throw LogicError();
     1.8 -	else if(i->second.type!=ArgParser::BOOL)
     1.9 -	  throw LogicError();
    1.10 -	else return *(i->second.bool_p);
    1.11 +	LEMON_ASSERT(i==_parser._opts.end(),
    1.12 +		     std::string()+"Unkown option: '"+_name+"'");
    1.13 +	LEMON_ASSERT(i->second.type!=ArgParser::BOOL,
    1.14 +		     std::string()+"'"+_name+"' is a bool option");
    1.15 +	return *(i->second.bool_p);
    1.16        }
    1.17        ///\e
    1.18        operator std::string()
    1.19        {
    1.20  	Opts::iterator i = _parser._opts.find(_name);
    1.21 -	if(i==_parser._opts.end()) throw LogicError();
    1.22 -	else if(i->second.type!=ArgParser::STRING)
    1.23 -	  throw LogicError();
    1.24 -	else return *(i->second.string_p);
    1.25 +	LEMON_ASSERT(i==_parser._opts.end(),
    1.26 +		     std::string()+"Unkown option: '"+_name+"'");
    1.27 +	LEMON_ASSERT(i->second.type!=ArgParser::STRING,
    1.28 +		     std::string()+"'"+_name+"' is a string option");
    1.29 +	return *(i->second.string_p);
    1.30        }
    1.31        ///\e
    1.32        operator double() 
    1.33        {
    1.34  	Opts::iterator i = _parser._opts.find(_name);
    1.35 -	if(i==_parser._opts.end()) throw LogicError();
    1.36 -	else if(i->second.type!=ArgParser::DOUBLE) 
    1.37 -	  throw LogicError();
    1.38 -	else return *(i->second.double_p);
    1.39 +	LEMON_ASSERT(i==_parser._opts.end(),
    1.40 +		     std::string()+"Unkown option: '"+_name+"'");
    1.41 +	LEMON_ASSERT(i->second.type!=ArgParser::DOUBLE,
    1.42 +		     std::string()+"'"+_name+"' is a floating point option");
    1.43 +	return *(i->second.double_p);
    1.44        }
    1.45        ///\e
    1.46        operator int() 
    1.47        {
    1.48  	Opts::iterator i = _parser._opts.find(_name);
    1.49 -	if(i==_parser._opts.end()) throw LogicError();
    1.50 -	else if(i->second.type!=ArgParser::INTEGER)
    1.51 -	  throw LogicError();
    1.52 -	else return *(i->second.int_p);
    1.53 +	LEMON_ASSERT(i==_parser._opts.end(),
    1.54 +		     std::string()+"Unkown option: '"+_name+"'");
    1.55 +	LEMON_ASSERT(i->second.type!=ArgParser::INTEGER,
    1.56 +		     std::string()+"'"+_name+"' is an integer option");
    1.57 +	return *(i->second.int_p);
    1.58        }
    1.59  
    1.60      };