HDF5 C++ API  1.10.1
 All Classes Namespaces Functions Variables Typedefs Friends Pages
H5Attribute.h
1 // C++ informative line for the emacs editor: -*- C++ -*-
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3  * Copyright by The HDF Group. *
4  * Copyright by the Board of Trustees of the University of Illinois. *
5  * All rights reserved. *
6  * *
7  * This file is part of HDF5. The full HDF5 copyright notice, including *
8  * terms governing use, modification, and redistribution, is contained in *
9  * the COPYING file, which can be found at the root of the source code *
10  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
11  * If you do not have access to either file, you may request a copy from *
12  * help@hdfgroup.org. *
13  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14 
15 #ifndef __H5Attribute_H
16 #define __H5Attribute_H
17 
18 namespace H5 {
19 
28 // Inheritance: multiple H5Location/AbstractDs -> IdComponent
29 class H5_DLLCPP Attribute : public AbstractDs, public H5Location {
30  public:
31 
32  // Copy constructor: makes a copy of an existing Attribute object.
33  Attribute(const Attribute& original);
34 
35  // Default constructor
36  Attribute();
37 
38  // Creates a copy of an existing attribute using the attribute id
39  Attribute(const hid_t attr_id);
40 
41  // Closes this attribute.
42  virtual void close();
43 
44  // Gets the name of this attribute.
45  ssize_t getName(char* attr_name, size_t buf_size = 0) const;
46  H5std_string getName(size_t len) const;
47  H5std_string getName() const;
48  ssize_t getName(H5std_string& attr_name, size_t len = 0) const;
49  // The overloaded function below is replaced by the one above and it
50  // is kept for backward compatibility purpose.
51  ssize_t getName(size_t buf_size, H5std_string& attr_name) const;
52 
53  // Gets a copy of the dataspace for this attribute.
54  virtual DataSpace getSpace() const;
55 
56  // Returns the amount of storage size required for this attribute.
57  virtual hsize_t getStorageSize() const;
58 
59  // Returns the in memory size of this attribute's data.
60  virtual size_t getInMemDataSize() const;
61 
62  // Reads data from this attribute.
63  void read(const DataType& mem_type, void *buf) const;
64  void read(const DataType& mem_type, H5std_string& strg) const;
65 
66  // Writes data to this attribute.
67  void write(const DataType& mem_type, const void *buf) const;
68  void write(const DataType& mem_type, const H5std_string& strg) const;
69 
71  virtual H5std_string fromClass () const { return("Attribute"); }
72 
73  // Gets the attribute id.
74  virtual hid_t getId() const;
75 
76  // Destructor: properly terminates access to this attribute.
77  virtual ~Attribute();
78 
79 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80  protected:
81  // Sets the attribute id.
82  virtual void p_setId(const hid_t new_id);
83 #endif // DOXYGEN_SHOULD_SKIP_THIS
84 
85  private:
86  hid_t id; // HDF5 attribute id
87 
88  // This function contains the common code that is used by
89  // getTypeClass and various API functions getXxxType
90  // defined in AbstractDs for generic datatype and specific
91  // sub-types
92  virtual hid_t p_get_type() const;
93 
94  // Reads variable or fixed len strings from this attribute.
95  void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const;
96  void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const;
97 
98  // Friend function to set Attribute id. For library use only.
99  friend void f_Attribute_setId(Attribute* attr, hid_t new_id);
100 
101 }; // end of Attribute
102 } // namespace H5
103 
104 #endif // __H5Attribute_H
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5Attribute.h:71
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:24
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:29
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:28
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:36
AbstractDs is an abstract base class, inherited by Attribute and DataSet.
Definition: H5AbstractDs.h:36


The HDF Group Help Desk:
  Copyright by The HDF Group
and the Board of Trustees of the University of Illinois