コード例 #1
0
ファイル: node.go プロジェクト: caervs/golibrdf
//NewNode constructs a new node from a string literal
func NewNodeFromLiteral(world *World, literal string) (*Node, error) {
	node, err := NewNode(world)

	if err != nil {
		return nil, err
	}

	cLiteralString := C.CString(literal)
	defer C.free(unsafe.Pointer(cLiteralString))

	node.librdf_node = C.librdf_new_node_from_literal(world.librdf_world, (*C.uchar)(unsafe.Pointer(cLiteralString)), nil, 0)

	return node, nil
}
コード例 #2
0
ファイル: node.go プロジェクト: caervs/golibrdf
//NewNode constructs a new node from an xml literal
func NewNodeFromXmlLiteral(world *World, xmlLiteral string, xmlLanguage string) (*Node, error) {
	node, err := NewNode(world)

	if err != nil {
		return nil, err
	}

	cLiteralString := C.CString(xmlLiteral)
	defer C.free(unsafe.Pointer(cLiteralString))

	cXmlLangString := C.CString(xmlLanguage)
	defer C.free(unsafe.Pointer(cLiteralString))

	node.librdf_node = C.librdf_new_node_from_literal(world.librdf_world, (*C.uchar)(unsafe.Pointer(cLiteralString)), cXmlLangString, 1)

	return node, nil
}