Revision 4 (by moose, 2009/02/13 04:09:19) * add msgtest2.pl test for new highlevel api
* separate XS into Message and Item related code
* remove Makefile.old from svn
* add encode/decode support to hl CSE::Proto::Message class
* convert CSE::Proto::C::Item to use a simple blessed pointer instead of a hashref holding the handle
* fix CSE::Proto::Message::Item::clone to properly clone the value, not just copy an ARRAY ref
* add support for MESSAGE type items in the parser
#!/usr/bin/perl

use strict;
use warnings;

use lib qw/lib/;
use CSE::Proto::Message::Parser;

my $msg = CSE::Proto::Message::Parser->new(file => 'test.proto');
$msg->parse;

use CSE::Proto::Message;
my $obj = CSE::Proto::Message->create('Test');
print "new obj: ".$obj->name."\n";
for my $key ( $obj->items ) {
   my $item = $obj->item($key);
   print "   item: ".$item->typename . ':'. $item->name."\n";
   if($item->type == CSE::Proto::C::Item::TYPE_MESSAGE) {
      print "{\n";
      my $class = CSE::Proto::Message::Class($item->typename);
      for my $key2 ( $class->items ) {
         my $item2 = $class->item($key2);
         print "   item: ".$item2->typename . ':'. $item2->name."\n";
      }
      print "}\n";
   }
}

my $item_msg = $obj->item('pair')->value->[0];
print "value: ".$item_msg->name."\n";
print "keys: ".join(',',$item_msg->items)."\n";
$item_msg->item('key')->set_value('testkey');
$item_msg->item('value')->set_value('testvalue');
print "values: ".join(',',map { $item_msg->item($_)->value } $item_msg->items)."\n";
print $item_msg->item('key')->value."\n";
print $item_msg->item('value')->value."\n";