For the first case,
if I use a Variant::Map, after I received and decoded the message to get my 
struct, how could I extract Variant::List and Variant::Map correctly?

Example:
//sender
                Message message;

                Variant::Map content;
                content["id"] = 987654321; //int
                content["name"] = "Widget";//string
                content["percent"] = 0.99; //double

                Variant::List colours;
                colours.push_back(Variant("red"));
                colours.push_back(Variant("green"));
                colours.push_back(Variant("white"));
                content["colours"] = colours;

                Variant::Map dimensions;
                dimensions["length"] = 10.2;
                dimensions["width"] = 5.1;
                dimensions["depth"] = 2.0;
                content["dimensions"]= dimensions;              

                encode(content, message);

                sender.send(message, true);
                

                //receiver
                Message message_receive = receiver.fetch(Duration::SECOND * 1);
                
                Variant::Map content1;
                decode(message_receive, content1);
                
                //extract contents from received message
                int identification = content1["id"];
                string name1 = content1["name"];
                double percent1 = content1["percent"];

                ???Variant::List colours_received = content["colours"]; ??? (Is 
this right?)
                ???Variant::Map dimensions_received = content["dimensions"]; ???
                

Thanks,


Joe Ly

________________________________________
From: Andy Goldstein [[email protected]]
Sent: Thursday, October 18, 2012 3:38 PM
To: [email protected]
Subject: Re: Try to send a user-defined struct using C++ QPID

Hi Joe,

You have a couple of tried & true options.  You could manually copy the data 
from the struct into a Variant::Map and encode that into a Message.  You could 
use a library such as Google Protocol Buffers to both store the data in memory 
(i.e. instead of using a struct you'd use a protobuf generated class) and for 
transmission across the wire (since it serializes to/from a string).

Hope this helps,
Andy

On Oct 18, 2012, at 3:33 PM, Joe Ly wrote:

> Hi,
>
> Anyone knows how I could send a C/C++ user-defined struct that encodes into 
> qpid messages?
>
> For example, my struct is defined as
>
> struct a {
>      int j;
>      float k;
>      float r[29];
> } a;
>
>
> Thanks,
>
>
> Joe Ly
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to