mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
* Consolidate documentation under doc/ directory
Move user-facing guides from release_docs/ and doxygen/ into a single
doc/ root. release_docs/ now holds only release artifacts (changelogs,
history, release process, maintainer info).
- git mv release_docs/INSTALL*.md, USING_*.md, README_HPC.md,
BuildSystemNotes.md, AutotoolsToCMakeOptions.md,
HDF5_Library_2.0.0_Migration_Guide.md → doc/
- git mv doxygen/ → doc/doxygen/
- Update CMakeLists.txt: HDF5_DOXYGEN_DIR and add_subdirectory path
- Update CMakeInstallation.cmake: all install paths for moved files
- Update bin/make_vers: hardcoded doxygen/ path substitution
- Update doc/doxygen/CMakeLists.txt: EXAMPLES_DIRECTORY and comments
- Update README.md, CONTRIBUTING.md, SECURITY.md, config/README.md,
release_docs/RELEASE_PROCESS.md: links to moved files
- Update doxygen .dox files: release_docs/ URLs for moved guides
- Rewrite release_docs/README.md for narrowed scope
* Add HDF5_DOCS_DIR variable for doc/ root path
Introduce HDF5_DOCS_DIR = \${HDF5_SOURCE_DIR}/doc so that
CMakeInstallation.cmake and future callers reference the doc/
directory symbolically rather than by hardcoded path.
HDF5_DOXYGEN_DIR is now derived from HDF5_DOCS_DIR.
146 lines
3.9 KiB
C
146 lines
3.9 KiB
C
/* -*- c-file-style: "stroustrup" -*- */
|
|
|
|
#include "hdf5.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
int ret_val = EXIT_SUCCESS;
|
|
|
|
//! <!-- [create] -->
|
|
{
|
|
__label__ fail_acpl, fail_attr, fail_file;
|
|
hid_t file, acpl, fspace, attr;
|
|
|
|
unsigned mode = H5F_ACC_TRUNC;
|
|
char file_name[] = "f1.h5";
|
|
// attribute names can be arbitrary Unicode strings
|
|
char attr_name[] = "Χαρακτηριστικό";
|
|
|
|
if ((file = H5Fcreate(file_name, mode, H5P_DEFAULT, H5P_DEFAULT)) == H5I_INVALID_HID) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_file;
|
|
}
|
|
if ((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) == H5I_INVALID_HID) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_acpl;
|
|
}
|
|
// use UTF-8 encoding for the attribute name
|
|
if (H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_fspace;
|
|
}
|
|
// create a scalar (singleton) attribute
|
|
if ((fspace = H5Screate(H5S_SCALAR)) == H5I_INVALID_HID) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_fspace;
|
|
}
|
|
// create an attribute on the root group
|
|
if ((attr = H5Acreate2(file, attr_name, H5T_STD_I32LE, fspace, acpl, H5P_DEFAULT)) ==
|
|
H5I_INVALID_HID) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_attr;
|
|
}
|
|
|
|
H5Aclose(attr);
|
|
fail_attr:
|
|
H5Sclose(fspace);
|
|
fail_fspace:
|
|
H5Pclose(acpl);
|
|
fail_acpl:
|
|
H5Fclose(file);
|
|
fail_file:;
|
|
}
|
|
//! <!-- [create] -->
|
|
|
|
//! <!-- [read] -->
|
|
{
|
|
__label__ fail_attr, fail_file;
|
|
hid_t file, attr;
|
|
|
|
unsigned mode = H5F_ACC_RDONLY;
|
|
char file_name[] = "f1.h5";
|
|
char attr_name[] = "Χαρακτηριστικό";
|
|
int value;
|
|
|
|
if ((file = H5Fopen(file_name, mode, H5P_DEFAULT)) == H5I_INVALID_HID) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_file;
|
|
}
|
|
if ((attr = H5Aopen(file, attr_name, H5P_DEFAULT)) == H5I_INVALID_HID) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_attr;
|
|
}
|
|
// read the attribute value
|
|
if (H5Aread(attr, H5T_NATIVE_INT, &value) < 0)
|
|
ret_val = EXIT_FAILURE;
|
|
|
|
// do something w/ the attribute value
|
|
|
|
H5Aclose(attr);
|
|
fail_attr:
|
|
H5Fclose(file);
|
|
fail_file:;
|
|
}
|
|
//! <!-- [read] -->
|
|
|
|
//! <!-- [update] -->
|
|
{
|
|
__label__ fail_attr, fail_file;
|
|
hid_t file, attr;
|
|
|
|
unsigned mode = H5F_ACC_RDWR;
|
|
char file_name[] = "f1.h5";
|
|
char attr_name[] = "Χαρακτηριστικό";
|
|
int value = 1234;
|
|
|
|
if ((file = H5Fopen(file_name, mode, H5P_DEFAULT)) == H5I_INVALID_HID) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_file;
|
|
}
|
|
if ((attr = H5Aopen(file, attr_name, H5P_DEFAULT)) == H5I_INVALID_HID) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_attr;
|
|
}
|
|
// update the attribute value
|
|
if (H5Awrite(attr, H5T_NATIVE_INT, &value) < 0)
|
|
ret_val = EXIT_FAILURE;
|
|
|
|
H5Aclose(attr);
|
|
fail_attr:
|
|
H5Fclose(file);
|
|
fail_file:;
|
|
}
|
|
//! <!-- [update] -->
|
|
|
|
//! <!-- [delete] -->
|
|
{
|
|
__label__ fail_attr, fail_file;
|
|
hid_t file;
|
|
|
|
unsigned mode = H5F_ACC_RDWR;
|
|
char file_name[] = "f1.h5";
|
|
char attr_name[] = "Χαρακτηριστικό";
|
|
|
|
if ((file = H5Fopen(file_name, mode, H5P_DEFAULT)) == H5I_INVALID_HID) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_file;
|
|
}
|
|
// delete the attribute
|
|
if (H5Adelete(file, attr_name) < 0) {
|
|
ret_val = EXIT_FAILURE;
|
|
goto fail_attr;
|
|
}
|
|
|
|
fail_attr:
|
|
H5Fclose(file);
|
|
fail_file:;
|
|
}
|
|
//! <!-- [delete] -->
|
|
|
|
return ret_val;
|
|
}
|