[omniORB] _var Mapping Question
Ken Feuerman
kfeuerma@Adobe.COM
Wed, 22 Sep 1999 15:46:28 -0700
Yes, it turns out that both T::_nil() and CORBA::is_nil() work for checking
an uninitialized T_var variable. It looks as though the reason neither
worked for me when I sent the message is because of a typo:
if (!CORBA::is_nil(myvar)); // oops! extra semi-colon
myvar->doSomething();
Thus I was always calling myvar->doSomething(), even with a "NULL" myvar.
Thanks again!
--Ken Feuerman.
At 05:49 PM 9/22/99 -0400, Bruce Visscher wrote:
>If this isn't a FAQ, it should be.
>
>Ken Feuerman wrote:
>>
>> I'd like to do something like the following:
>>
>> T_var myvar; // empty initialization
>>
>> try
>> {
>> myvar = // Something that will likely throw
>> }
>> catch (...)
>> {
>> // oh well, didn't really need myvar anyhow
>> }
>>
>> if (myvar != "NULL") // (**)
>
>You can use T::_nil() here.
>
>> {
>> // do something with a non-"NULL" myvar
>> }
>>
>> Basically, in the line marked by (**), I need to check if the T_var
>> variable was ever assigned to successfully within the try{} block. Is
>> there some ORB-portable way to check if a T_var is still "empty
initialized"?
>>
>> By the way, I tried (!CORBA::is_nil(myvar)) for (**) above, and that did
>> not seem to work.
>>
>
>Exactly how did it fail?
>
>The following program prints "Hello world!" on my screen:
>
>#include <iostream>
>#include "foo.hh"
>
>int main() {
> foo_var myvar;
> if (CORBA::is_nil(myvar))
> std::cout << "Hello world!";
>}
>
>Bruce
>
>
>