On Fr, 2012-01-27 at 14:55 +0100, Mikel Astiz wrote:
> +template <class V1, class V2 = append_visitor_dummy_type> struct 
> append_visitor : public boost::static_visitor<>
> +{
> +    GVariantBuilder &builder;
> +    append_visitor(GVariantBuilder &b) : builder(b) {}
> +    void operator()(const V1 &v) const
> +    {
> +        dbus_traits<V1>::append(builder, v);
> +    }
> +    void operator()(const V2 &v) const
> +    {
> +        dbus_traits<V2>::append(builder, v);
> +    }
> +}; 

I think this could be simplified to

struct append_visitor : public boost::static_visitor<>
{
    GVariantBuilder &builder;
    append_visitor(GVariantBuilder &b) : builder(b) {}
    template <class V> void operator()(const V &v) const
    {
        dbus_traits<V>::append(builder, v);
    }
};

I'm wondering how it works, though. In libdbus, the iterator for the
variant must be opened with the type of the *value* in the variant. Here
the GVariantBuilder is opened with G_VARIANT_TYPE("v"), the type of the
*variant* itself:

    static std::string getType() { return "v"; }
    ...
    static void append(GVariantBuilder &builder, const boost::variant<V> &value)
    {
        g_variant_builder_open(&builder, G_VARIANT_TYPE(getType().c_str()));
        boost::apply_visitor(append_visitor<V>(builder), value);
        g_variant_builder_close(&builder);
    }

I checked with dbus-monitor, the resulting D-Bus message has "variant
string" as type of value, as intended.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.


_______________________________________________
SyncEvolution mailing list
[email protected]
http://lists.syncevolution.org/listinfo/syncevolution

Reply via email to