Boost logo

Boost Users :

Subject: [Boost-users] [program_options] Custom Validation for a String Value
From: Ryan (boost_at_[hidden])
Date: 2013-06-19 17:59:15


Hello,

Is there a way of validating a string type program option before it's
stored in the map?

add_options()
  ("arg" , value<std::string>()->default_value("Hi"), "Greeting");

boost::regex pattern("^(Hello | Good Morning | Hi)$");

I've used custom validation for types that program options doesn't
recognize. I'd like to check the string before it's stored in the map like
the custom validation does for unknown types. I'd rather the error be
caught early. Is there a way to use the regex against the program option?

Ryan



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