|
Boost Users : |
From: Sean Huang (huangsean_at_[hidden])
Date: 2006-03-30 09:53:01
----- Original Message -----
From: "Peng Yu" <pengyu.ut_at_[hidden]>
>I tried to supply a hex number to an unsigned long integer. But it fails.
>
> ("code", po::value<unsigned long>(), "Via pattern code")
>
> Error message:
> in option 'code': invalid option value '0x5A'
>
> Could you please let me if it is possible to input a hex form integer in
> the command line?
>
Well, you can but it needs additional work (I am not the library author and
cannot say if there is a better way). One way is to define your own validate
overloads in boost::program_options:
namespace boost {
namespace program_options {
template< class CharType, class Traits > void validate( boost::any& v, const
std::vector< std::basic_string< CharType, Traits> >& xs, unsigned long*,
long )
{
// code to read the value from xs
// Many iostream implementations support the auto-radix selection by
clearing the basefield. But it is not portable
}
}
}
HTH,
Sean
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net