Regarding nested sequences

Regarding nested sequences

Post by Deep » Sun, 27 Jul 2003 15:27:22



Hi,

Has anyone used nested sequences in their applications ?
I am looking for an application that uses two levels of nesting of
sequnces.
The idl would look something like this:

interface test
{

 typedef sequence < sequence < short > > test_seq;
 .......
 .......

Quote:};

I would like to know how we can use the C++ mapping for the above in a
C++ application.  The difficulty I am facing is that no specification
talks about the C++ mapping for a nested sequence.

Thanks in advance..
Deepak.

 
 
 

Regarding nested sequences

Post by Alan Walke » Mon, 28 Jul 2003 11:05:49


Deepak,
    The problem with nested sequences is the naming of the intermediate
structures.  Use typedef.  I use nested sequences all the time, here's one
of my IDL files cut down, with a few names changed:

struct XXX {
 string x1;
 short x2;

Quote:};

typedef sequence<XXX> XXX_seq;

struct Option {
 double amount;
 XXX_seq    x_data;

Quote:};

typedef sequence<Option> Response;

interface my_interface {
  short  doSomething(in string req, out Response resp);

Quote:};

Alan.


Quote:> Hi,

> Has anyone used nested sequences in their applications ?
> I am looking for an application that uses two levels of nesting of
> sequnces.
> The idl would look something like this:

> interface test
> {

>  typedef sequence < sequence < short > > test_seq;
>  .......
>  .......

> };

> I would like to know how we can use the C++ mapping for the above in a
> C++ application.  The difficulty I am facing is that no specification
> talks about the C++ mapping for a nested sequence.

> Thanks in advance..
> Deepak.


 
 
 

Regarding nested sequences

Post by Michi Hennin » Wed, 30 Jul 2003 06:55:54



Quote:> interface test
> {

>  typedef sequence < sequence < short > > test_seq;

> };

> I would like to know how we can use the C++ mapping for the above in a
> C++ application.  The difficulty I am facing is that no specification
> talks about the C++ mapping for a nested sequence.

It should look something like this:

test::test_seq s; // Instantiate a sequence

s.length(2); // The outer sequence has two elements

s[0].length(1); // The first inner sequence has one element
s[1].length(3); // The second inner sequence has three elements

// Initialize elements
s[0][0] = 47;
s[1][0] = 99;
s[1][1] = 42;
s[1][2] = 13;

You can find a quite detailed description in Steve's and my book.
http://www.awprofessional.com/catalog/product.asp?product_id={E405000A-5F7E-420D-84AE-9BCDCD27FEDB}

Cheers,

Michi.

--
Michi Henning              Ph: +61 4 1118-2700
ZeroC, Inc.                http://www.zeroc.com