HDF5 C++ API Reference Manual

- Main Page
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

# H5DataType.h

Go to the documentation of this file.

    00001 // C++ informative line for the emacs editor: -*- C++ -*-
    00002 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    00003  * Copyright by The HDF Group.                                               *
    00004  * Copyright by the Board of Trustees of the University of Illinois.         *
    00005  * All rights reserved.                                                      *
    00006  *                                                                           *
    00007  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
    00008  * terms governing use, modification, and redistribution, is contained in    *
    00009  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
    00010  * of the source code distribution tree; Copyright.html can be found at the  *
    00011  * root level of an installed copy of the electronic HDF5 document set and   *
    00012  * is linked from the top-level documents page.  It can also be found at     *
    00013  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
    00014  * access to either file, you may request a copy from help@hdfgroup.org.     *
    00015  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    00016
    00017 #ifndef _H5DataType_H
    00018 #define _H5DataType_H
    00019
    00020 #ifndef H5_NO_NAMESPACE
    00021 namespace H5 {
    00022 #endif
    00023
    00024 class H5_DLLCPP DataType : public H5Object {
    00025    public:
    00026         // Creates a datatype given its class and size
    00027         DataType( const H5T_class_t type_class, size_t size );
    00028
    00029         // Copy constructor: makes a copy of the original object
    00030         DataType( const DataType& original );
    00031
    00032         // Creates a datatype by way of dereference.
    00033         DataType(H5Object& obj, void* ref, H5R_type_t ref_type = H5R_OBJECT);
    00034         DataType(H5File& h5file, void* ref, H5R_type_t ref_type = H5R_OBJECT);
    00035         DataType(Attribute& attr, void* ref, H5R_type_t ref_type = H5R_OBJECT);
    00036
    00037         // Closes this datatype.
    00038         virtual void close();
    00039
    00040         // Copies an existing datatype to this datatype object.
    00041         void copy(const DataType& like_type);
    00042
    00043         // Copies the datatype of dset to this datatype object.
    00044         void copy(const DataSet& dset);
    00045
    00046         // Returns the datatype class identifier.
    00047         H5T_class_t getClass() const;
    00048
    00049         // Commits a transient datatype to a file; this datatype becomes
    00050         // a named datatype which can be accessed from the location.
    00051         void commit( H5File& loc, const char* name);
    00052         void commit( H5File& loc, const H5std_string& name);
    00053         void commit( H5Object& loc, const char* name);
    00054         void commit( H5Object& loc, const H5std_string& name);
    00055
    00056         // Determines whether this datatype is a named datatype or
    00057         // a transient datatype.
    00058         bool committed() const;
    00059
    00060         // Finds a conversion function that can handle the conversion
    00061         // this datatype to the given datatype, dest.
    00062         H5T_conv_t find( const DataType& dest, H5T_cdata_t **pcdata ) const;
    00063
    00064         // Converts data from between specified datatypes.
    00065         void convert( const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const;
    00066
    00067         // Assignment operator
    00068         DataType& operator=( const DataType& rhs );
    00069
    00070         // Determines whether two datatypes are the same.
    00071         bool operator==(const DataType& compared_type ) const;
    00072
    00073         // Locks a datatype.
    00074         void lock() const;
    00075
    00076         // Returns a pointer to the current global overflow function.
    00077         H5T_overflow_t getOverflow(void) const;
    00078
    00079         // Sets the overflow handler to a specified function.
    00080         void setOverflow(H5T_overflow_t func) const;
    00081
    00082         // Returns the size of a datatype.
    00083         size_t getSize() const;
    00084
    00085         // Returns the base datatype from which a datatype is derived.
    00086         // Note: not quite right for specific types yet???
    00087         DataType getSuper() const;
    00088
    00089         // Registers a conversion function.
    00090         void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
    00091         void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
    00092
    00093         // Removes a conversion function from all conversion paths.
    00094         void unregister( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
    00095         void unregister( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
    00096
    00097         // Tags an opaque datatype.
    00098         void setTag( const char* tag ) const;
    00099         void setTag( const H5std_string& tag ) const;
    00100
    00101         // Gets the tag associated with an opaque datatype.
    00102         H5std_string getTag() const;
    00103
    00104         // Checks whether this datatype contains (or is) a certain type class.
    00105         bool detectClass(H5T_class_t cls) const;
    00106
    00107         // Checks whether this datatype is a variable-length string.
    00108         bool isVariableStr() const;
    00109
    00110         // Retrieves the type of object that an object reference points to.
    00111         H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
    00112
    00113         // Retrieves a dataspace with the region pointed to selected.
    00114         DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
    00115
    00116         // Returns this class name
    00117         virtual H5std_string fromClass () const { return("DataType"); }
    00118
    00119         // Creates a copy of an existing DataType using its id
    00120         DataType( const hid_t type_id );
    00121
    00122         // Default constructor
    00123         DataType();
    00124
    00125         // Gets the datatype id.
    00126         virtual hid_t getId() const;
    00127
    00128         // Destructor: properly terminates access to this datatype.
    00129         virtual ~DataType();
    00130
    00131    protected:
    00132         hid_t id;       // HDF5 datatype id
    00133
    00134         // Sets the datatype id.
    00135         virtual void p_setId(const hid_t new_id);
    00136
    00137    private:
    00138         void p_commit(hid_t loc_id, const char* name);
    00139 };
    00140 #ifndef H5_NO_NAMESPACE
    00141 }
    00142 #endif
    00143 #endif