package nosqldb_sdk import ( "C" ) import ( "strings" "unsafe" "github.com/oracle/nosql-go-sdk/nosqldb" "github.com/oracle/nosql-go-sdk/nosqldb/common" "nosql_db_sdk_ffi/util/ptrproxy" ) //export ffi_nosqldb_config_new func ffi_nosqldb_config_new() NosqldbConfig { cfg := nosqldb.Config{} return NosqldbConfig(ptrproxy.Ref(unsafe.Pointer(&cfg))) } const ( endpoint = iota mode region username password ) //export ffi_nosqldb_config_set func ffi_nosqldb_config_set(unsafe_nosqldb_config_ptr NosqldbConfig, key C.uint, value string) Error { nosqldb_config_ptr, ok := ptrproxy.Deref(unsafe.Pointer(unsafe_nosqldb_config_ptr)) if !ok { return C.CString("NosqldbConfigPtr cannot deref") } config := (*nosqldb.Config)(nosqldb_config_ptr) value_cpy := strings.Clone(value) switch key { case endpoint: config.Endpoint = value_cpy case mode: config.Mode = value_cpy case region: config.Region = common.Region(value_cpy) case username: config.Username = value_cpy case password: config.Password = []byte(value_cpy) default: return C.CString("invalid key") } return nil } //export ffi_nosqldb_config_set_logging_config func ffi_nosqldb_config_set_logging_config(unsafe_nosqldb_config_ptr NosqldbConfig, unsafe_nosqldb_logging_config_ptr NosqldbLoggingConfig) Error { nosqldb_config_ptr, ok := ptrproxy.Deref(unsafe.Pointer(unsafe_nosqldb_config_ptr)) if !ok { return C.CString("NosqldbConfigPtr cannot deref") } cfg := (*nosqldb.Config)(nosqldb_config_ptr) nosqldb_logging_config_ptr, ok := ptrproxy.Move(unsafe.Pointer(unsafe_nosqldb_logging_config_ptr)) if !ok { return C.CString("NosqldbLoggingConfigPtr cannot deref") } lcfg := (*nosqldb.LoggingConfig)(nosqldb_logging_config_ptr) cfg.LoggingConfig = *lcfg return nil }