[omniORB] Dereferencing _vars

jnye@micro-optics.com jnye@micro-optics.com
Thu, 7 Jun 2001 14:12:17 -0300


Yep, there is. Try:

foo::nvseq_var nvs = myFoo->getNvSeq();
   for (int i = 0; i < nvs->length(); i++)
   {
      cout << "name = " << nvs[i].name.in() << "\n";
      cout << "value = " << nvs[i].value.in() << "\n";
   }

Notice the 'nvs' instead of (*nvs). All _var classes for lists have this
cool feature.

Cheers,
Jason.

-----Original Message-----
From: owner-omniorb-list@uk.research.att.com
[mailto:owner-omniorb-list@uk.research.att.com]On Behalf Of Bruce
Fountain
Sent: Thursday, June 07, 2001 1:59 PM
To: omniorb-list@uk.research.att.com
Subject: [omniORB] Dereferencing _vars


One last one before I turn in...

I don't seem to be able to deference an _var in the same way I
could with other ORBs. For instance, if I have the following IDL:

interface foo
{
   struct nv
   {
      string name;
      string value;
   };

   typedef sequence<nv> nvseq;

   nvseq getNvSeq();
};

Then I would normally use getNvSeq() something like this:

   foo::nvseq_var nvs = myFoo->getNvSeq();
   for (int i = 0; i < nvs->length(); i++)
   {
      cout << "name = " << (*nvs)[i].name.in() << "\n";
      cout << "value = " << (*nvs)[i].value.in() << "\n";
   }

but omniORB won't let me dereference (*result). I can introduce a
new variable which is a pointer and dereference that:
   foo::nvseq_var nvs = myFoo->getNvSeq();
   const foo:nvseq* ptr = nvs.in();
   for (int i = 0; i < ptr->length(); i++)
   {
      cout << "name = " << (*ptr)[i].name.in() << "\n";
      cout << "value = " << (*ptr)[i].value.in() << "\n";
   }

... bit ugly though. There is probably a really simple, elegant
trick, right?

Bruce Fountain
Mi Consulting Group (Australia) Pty Ltd
Direct Line:  +61 (0)8 9368 8607
Switchboard:  +61 (0)8 9368 8600
Facsimile:    +61 (0)8 9368 8699
E-mail: b_fountain@motherwell.com.au