8#include <boost/python/class.hpp>
9#include <boost/python/default_call_policies.hpp>
10#include <boost/python/enum.hpp>
11#include <boost/python/list.hpp>
12#include <boost/python/make_constructor.hpp>
24CompositeValidator *createCompositeValidator(
const boost::python::list &validators,
const CompositeRelation &relation) {
27 const bpl::ssize_t nitems = bpl::len(validators);
28 for (bpl::ssize_t i = 0; i < nitems; ++i) {
30 composite->add(bpl::extract<IValidator_sptr>(validators[i]));
31 }
catch (boost::python::error_already_set &) {
33 os <<
"Cannot extract Validator from element " << i;
34 throw std::invalid_argument(os.str());
42 enum_<CompositeRelation>(
"CompositeRelation").value(
"AND", CompositeRelation::AND).value(
"OR", CompositeRelation::OR);
44 class_<CompositeValidator, bases<IValidator>, boost::noncopyable>(
"CompositeValidator")
45 .def(
"__init__", make_constructor(&createCompositeValidator, default_call_policies(),
46 (arg(
"validators"), arg(
"relation") = CompositeRelation::AND)))
48 (arg(
"self"), arg(
"other")),
"Add another validator to the list");
void export_CompositeValidator()
void add()
Add a validator based on a template type.
IValidator is the basic interface for all validators for properties.
CompositeRelation
A composite validator that can combine any 2+ arbitrary validators together.
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.