1# inputmethod_private_command_capi.h 2<!--Kit: IME Kit--> 3<!--Subsystem: MiscServices--> 4<!--Owner: @illybyy--> 5<!--Designer: @andeszhang--> 6<!--Tester: @murphy1984--> 7<!--Adviser: @zhang_yixin13--> 8 9## 概述 10 11提供私有数据对象的创建、销毁与读写方法。 12 13**引用文件:** <inputmethod/inputmethod_private_command_capi.h> 14 15**库:** libohinputmethod.so 16 17**系统能力:** SystemCapability.MiscServices.InputMethodFramework 18 19**起始版本:** 12 20 21**相关模块:** [InputMethod](capi-inputmethod.md) 22 23## 汇总 24 25### 结构体 26 27| 名称 | typedef关键字 | 描述 | 28| -- | -- | -- | 29| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) | InputMethod_PrivateCommand | 表示私有数据的结构体类型。输入框和输入法应用之间交互的私有数据。 | 30 31### 函数 32 33| 名称 | 描述 | 34| -- |-----------------------------------------------------| 35| [InputMethod_PrivateCommand *OH_PrivateCommand_Create(char key[], size_t keyLength)](#oh_privatecommand_create) | 创建一个新的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例。 | 36| [void OH_PrivateCommand_Destroy(InputMethod_PrivateCommand *command)](#oh_privatecommand_destroy) | 销毁一个[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例。 | 37| [InputMethod_ErrorCode OH_PrivateCommand_SetKey(InputMethod_PrivateCommand *command, char key[], size_t keyLength)](#oh_privatecommand_setkey) | 设置[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)的key值。 | 38| [InputMethod_ErrorCode OH_PrivateCommand_SetBoolValue(InputMethod_PrivateCommand *command, bool value)](#oh_privatecommand_setboolvalue) | 设置[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)的布尔类型value值。 | 39| [InputMethod_ErrorCode OH_PrivateCommand_SetIntValue(InputMethod_PrivateCommand *command, int32_t value)](#oh_privatecommand_setintvalue) | 设置[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)的整数类型value值。 | 40| [InputMethod_ErrorCode OH_PrivateCommand_SetStrValue(InputMethod_PrivateCommand *command, char value[], size_t valueLength)](#oh_privatecommand_setstrvalue) | 设置[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)的字符串类型value值。 | 41| [InputMethod_ErrorCode OH_PrivateCommand_GetKey(InputMethod_PrivateCommand *command, const char **key, size_t *keyLength)](#oh_privatecommand_getkey) | 从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取key值。 | 42| [InputMethod_ErrorCode OH_PrivateCommand_GetValueType(InputMethod_PrivateCommand *command, InputMethod_CommandValueType *type)](#oh_privatecommand_getvaluetype) | 从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取value的数据类型。 | 43| [InputMethod_ErrorCode OH_PrivateCommand_GetBoolValue(InputMethod_PrivateCommand *command, bool *value)](#oh_privatecommand_getboolvalue) | 从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取布尔类型的value的值。 | 44| [InputMethod_ErrorCode OH_PrivateCommand_GetIntValue(InputMethod_PrivateCommand *command, int32_t *value)](#oh_privatecommand_getintvalue) | 从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取整数类型的value的值。 | 45| [InputMethod_ErrorCode OH_PrivateCommand_GetStrValue(InputMethod_PrivateCommand *command, const char **value, size_t *valueLength)](#oh_privatecommand_getstrvalue) | 从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取字符串类型的value的值。 | 46 47## 函数说明 48 49### OH_PrivateCommand_Create() 50 51``` 52InputMethod_PrivateCommand *OH_PrivateCommand_Create(char key[], size_t keyLength) 53``` 54 55**描述** 56 57创建一个新的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例。 58 59**起始版本:** 12 60 61 62**参数:** 63 64| 参数项 | 描述 | 65| -- | -- | 66| char key[] | 私有数据的key值。 | 67| size_t keyLength | key长度。 | 68 69**返回:** 70 71| 类型 | 说明 | 72| -- | -- | 73| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) * | 如果创建成功,返回一个指向新创建的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。<br> 如果创建失败,对象返回NULL,可能的失败原因有应用地址空间满。 | 74 75### OH_PrivateCommand_Destroy() 76 77``` 78void OH_PrivateCommand_Destroy(InputMethod_PrivateCommand *command) 79``` 80 81**描述** 82 83销毁一个[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例。 84 85**起始版本:** 12 86 87 88**参数:** 89 90| 参数项 | 描述 | 91| -- | -- | 92| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被销毁的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 93 94### OH_PrivateCommand_SetKey() 95 96``` 97InputMethod_ErrorCode OH_PrivateCommand_SetKey(InputMethod_PrivateCommand *command, char key[], size_t keyLength) 98``` 99 100**描述** 101 102设置[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)的key值。 103 104**起始版本:** 12 105 106 107**参数:** 108 109| 参数项 | 描述 | 110| -- | -- | 111| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被设置的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 112| char key[] | key值。 | 113| size_t keyLength | key长度。 | 114 115**返回:** 116 117| 类型 | 说明 | 118| -- | -- | 119| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | 返回一个特定的错误码。<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 表示成功。<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 非预期的空指针。<br> 具体错误码可以参考 [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode)。 | 120 121### OH_PrivateCommand_SetBoolValue() 122 123``` 124InputMethod_ErrorCode OH_PrivateCommand_SetBoolValue(InputMethod_PrivateCommand *command, bool value) 125``` 126 127**描述** 128 129设置[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)的布尔类型value值。 130 131**起始版本:** 12 132 133 134**参数:** 135 136| 参数项 | 描述 | 137| -- | -- | 138| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被设置的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 139| bool value | 布尔类型value值。 | 140 141**返回:** 142 143| 类型 | 说明 | 144| -- | -- | 145| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | 返回一个特定的错误码。<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 表示成功。<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 非预期的空指针。<br> 具体错误码可以参考 [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode)。 | 146 147### OH_PrivateCommand_SetIntValue() 148 149``` 150InputMethod_ErrorCode OH_PrivateCommand_SetIntValue(InputMethod_PrivateCommand *command, int32_t value) 151``` 152 153**描述** 154 155设置[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)的整数类型value值。 156 157**起始版本:** 12 158 159 160**参数:** 161 162| 参数项 | 描述 | 163| -- | -- | 164| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被设置的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 165| int32_t value | 整型value值。 | 166 167**返回:** 168 169| 类型 | 说明 | 170| -- | -- | 171| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | 返回一个特定的错误码。<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 表示成功。<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 非预期的空指针。<br> 具体错误码可以参考 [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode)。 | 172 173### OH_PrivateCommand_SetStrValue() 174 175``` 176InputMethod_ErrorCode OH_PrivateCommand_SetStrValue(InputMethod_PrivateCommand *command, char value[], size_t valueLength) 177``` 178 179**描述** 180 181设置[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)的字符串类型value值。 182 183**起始版本:** 12 184 185 186**参数:** 187 188| 参数项 | 描述 | 189| -- | -- | 190| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被设置的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 191| char value[] | 字符串类型value值。 | 192| size_t valueLength | 表示字符串数据值的长度。 | 193 194**返回:** 195 196| 类型 | 说明 | 197| -- | -- | 198| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | 返回一个特定的错误码。<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 表示成功。<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 非预期的空指针。<br> 具体错误码可以参考 [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode)。 | 199 200### OH_PrivateCommand_GetKey() 201 202``` 203InputMethod_ErrorCode OH_PrivateCommand_GetKey(InputMethod_PrivateCommand *command, const char **key, size_t *keyLength) 204``` 205 206**描述** 207 208从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取key值。 209 210**起始版本:** 12 211 212 213**参数:** 214 215| 参数项 | 描述 | 216| -- | -- | 217| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被获取key值的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 218| const char **key | key的生命周期和command一致。不要直接保存key地址,或者直接写key。建议拷贝后使用。 | 219| size_t *keyLength | key长度。 | 220 221**返回:** 222 223| 类型 | 说明 | 224| -- | -- | 225| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | 返回一个特定的错误码。<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 表示成功。<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 非预期的空指针。<br> 具体错误码可以参考 [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode)。 | 226 227### OH_PrivateCommand_GetValueType() 228 229``` 230InputMethod_ErrorCode OH_PrivateCommand_GetValueType(InputMethod_PrivateCommand *command, InputMethod_CommandValueType *type) 231``` 232 233**描述** 234 235从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取value的数据类型。 236 237**起始版本:** 12 238 239 240**参数:** 241 242| 参数项 | 描述 | 243| -- | -- | 244| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被获取value值的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 245| [InputMethod_CommandValueType](capi-inputmethod-types-capi-h.md#inputmethod_commandvaluetype) *type | 表示指向 [InputMethod_CommandValueType](capi-inputmethod-types-capi-h.md#inputmethod_commandvaluetype) 实例的指针。 用于value值的数据类型。 | 246 247**返回:** 248 249| 类型 | 说明 | 250| -- | -- | 251| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | 返回一个特定的错误码。<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 表示成功。<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 非预期的空指针。<br> 具体错误码可以参考 [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode)。 | 252 253### OH_PrivateCommand_GetBoolValue() 254 255``` 256InputMethod_ErrorCode OH_PrivateCommand_GetBoolValue(InputMethod_PrivateCommand *command, bool *value) 257``` 258 259**描述** 260 261从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取布尔类型的value的值。 262 263**起始版本:** 12 264 265 266**参数:** 267 268| 参数项 | 描述 | 269| -- | -- | 270| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被获取value值的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 271| bool *value | 布尔类型的value的值。 | 272 273**返回:** 274 275| 类型 | 说明 | 276| -- | -- | 277| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | 返回一个特定的错误码。<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 表示成功。<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 非预期的空指针。<br> [IME_ERR_QUERY_FAILED](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 查询失败,命令中没有布尔值。<br> 具体错误码可以参考 [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode)。 | 278 279### OH_PrivateCommand_GetIntValue() 280 281``` 282InputMethod_ErrorCode OH_PrivateCommand_GetIntValue(InputMethod_PrivateCommand *command, int32_t *value) 283``` 284 285**描述** 286 287从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取整数类型的value的值。 288 289**起始版本:** 12 290 291 292**参数:** 293 294| 参数项 | 描述 | 295| -- | -- | 296| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被获取value值的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 297| int32_t *value | 整数类型的value的值。 | 298 299**返回:** 300 301| 类型 | 说明 | 302| -- | -- | 303| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | 返回一个特定的错误码。<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 表示成功。<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 非预期的空指针。<br> [IME_ERR_QUERY_FAILED](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 查询失败,命令中没有布尔值。<br> 具体错误码可以参考 [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode)。 | 304 305### OH_PrivateCommand_GetStrValue() 306 307``` 308InputMethod_ErrorCode OH_PrivateCommand_GetStrValue(InputMethod_PrivateCommand *command, const char **value, size_t *valueLength) 309``` 310 311**描述** 312 313从[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)获取字符串类型的value的值。 314 315**起始版本:** 12 316 317 318**参数:** 319 320| 参数项 | 描述 | 321| -- | -- | 322| [InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md) *command | 指向即将被获取value值的[InputMethod_PrivateCommand](capi-inputmethod-inputmethod-privatecommand.md)实例的指针。 | 323| const char **value | 字符串类型的value的值。 | 324| size_t *valueLength | value的生命周期和command一致。不要直接保存value地址,或者直接写value。建议拷贝后使用。 | 325 326**返回:** 327 328| 类型 | 说明 | 329| -- | -- | 330| [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) | 返回一个特定的错误码。<br> [IME_ERR_OK](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 表示成功。<br> [IME_ERR_NULL_POINTER](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 非预期的空指针。<br> [IME_ERR_QUERY_FAILED](capi-inputmethod-types-capi-h.md#inputmethod_errorcode) - 查询失败,命令中没有布尔值。<br> 具体错误码可以参考 [InputMethod_ErrorCode](capi-inputmethod-types-capi-h.md#inputmethod_errorcode)。 | 331 332 333