crossbario / autobahn-cpp

WAMP for C++ in Boost/Asio
https://crossbar.io/autobahn
Boost Software License 1.0
251 stars 104 forks source link

Wrapping, and conversion utilities #38

Closed mgmarino closed 8 years ago

mgmarino commented 9 years ago

I'm opening this issue more as a discussion thread covering the following topics:

  1. Conversion of types to anyvec/anymap.
  2. Wrapping external library calls to fit the RPC paradigm. (e.g. any function( const anyvec&, const anymap& ))

If this have been discussed elsewhere, I apologize! (I couldn't find it. :-) )

I believe that many users of this package will be writing code to wrap c/c++ libraries and enable communication/RPC with web servers, python, etc. As such, I think it would make sense to add some utilities to help facilitate this. I am somewhat volunteering to help as well as asking for some input as to what others think is best.

What I have already done (all of the following is done in boost-based template headers):

  1. Written templated conversion of basic, array, and sequence (struct) types to anyvec and anymap. This allows, e.g., the transparent conversion of C/C++ structs to anyvec/anymap (and hence JSON) objects. This requires the boost::fusion headers.
  2. I have written some fairly general wrapping templates to ease wrapping external library calls to the Autobahn RPC call.
  3. I have made some steps towards trying to improve the current serialization/conversion system, though this is not final. In particular, I would envision something like what happens in boost::python, where users can also register how types can be converted from and to python. In this case, it would support the conversion from and to anyvec and anymap (and the supported 'basic' types).

I would be happy to hear comments and to show what I already have. I have been writing this for our own usage in-house, but I've been trying to make it general enough to be more useful.

Thanks.

davidchappelle commented 9 years ago

In the c++ wamp router that I am working on we opted to not use boost::any as a variant type. Instead we simply use msgpack::object (msgpack-c) to represent parameters. The library provides a convenience type of msgpack::tuple which is equivalent to anyvec. I am sure that anymap could also be easily represented in msgpack.

KrishnaPG commented 8 years ago

Wondering the state of this. Has this been ported into Autobahn?

oberstet commented 8 years ago

Yes, @davidchappelle has done most of the work here, `boost::any`` and so on is no more, see eg here and here ..

oberstet commented 8 years ago

I am closing this for now .. if @mgmarino doesn't see his issues/questions addressed, please feel free to reopen ..