dopaque.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*! \file
  2. Functions for Opaque Types
  3. Copyright 2011 University Corporation for Atmospheric
  4. Research/Unidata. See \ref copyright file for more info. */
  5. #include "ncdispatch.h"
  6. /** \name Opaque Types
  7. Functions to create and learn about opaque types. */
  8. /*! \{ */ /* All these functions are part of this named group... */
  9. /** \ingroup user_types
  10. Create an opaque type. Provide a size and a name.
  11. \param ncid \ref ncid
  12. \param size The size of each opaque object in bytes.
  13. \param name \ref object_name of the new type.
  14. \param xtypep Pointer where the new typeid for this type is returned.
  15. \returns ::NC_NOERR No error.
  16. \returns ::NC_EBADID Bad \ref ncid.
  17. \returns ::NC_EBADTYPE Bad type id.
  18. \returns ::NC_ENOTNC4 Not an netCDF-4 file, or classic model enabled.
  19. \returns ::NC_EHDFERR An error was reported by the HDF5 layer.
  20. \returns ::NC_ENAMEINUSE That name is in use.
  21. \returns ::NC_EMAXNAME Name exceeds max length NC_MAX_NAME.
  22. \returns ::NC_EBADNAME Name contains illegal characters.
  23. \returns ::NC_EPERM Attempt to write to a read-only file.
  24. \returns ::NC_ENOTINDEFINE Not in define mode.
  25. */
  26. int
  27. nc_def_opaque(int ncid, size_t size, const char *name, nc_type *xtypep)
  28. {
  29. NC* ncp;
  30. int stat = NC_check_id(ncid,&ncp);
  31. if(stat != NC_NOERR) return stat;
  32. return ncp->dispatch->def_opaque(ncid,size,name,xtypep);
  33. }
  34. /** \ingroup user_types
  35. Learn about an opaque type.
  36. \param ncid \ref ncid
  37. \param xtype Typeid to inquire about.
  38. \param name The \ref object_name of this type will be
  39. copied here. \ref ignored_if_null.
  40. \param sizep The size of the type will be copied here. \ref
  41. ignored_if_null.
  42. \returns ::NC_NOERR No error.
  43. \returns ::NC_EBADID Bad \ref ncid.
  44. \returns ::NC_EBADTYPE Bad type id.
  45. \returns ::NC_ENOTNC4 Not an netCDF-4 file, or classic model enabled.
  46. \returns ::NC_EHDFERR An error was reported by the HDF5 layer.
  47. */
  48. int
  49. nc_inq_opaque(int ncid, nc_type xtype, char *name, size_t *sizep)
  50. {
  51. int class = 0;
  52. int stat = nc_inq_user_type(ncid,xtype,name,sizep,NULL,NULL,&class);
  53. if(stat != NC_NOERR) return stat;
  54. if(class != NC_OPAQUE) stat = NC_EBADTYPE;
  55. return stat;
  56. }
  57. /*! \} */ /* End of named group ...*/