fixed exceptions and typeDesc for constraints

This commit is contained in:
mes5k 2005-01-07 04:00:48 +00:00
parent b6b87d65f7
commit f08a70dbd7
2 changed files with 12 additions and 6 deletions

View File

@ -363,6 +363,7 @@ MultiArg<T>::MultiArg(const std::string& flag,
Constraint<T>* constraint, Constraint<T>* constraint,
Visitor* v) Visitor* v)
: Arg( flag, name, desc, req, true, v ), : Arg( flag, name, desc, req, true, v ),
_typeDesc( constraint->shortID() ),
_constraint( constraint ) _constraint( constraint )
{ } { }
@ -375,6 +376,7 @@ MultiArg<T>::MultiArg(const std::string& flag,
CmdLineInterface& parser, CmdLineInterface& parser,
Visitor* v) Visitor* v)
: Arg( flag, name, desc, req, true, v ), : Arg( flag, name, desc, req, true, v ),
_typeDesc( constraint->shortID() ),
_constraint( constraint ) _constraint( constraint )
{ {
parser.add( this ); parser.add( this );
@ -484,7 +486,8 @@ void MultiArg<T>::_extractValue( const std::string& val )
if ( ! _constraint->check( _values.back() ) ) if ( ! _constraint->check( _values.back() ) )
throw( CmdLineParseException( "Value '" + val + throw( CmdLineParseException( "Value '" + val +
"' does not meet constraint: " + "' does not meet constraint: " +
_constraint->description() ) ); _constraint->description(),
toString() ) );
} }

View File

@ -402,6 +402,7 @@ ValueArg<T>::ValueArg(const std::string& flag,
Visitor* v) Visitor* v)
: Arg(flag, name, desc, req, true, v), : Arg(flag, name, desc, req, true, v),
_value( val ), _value( val ),
_typeDesc( constraint->shortID() ),
_constraint( constraint ) _constraint( constraint )
{ } { }
@ -415,8 +416,9 @@ ValueArg<T>::ValueArg(const std::string& flag,
CmdLineInterface& parser, CmdLineInterface& parser,
Visitor* v) Visitor* v)
: Arg(flag, name, desc, req, true, v), : Arg(flag, name, desc, req, true, v),
_value( val ), _value( val ),
_constraint( constraint ) _typeDesc( constraint->shortID() ),
_constraint( constraint )
{ {
parser.add( this ); parser.add( this );
} }
@ -481,7 +483,7 @@ bool ValueArg<T>::processArg(int *i, std::vector<std::string>& args)
template<class T> template<class T>
std::string ValueArg<T>::shortID(const std::string& val) const std::string ValueArg<T>::shortID(const std::string& val) const
{ {
return Arg::shortID( _typeDesc ); return Arg::shortID( _typeDesc );
} }
/** /**
@ -490,7 +492,7 @@ std::string ValueArg<T>::shortID(const std::string& val) const
template<class T> template<class T>
std::string ValueArg<T>::longID(const std::string& val) const std::string ValueArg<T>::longID(const std::string& val) const
{ {
return Arg::longID( _typeDesc ); return Arg::longID( _typeDesc );
} }
template<class T> template<class T>
@ -513,7 +515,8 @@ void ValueArg<T>::_extractValue( const std::string& val )
if ( ! _constraint->check( _value ) ) if ( ! _constraint->check( _value ) )
throw( CmdLineParseException( "Value '" + val + throw( CmdLineParseException( "Value '" + val +
"' does not meet constraint: " + "' does not meet constraint: " +
_constraint->description() ) ); _constraint->description(),
toString() ) );
} }
} // namespace TCLAP } // namespace TCLAP