From 759eb840f3b5ffcc56155369b02ed360ce19c409 Mon Sep 17 00:00:00 2001 From: "Darryl L. Pierce" Date: Tue, 11 Feb 2014 15:15:14 +0000 Subject: QPID-5546: Expose the get_content_object method in Perl. Updated the spout and drain examples to use this rather than encode/decode to retrieve the content of a message. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1567173 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/bindings/qpid/examples/perl/drain.pl | 4 +-- qpid/cpp/bindings/qpid/examples/perl/spout.pl | 2 +- .../qpid/perl/lib/qpid/messaging/Message.pm | 33 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/qpid/cpp/bindings/qpid/examples/perl/drain.pl b/qpid/cpp/bindings/qpid/examples/perl/drain.pl index f7a710c485..d0150854b2 100755 --- a/qpid/cpp/bindings/qpid/examples/perl/drain.pl +++ b/qpid/cpp/bindings/qpid/examples/perl/drain.pl @@ -92,13 +92,13 @@ eval { # if the message content was a map, then we will print # it out as a series of name => value pairs + my $content = $message->get_content_object; if ( $message->get_content_type() eq "amqp/map" ) { - my $content = $message->get_content(); map { print "\n$_ => $content->{$_}"; } keys %{$content}; } else { # it's not a map, so just print the content as a string - print $message->get_content(); + print $content; } print "')\n"; diff --git a/qpid/cpp/bindings/qpid/examples/perl/spout.pl b/qpid/cpp/bindings/qpid/examples/perl/spout.pl index 7468a25a3a..c97c2a58af 100755 --- a/qpid/cpp/bindings/qpid/examples/perl/spout.pl +++ b/qpid/cpp/bindings/qpid/examples/perl/spout.pl @@ -91,7 +91,7 @@ eval { if (@entries) { my $content = {}; setEntries($content); - $message->set_content($content); + $message->set_content_object($content); } elsif ($content) { $message->set_content($content); diff --git a/qpid/cpp/bindings/qpid/perl/lib/qpid/messaging/Message.pm b/qpid/cpp/bindings/qpid/perl/lib/qpid/messaging/Message.pm index 6437290244..6926eb221f 100644 --- a/qpid/cpp/bindings/qpid/perl/lib/qpid/messaging/Message.pm +++ b/qpid/cpp/bindings/qpid/perl/lib/qpid/messaging/Message.pm @@ -527,6 +527,39 @@ sub get_properties { =pod +=head2 CONTENT OBJECT + +The message content, represented as anh object. + +=over + +=item $msg->set_content_object( \%content ) + +=item $content = $msg->get_Content_object + +=back + +=cut + +sub set_content_object { + my ($self) = @_; + my $impl = $self->{_impl}; + + my $content = $_[1]; + + $impl->setContentObject($content); +} + +sub get_content_object { + my ($self) = @_; + my $impl = $self->{_impl}; + my $content = $impl->getContentObject; + + return $content; +} + +=pod + =head2 CONTENT The message content. -- cgit v1.2.1