Return-Path: X-Original-To: apmail-qpid-users-archive@www.apache.org Delivered-To: apmail-qpid-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C47AC914A for ; Thu, 5 Apr 2012 02:40:17 +0000 (UTC) Received: (qmail 65027 invoked by uid 500); 5 Apr 2012 02:40:17 -0000 Delivered-To: apmail-qpid-users-archive@qpid.apache.org Received: (qmail 64843 invoked by uid 500); 5 Apr 2012 02:40:17 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 64822 invoked by uid 99); 5 Apr 2012 02:40:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2012 02:40:16 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of zhihua.che@gmail.com designates 209.85.210.50 as permitted sender) Received: from [209.85.210.50] (HELO mail-pz0-f50.google.com) (209.85.210.50) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2012 02:40:09 +0000 Received: by dakh32 with SMTP id h32so973291dak.23 for ; Wed, 04 Apr 2012 19:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=Kk7fvLjY0pAgMd7lkzGuOVEqfAdpaj5wGOQCjyzngUc=; b=Y7pzr+qvObJpoHi1yx6VmVFmTjF29yyKkrTEfnUaZ+BxDP8V/cSf6UrfpgY2FHqab9 zBTzGiNIRM45N757yUHc/LgRJbczXbGcaJsgQDvOi/Db0QnlVy8uHPLmmpesOeAcqvjT ZTBxkAlDazvm1CQ6lTT5FOoL6iv/1hOHlj2kczwwO1EFfqikLSyMY9Zqd/JVK2p4cI9R 7zSwxEcetfEAZFBvar1XDU011SgnS0J54R49iLUhzJiGOeA3HrhJKiABAj5E2M8bDFDd oY+5G7wzho8mdb13WesTBaeJjg3xqgLSnVM6WgDmbT/se46HJmhuXL6INMKhobQHMlAv IKMg== MIME-Version: 1.0 Received: by 10.68.213.73 with SMTP id nq9mr2723532pbc.143.1333593588389; Wed, 04 Apr 2012 19:39:48 -0700 (PDT) Received: by 10.68.230.74 with HTTP; Wed, 4 Apr 2012 19:39:48 -0700 (PDT) In-Reply-To: References: Date: Thu, 5 Apr 2012 10:39:48 +0800 Message-ID: Subject: Re: Is there compelte API reference and How serialize byte array like int array[n] From: Zhihua Che To: users@qpid.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sorry, I'm late. First, thanks for your reply. As far as portablity is concerned, I guess setContent(const char *, size_t) is not a suitable option. If I choose Variant=EF=BC=8C that means I have to write code like this: struct binary_data { int id; char name[8]; struct othertype filed; * * } __attribute__((aligned(sizeof(VAR_INT32)))); // sender struct binary_data data; Variant::list list; list.push_back(data.id); list.push_back(data.name); for (int i =3D 0, *p =3D (int*)&data.field; i < sizeof(data.field)/sizeof(VAR_INT32); i++) { list.push_back(*(p + i)); } // receiver struct binary_data data; data.id =3D list.pop_front(); // wrong grammer, but I believe you understand what I mean:-) data.name =3D list.pop_front(); for (int i =3D 0, *p =3D (int*)&data.filed; i < sizeof(data.field)/sizeof(VAR_INT32) ; i++) { *(p + i) =3D list.pop_front(); } It's a little wierd:-) I wonder if my code is a good programming style. =E5=9C=A8 2012=E5=B9=B44=E6=9C=881=E6=97=A5 =E4=B8=8B=E5=8D=8810:15=EF=BC= =8CChuck Rolke =E5=86=99=E9=81=93=EF=BC=9A > Hi, > > The http://qpid.apache.org/books/0.14/Programming-In-Apache-Qpid/html/ind= ex.html guide describes what you are trying to do. Take a look at the the := :List type. As implemented by Qpid the List type maps an array into a singl= e AMQP message object. For example you can send a single int in a message a= nd the AMQP encoding will be . Or you can send an array of int a= s a list encoded as . U= sing this strategy is a good idea as your receiver will receive the array w= ithout any explicit packing, unpacking, or byte swapping. Again, the Progra= mming-In document describes this. > > You can deal with messages using raw bytes as easily as with using string= s. See paste from Message.h below. With this method you can send arbitrary = blocks of binary data no problem. > > Regards, > Chuck > > > =C2=A0 =C2=A0/** > =C2=A0 =C2=A0 * Set the content to the data held in the string parameter.= Note: > =C2=A0 =C2=A0 * this is treated as raw bytes and need not be text. Consid= er > =C2=A0 =C2=A0 * setting the content-type to indicate how the data should = be > =C2=A0 =C2=A0 * interpreted by recipients. > =C2=A0 =C2=A0 */ > =C2=A0 =C2=A0QPID_MESSAGING_EXTERN void setContent(const std::string&); > =C2=A0 =C2=A0/** > =C2=A0 =C2=A0 * Copy count bytes from the region pointed to by chars as t= he > =C2=A0 =C2=A0 * message content. > =C2=A0 =C2=A0 */ > =C2=A0 =C2=A0QPID_MESSAGING_EXTERN void setContent(const char* chars, siz= e_t count); > > =C2=A0 =C2=A0/** Get the content as a std::string */ > =C2=A0 =C2=A0QPID_MESSAGING_EXTERN std::string getContent() const; > =C2=A0 =C2=A0/** > =C2=A0 =C2=A0 * Get a const pointer to the start of the content data. The > =C2=A0 =C2=A0 * memory pointed to is owned by the message. The getContent= Size() > =C2=A0 =C2=A0 * method indicates how much data there is (i.e. the extent = of the > =C2=A0 =C2=A0 * memory region pointed to by the return value of this meth= od). > =C2=A0 =C2=A0 */ > =C2=A0 =C2=A0QPID_MESSAGING_EXTERN const char* getContentPtr() const; > =C2=A0 =C2=A0/** Get the size of content in bytes. */ > =C2=A0 =C2=A0QPID_MESSAGING_EXTERN size_t getContentSize() const; > > > > ----- Original Message ----- >> From: "Zhihua Che" >> To: "users" >> Sent: Sunday, April 1, 2012 6:10:37 AM >> Subject: Is there compelte API reference and How serialize byte array li= ke int array[n] >> >> Hi, everyone >> >> =C2=A0 =C2=A0 I'm using qpid to transfer binary data. I find that Varian= t is >> designed for this purpose. But I also find that it only can serialize >> character string. >> =C2=A0 =C2=A0 I wonder if there is straight way to serialize byte stream= . >> >> =C2=A0 =C2=A0By the way, Is there complete API reference available? The >> documents I find are just tutorial and I wonder if I can learn more >> APIs or details about qpid from somewhere. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org >> For additional commands, e-mail: users-help@qpid.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org > For additional commands, e-mail: users-help@qpid.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org For additional commands, e-mail: users-help@qpid.apache.org