// NewCompoundType creates a new CompoundType. // size is the size in bytes of the compound datatype. func NewCompoundType(size int) (*CompoundType, error) { id := C.H5Tcreate(C.H5T_class_t(T_COMPOUND), C.size_t(size)) if err := checkID(id); err != nil { return nil, err } t := &CompoundType{Datatype{Location{Identifier{id}}}} runtime.SetFinalizer(t, (*CompoundType).finalizer) return t, nil }
// Creates a new datatype. // hid_t H5Tcreate( H5T_class_t class, size_tsize ) func CreateDataType(class TypeClass, size int) (t *DataType, err error) { t = nil err = nil hid := C.H5Tcreate(C.H5T_class_t(class), C.size_t(size)) err = togo_err(C.herr_t(int(hid))) if err != nil { return } t = new_dtype(hid, _type_cls_to_go_type[class]) return }
// CreateDatatype creates a new datatype. // class must be T_COMPUND, T_OPAQUE, T_ENUM or T_STRING. // size is the size of the new datatype in bytes. func CreateDatatype(class TypeClass, size int) (*Datatype, error) { _, ok := parametricTypes[class] if !ok { return nil, fmt.Errorf( "invalid TypeClass, want %v, %v, %v or %v, got %v", T_COMPOUND, T_OPAQUE, T_STRING, T_ENUM) } hid := C.H5Tcreate(C.H5T_class_t(class), C.size_t(size)) err := h5err(C.herr_t(int(hid))) if err != nil { return nil, err } return NewDatatype(hid), nil }