[omniORB] Pointer from a _var?

Glenn A. Hochberg gah@research.att.com
Thu, 21 Jun 2001 10:23:15 -0400


I think what you want to test is whether the sequence_var is holding a
non-null pointer to a sequence, correct?
If so, just cast the _var to a T*:

// Client.cpp
Foo::ShortSeq_var ss;
if ((Foo::ShortSeq_ptr)ss == 0)
{
    std::cout << "ss is null\n";
}

I think that should work.

    -Glenn

John Hedges wrote:

> > The pointer inside the sequence would always be valid, unless the length
> of the sequence is 0. So you could indirectly test the pointer through the
> sequence's length() metod.
> > For arithmetics inside the sequence buffer you have the [] operator.
> >
> > -Haarek-
>
> Trouble is that using length() on an unititialised sequence is dangerous.
> It would probably be best to think of a way other than testing for NULL on
> a sequence - like having zero length sequences instead as Haarek suggests.
> However using ss.operator->() returns the value of the underlying T*
> despite being a bit wierd to look at :)
>
> John
>
> >
> > Bruce Fountain wrote:
> >
> > > Stephen Crawley wrote:
> > > > You need to get the contents of the _var.  Try this:
> > > >
> > > >   // Client.cpp
> > > >     Foo::ShortSeq_var ss;
> > > >     if (*ss == 0)
> > > >     {
> > > >         std::cout << "ss is null\n";
> > > >     }
> > >
> > > I just tried this. It produces the identical error on compilation
> > > (ie. still trying to find an == operator for FooShortSeq_var),
> > > which would suggest that dereferencing using * doesn't give me a
> > > (FooShortSeq*).
> > >
> > > Bruce
> >
> > --
> > Haarek Ryeng
> > Senior Software Development Engineer
> > Data Respons AS, Sandviksvn. 26,N-1323 HOEVIK, Norway.
> > Tel: +47 67112071 Mob: +47 90196734
> >
> >    Embedded Computers & Realtime Professionals
> >              www.datarespons.no
> >
> >
> >