[omniORB] _var Mapping Question
Bruce Visscher
visschb@rjrt.com
Wed, 22 Sep 1999 17:49:59 -0400
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