[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #GQK-400775]: netCDF C++ API question - is_valid()



Hi Mike,

You can use just use the NULL test and not bother with
the is_valid() method for returns from get_dim(), get_var(),
and get_att() methods.

The purpose of the is_valid() method is to provide a way
to handle the situation where you get an attribute, for
example, close the file (which calls destructors for the
dimensions and variables but not for the attributes), and
then hand off the attribute to some other method.  If the
underlying file is no longer open, is_valid() will return
false, because setting the value of the attribute will no
longer change its value in the file.  So the attribute
might not be NULL, but is_valid() would return false.

Use of the is_valid() method is an artifact of the lack of
exceptions in most C++ compilers when the netCDF C++
interface was first written and the fact that constructors
are not allowed to fail.

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: GQK-400775
Department: Support netCDF
Priority: Normal
Status: Closed