/* Hdf_attr.hpp */ #ifndef HDF_ATTR_HPP #define HDF_ATTR_HPP #include #include #include #include #include "mfhdf.h" #include "Hdf_exceptions.hpp" class Hdf_attr { public: /** * @enum attr_own the type of the owner of an attribute * An attribute can refer either to a file, an sds, a VData, a VData field or a VGroup, and the way to read them in a file depends of it */ typedef enum { UNDEFINED, SDS, VDATA, // other owner to add } attr_own; // TODO update constructor to write attributes in a file : this one only fits to reading Hdf_attr(const int32 object_id, const int32 iattr, const char *attr_name, const int32 attr_type, const int32 attr_nvalues, const attr_own owner=SDS, const int32 vd_field_idx=_HDF_VDATA); Hdf_attr(); Hdf_attr(const Hdf_attr &hdf_attr); ~Hdf_attr(); int32 get_type() const { return type; }; int32 get_nvalues() const { return nvalues; } void get_value(void *value, int32 ival = 0) const; // ival is the index of value to retrieve from values void get_values(void *values) const; // values must be allocated by the caller : values = new attr_type[attr.get_nvalues()] std::string get_name() const { return name; } std::string to_string() const; std::string list_of_values() const; Hdf_attr &operator= (const Hdf_attr &hdf_attr); friend std::ostream &operator<< (std::ostream &stream, const Hdf_attr &hdf_attr); // change these to control the output of list_of_values() // these limits are intended to avoid a too large output (only the first and the last values will be displayed, separated by ...) // set them to 0 to display ALL the attribute values (even if there are hundreds or thousands of them) static int32 chars_to_display; static int32 numbers_to_display; private: int32 obj_id; int32 index; std::string name; int32 type; int32 nvalues; void* values; void allocate_values(); void deallocate_values(); void copy_values(const Hdf_attr &hdf_attr); }; #endif