예제 #1
0
func GetAllSchemeDetails() []*SchemeDetails {
	allHandles := C.varnam_get_all_handles()
	if allHandles == nil {
		return []*SchemeDetails{}
	}

	var schemeDetails []*SchemeDetails
	length := int(C.varray_length(allHandles))
	for i := 0; i < length; i++ {
		handle := (*C.varnam)(C.varray_get(allHandles, C.int(i)))
		var detail *C.vscheme_details
		rc := C.varnam_get_scheme_details(handle, &detail)
		if rc != C.VARNAM_SUCCESS {
			return []*SchemeDetails{}
		}

		schemeDetails = append(schemeDetails, &SchemeDetails{
			LangCode: C.GoString(detail.langCode), Identifier: C.GoString(detail.identifier),
			DisplayName: C.GoString(detail.displayName), Author: C.GoString(detail.author),
			CompiledDate: C.GoString(detail.compiledDate), IsStable: detail.isStable > 0})

		C.varnam_destroy(handle)
	}

	return schemeDetails
}
예제 #2
0
func (v *Varnam) Transliterate(text string) []string {
	var va *C.varray
	C.varnam_transliterate(v.handle, C.CString(text), &va)
	var i C.int
	var array []string
	for i = 0; i < C.varray_length(va); i++ {
		word := (*C.vword)(C.varray_get(va, i))
		array = append(array, C.GoString(word.text))
	}
	return array
}
예제 #3
0
func (v *Varnam) Transliterate(text string) ([]string, error) {
	var va *C.varray
	rc := C.varnam_transliterate(v.handle, C.CString(text), &va)
	if rc != C.VARNAM_SUCCESS {
		errorCode := (int)(rc)
		return nil, &VarnamError{errorCode: errorCode, message: v.getVarnamError(errorCode)}
	}
	var i C.int
	var array []string
	for i = 0; i < C.varray_length(va); i++ {
		word := (*C.vword)(C.varray_get(va, i))
		array = append(array, C.GoString(word.text))
	}
	return array, nil
}