Archived
This forum has been archived. Please start a new discussion on GitHub.
How to use user defined C++ types in Slice
#ifndef HELLO_ICE #define HELLO_ICE [["cpp:include:../inc/GridData.h"]] // in GridData.h // struct GridDatum { ... }; // typedef std::deque<GridDatum> GridData; module SRR { interface SRRData { idempotent void sendGridData(GridData data); idempotent void sendGridPoint(float east, float south, int id); void shutdown(); }; }; #endif
I am trying to use my own defined types. The above Slice snippet illustrates what I am trying to do. The few comment lines indicate what is in GridData.h where my types are defined. I tried the a lot of variations on the "cpp:type] metadata without success.
How do I use my own data types?
Rud
0
Comments
-
Hi Rud,
C++ does not have serializable types like Java and C#, so you need to tell Ice how to serialize the C++ objects you want to transmit as sequence<byte> (or sequence of some other type).
This is done through StreamHelper templates, as described in C++ Mapping for Sequences - Ice 3.5 - ZeroC.
For a complete working example, I recommend the Protocol Buffers lab release: ZeroC Labs: Protocol Buffers. And then replace the PB by your own type or type-family.
Cheers,
Bernard0