示例#1
0
文件: h5t.go 项目: jonlawlor/go-hdf5
// OpenDatatype opens a named datatype.
func OpenDatatype(c CommonFG, name string, tapl_id int) (*Datatype, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	id := C.H5Topen2(C.hid_t(c.id), c_name, C.hid_t(tapl_id))
	if err := checkID(id); err != nil {
		return nil, err
	}
	return NewDatatype(id), nil
}
示例#2
0
文件: h5g.go 项目: simleb/go-hdf5
func createGroup(id C.hid_t, name string, link_flags, grp_c_flags, grp_a_flags int) (*Group, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Gcreate2(id, c_name, C.hid_t(link_flags), C.hid_t(grp_c_flags), P_DEFAULT.id)
	if err := h5err(C.herr_t(int(hid))); err != nil {
		return nil, err
	}
	g := &Group{Location{hid}}
	runtime.SetFinalizer(g, (*Group).finalizer)
	return g, nil
}
示例#3
0
文件: h5t.go 项目: kisielk/go-hdf5
func OpenDatatype(c CommonFG, name string, tapl_id int) (*Datatype, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	id := C.H5Topen2(C.hid_t(c.id), c_name, C.hid_t(tapl_id))
	err := h5err(C.herr_t(id))
	if err != nil {
		return nil, err
	}
	dt := &Datatype{Location{Identifier{id}}}
	runtime.SetFinalizer(dt, (*Datatype).finalizer)
	return dt, err
}
示例#4
0
文件: h5t.go 项目: pauh/go-hdf5
func openDatatype(loc_id C.hid_t, name string, tapl_id int) (*Datatype, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Topen2(C.hid_t(loc_id), c_name, C.hid_t(tapl_id))
	err := h5err(C.herr_t(hid))
	if err != nil {
		return nil, err
	}
	dt := &Datatype{id: hid}
	runtime.SetFinalizer(dt, (*Datatype).finalizer)
	return dt, err
}
示例#5
0
文件: h5g.go 项目: kisielk/go-hdf5
// CreateGroup creates a new empty group and links it to a location in the file.
func (g *CommonFG) CreateGroup(name string) (*Group, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	link_flags := C.hid_t(C.H5P_DEFAULT)
	grp_c_flags := C.hid_t(C.H5P_DEFAULT)
	hid := C.H5Gcreate2(g.id, c_name, link_flags, grp_c_flags, P_DEFAULT.id)
	if err := h5err(C.herr_t(int(hid))); err != nil {
		return nil, err
	}
	group := &Group{CommonFG{Location{Identifier{hid}}}}
	runtime.SetFinalizer(group, (*Group).finalizer)
	return group, nil
}
示例#6
0
// Creates a new empty group and links it to a location in the file.
// hid_t H5Gcreate2( hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id )
func (self *File) CreateGroup(name string, link_flags, grp_c_flags, grp_a_flags int) (g *Group, err error) {
	g = nil
	err = nil

	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Gcreate2(self.id, c_name, C.hid_t(link_flags), C.hid_t(grp_c_flags), P_DEFAULT.id)
	err = togo_err(C.herr_t(int(hid)))
	if err != nil {
		return
	}
	g = &Group{id: hid}
	runtime.SetFinalizer(g, (*Group).h5g_finalizer)
	return
}
示例#7
0
文件: h5p.go 项目: jonlawlor/go-hdf5
// NewPropList creates a new PropList as an instance of a property list class.
func NewPropList(cls_id PropType) (*PropList, error) {
	hid := C.H5Pcreate(C.hid_t(cls_id))
	if err := checkID(hid); err != nil {
		return nil, err
	}
	return newPropList(hid), nil
}
示例#8
0
文件: h5p.go 项目: pauh/go-hdf5
// Creates a new property as an instance of a property list class.
// hid_t H5Pcreate(hid_t cls_id )
func NewPropList(cls_id PropType) (*PropList, error) {
	hid := C.H5Pcreate(C.hid_t(cls_id))
	err := h5err(C.herr_t(int(hid)))
	if err != nil {
		return nil, err
	}
	p := new_proplist(hid)
	return p, err
}
示例#9
0
// Opens a named datatype.
// hid_t H5Topen2( hid_t loc_id, const char * name, hid_t tapl_id )
func (f *File) OpenDataType(name string, tapl_id int) (*DataType, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Topen2(f.id, c_name, C.hid_t(tapl_id))
	err := togo_err(C.herr_t(hid))
	if err != nil {
		return nil, err
	}
	dt := &DataType{id: hid}
	runtime.SetFinalizer(dt, (*DataType).h5t_finalizer)
	return dt, err
}
示例#10
0
// Opens an existing group in a file.
// hid_t H5Gopen2( hid_t loc_id, const char * name, hid_t gapl_id )
func (f *File) OpenGroup(name string, gapl_flag int) (g *Group, err error) {
	g = nil
	err = nil

	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	hid := C.H5Gopen2(f.id, c_name, C.hid_t(gapl_flag))
	err = togo_err(C.herr_t(int(hid)))
	if err != nil {
		return
	}
	g = &Group{id: hid}
	runtime.SetFinalizer(g, (*Group).h5g_finalizer)
	return
}