Open
Description
Hi, another question: is it possible to conditially group a set of members in a binding trait, and if so, what's the syntax?
a bit stupid example because you could create another struct/class Turnus with its own binding instead:
struct test {
int m_id;
std::string m_turnusEinheit{}; //'E'=einmalig, 'D'=täglich, 'W'=wöchentlich, 'M'=monatlich
unsigned int m_turnusAnzahl{}; // abhängig von der Turnuseinheit auszuwerten, z.B. 2 = alle 2 Wochen/Monate
unsigned int m_turnusTag{}; //'W': 1-7 = Montag-Sonntag; 'M': 1-31 = der 1. des Monats, der 2. des Monats,..., der 31. des Monats
};
template<typename T, typename = void>
struct my_traits
: public tao::json::traits<T>
{};
template<>
struct my_traits<test>
: public tao::json::binding::object<
TAO_JSON_BIND_REQUIRED("id", &test::m_id),
// TODO: all three only if (!m_turnusEinheit.empty())
TAO_JSON_BIND_OPTIONAL("turnusEinheit", &test::m_turnusEinheit),
TAO_JSON_BIND_OPTIONAL("turnusAnzahl", &test::m_turnusAnzahl),
TAO_JSON_BIND_OPTIONAL("turnusTag", &test::m_turnusTag)
>
{};