// Get reads data from the file. func (f *File) Get(name string, something interface{}) error { value := reflect.ValueOf(something) if value.Kind() != reflect.Ptr { return errors.New("expected a pointer") } value = reflect.Indirect(value) cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) did := C.H5Dopen2(f.fid, cname, C.H5P_DEFAULT) if did < 0 { return errors.New("cannot find the dataset") } defer C.H5Dclose(did) object := newObject() defer object.free() object.tid = C.H5Dget_type(did) if object.tid < 0 { return errors.New("cannot get the datatype of the dataset") } if err := initializeToGet(object, value); err != nil { return err } if C.H5Dread(did, object.tid, C.H5S_ALL, C.H5S_ALL, C.H5P_DEFAULT, object.data) < 0 { return errors.New("cannot read the dataset from the file") } if err := finalizeToGet(object, value); err != nil { return err } one := C.hsize_t(1) sid := C.H5Screate_simple(1, (*C.hsize_t)(unsafe.Pointer(&one)), nil) if sid < 0 { return errors.New("cannot create a data space") } defer C.H5Sclose(sid) if C.H5Dvlen_reclaim(object.tid, sid, C.H5P_DEFAULT, object.data) < 0 { return errors.New("cannot reclaim memory") } return nil }
// Type returns an identifier for a copy of the datatype for a dataset. func (t *Table) Type() (*Datatype, error) { hid := C.H5Dget_type(t.id) if err := checkID(hid); err != nil { return nil, err } return NewDatatype(hid), nil }
// Datatype returns the HDF5 Datatype of the Dataset func (s *Dataset) Datatype() (*Datatype, error) { dtype_id := C.H5Dget_type(s.id) if dtype_id < 0 { return nil, fmt.Errorf("couldn't open Datatype from Dataset %q", s.Name()) } return NewDatatype(dtype_id), nil }
// Type returns an identifier for a copy of the datatype for a dataset. func (t *Table) Type() (*Datatype, error) { hid := C.H5Dget_type(t.id) err := h5err(C.herr_t(int(hid))) if err != nil { return nil, err } return copyDatatype(hid) }
// Returns an identifier for a copy of the datatype for a dataset. // hid_t H5Dget_type(hid_t dataset_id ) func (t *Table) Type() (*DataType, error) { hid := C.H5Dget_type(t.id) err := togo_err(C.herr_t(int(hid))) if err != nil { return nil, err } dt := new_dtype(hid, nil) return dt, err }
// Returns an identifier for a copy of the datatype for a dataset. // hid_t H5Dget_type(hid_t dataset_id ) func (s *Dataset) Type() (*Datatype, error) { hid := C.H5Dget_type(s.id) err := h5err(C.herr_t(int(hid))) if err != nil { return nil, err } dt := NewDatatype(hid, nil) return dt, err }