bes  Updated for version 3.20.6
nc_util.cc
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of nc_handler, a data handler for the OPeNDAP data
4 // server.
5 
6 // Copyright (c) 2002,2003 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@opendap.org>
8 //
9 // This is free software; you can redistribute it and/or modify it under the
10 // terms of the GNU Lesser General Public License as published by the Free
11 // Software Foundation; either version 2.1 of the License, or (at your
12 // option) any later version.
13 //
14 // This software is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 // License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 #include "config.h"
26 
27 #include <netcdf.h>
28 
29 bool is_user_defined_type(int /*ncid*/, int type)
30 {
31 #if NETCDF_VERSION >= 4
32  return type >= NC_FIRSTUSERTYPEID;
33 
34 #if 0
35  // Use the above - it's simpler and supported in the netcdf.h header. jhrg 8/2/18
36  int ntypes;
37  int typeids[NC_MAX_VARS]; // It's likely safe to assume there are
38  // no more types than variables. jhrg
39  // 2/9/12
40  int err = nc_inq_typeids(ncid, &ntypes, typeids);
41  if (err != NC_NOERR)
42  throw Error(err, "Could not get the user defined type information.");
43 
44  for (int i = 0; i < ntypes; ++i) {
45  if (type == typeids[i])
46  return true;
47  }
48 
49  return false;
50 #endif
51 
52 #else
53  return false;
54 #endif
55 }
56 
Error