HDF5 C++ API  1.8.20
 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
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 the file, in which this attribute belongs.
45  H5std_string getFileName() const;
46 
47  // Gets the name of this attribute.
48  ssize_t getName(char* attr_name, size_t buf_size = 0) const;
49  H5std_string getName(size_t len) const;
50  H5std_string getName() const;
51  ssize_t getName(H5std_string& attr_name, size_t len = 0) const;
52  // The overloaded function below is replaced by the one above and it
53  // is kept for backward compatibility purpose.
54  ssize_t getName(size_t buf_size, H5std_string& attr_name) const;
55 
56  // Gets a copy of the dataspace for this attribute.
57  virtual DataSpace getSpace() const;
58 
59  // Returns the amount of storage size required for this attribute.
60  virtual hsize_t getStorageSize() const;
61 
62  // Returns the in memory size of this attribute's data.
63  virtual size_t getInMemDataSize() const;
64 
65  // Reads data from this attribute.
66  void read(const DataType& mem_type, void *buf) const;
67  void read(const DataType& mem_type, H5std_string& strg) const;
68 
69  // Writes data to this attribute.
70  void write(const DataType& mem_type, const void *buf) const;
71  void write(const DataType& mem_type, const H5std_string& strg) const;
72 
73  // Flushes all buffers associated with the file specified by this
74  // attribute to disk.
75  void flush(H5F_scope_t scope) const;
76 
78  virtual H5std_string fromClass () const { return("Attribute"); }
79 
80  // Gets the attribute id.
81  virtual hid_t getId() const;
82 
83  // Destructor: properly terminates access to this attribute.
84  virtual ~Attribute();
85 
86 #ifndef DOXYGEN_SHOULD_SKIP_THIS
87  protected:
88  // Sets the attribute id.
89  virtual void p_setId(const hid_t new_id);
90 #endif // DOXYGEN_SHOULD_SKIP_THIS
91 
92  private:
93  hid_t id; // HDF5 attribute id
94 
95  // This function contains the common code that is used by
96  // getTypeClass and various API functions getXxxType
97  // defined in AbstractDs for generic datatype and specific
98  // sub-types
99  virtual hid_t p_get_type() const;
100 
101  // Reads variable or fixed len strings from this attribute.
102  void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const;
103  void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const;
104 
105  // do not inherit H5Object::iterateAttrs
106  int iterateAttrs() { return 0; }
107 
108  // do not inherit H5Object::renameAttr
109  void renameAttr() {}
110 
111  // Friend function to set Attribute id. For library use only.
112  friend void f_Attribute_setId(Attribute* attr, hid_t new_id);
113 
114 }; // end of Attribute
115 } // namespace H5
116 
117 #endif // __H5Attribute_H
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5Attribute.h:78
void f_Attribute_setId(Attribute *attr, hid_t new_id)
Definition: H5Location.cpp:1132
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:25
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, providing a collection of wrappers of the C functions that take...
Definition: H5Location.h:42
AbstractDs is an abstract base class, inherited by Attribute and DataSet.
Definition: H5AbstractDs.h:38


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