|
Boost Users : |
Subject: Re: [Boost-users] [program_options] Custom validate for asio endpoints
From: Anthony Foglia (AFoglia_at_[hidden])
Date: 2009-10-29 10:20:40
Ryan McConnehey wrote:
> I'm trying to validate an ip address and port that is being passed in
> through the command line arguments. I could retrieve the string and do
> the validation outside program options. I thought it would be better to
> use the custom validate function shown in the documentation. I'm trying
> to retrieve the information as a boost::asio::ip::udp::endpoint. Even
> after creating the validate function the compiler is complaining that
> there is no user defined function or stream operator. I've include some
> code to show what I'm doing. Any help would be great.
>
[CommandLine class omitted]
>
> static void validate(boost::any & v, std::vector<std::string> const&
> values, boost::asio::ip::udp::endpoint * target_type, int) {
> CommandLine::validate(v, values);
> }
I've only tried custom validation once, a while ago, but when I did, I
put the validate function in the same namespace as the target type. It
wouldn't surprise me if program options uses ADL and that's actually a
requirement. So try putting validate in the boost::asio::ip::udp namespace.
-- Anthony Foglia Princeton Consultants (609) 987-8787 x233
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