openharmony 鸿蒙 capi-oh-data-values-h

2026-08-25 浏览 (1)

oh_data_values.h

Overview

Defines APIs and enums related to multiple data values.

File to include: <database/data/oh_data_values.h>

Library: libnative_rdb_ndk.z.so

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Since: 18

Related module: RDB

Summary

Structs

Nametypedef KeywordDescription
OH_Data_ValuesOH_Data_ValuesDefines the OH_Data_Values struct.

Functions

NameDescription
OH_Data_Values *OH_Values_Create(void)Creates an OH_Data_Values instance to store multiple KV pairs.
int OH_Values_Destroy(OH_Data_Values *values)Destroys an OH_Data_Values instance.
int OH_Values_Put(OH_Data_Values *values, const OH_Data_Value *val)Adds data of the OH_Data_Value type to an OH_Data_Values instance.
int OH_Values_PutNull(OH_Data_Values *values)Adds empty data to an OH_Data_Values instance.
int OH_Values_PutInt(OH_Data_Values *values, int64_t val)Adds an integer to an OH_Data_Values instance.
int OH_Values_PutReal(OH_Data_Values *values, double val)Adds REAL data to an OH_Data_Values instance.
int OH_Values_PutText(OH_Data_Values *values, const char *val)Adds a string to an OH_Data_Values instance.
int OH_Values_PutBlob(OH_Data_Values *values, const unsigned char *val, size_t length)Adds BLOB data to an OH_Data_Values instance.
int OH_Values_PutAsset(OH_Data_Values *values, const Data_Asset *val)Adds an asset to an OH_Data_Values instance.
int OH_Values_PutAssets(OH_Data_Values *values, const Data_Asset * const * val, size_t length)Adds assets to an OH_Data_Values instance.
int OH_Values_PutFloatVector(OH_Data_Values *values, const float *val, size_t length)Adds a float array to an OH_Data_Values instance.
int OH_Values_PutUnlimitedInt(OH_Data_Values *values, int sign, const uint64_t *trueForm, size_t length)Adds an integer array of any length to an OH_Data_Values instance.
int OH_Values_Count(OH_Data_Values *values, size_t *count)Obtains the number of values in an OH_Data_Values instance.
int OH_Values_GetType(OH_Data_Values *values, int index, OH_ColumnType *type)Obtains the type of a value in an OH_Data_Values instance.
int OH_Values_Get(OH_Data_Values *values, int index, OH_Data_Value **val)Obtains data of the OH_Data_Value type.
int OH_Values_IsNull(OH_Data_Values *values, int index, bool *val)Checks whether a value is null.
int OH_Values_GetInt(OH_Data_Values *values, int index, int64_t *val)Obtains the integer from an OH_Data_Values instance.
int OH_Values_GetReal(OH_Data_Values *values, int index, double *val)Obtains the REAL data from an OH_Data_Values instance.
int OH_Values_GetText(OH_Data_Values *values, int index, const char **val)Obtains the string from an OH_Data_Values instance.
int OH_Values_GetBlob(OH_Data_Values *values, int index, const uint8_t **val, size_t *length)Obtains the BLOB data from an OH_Data_Values instance.
int OH_Values_GetAsset(OH_Data_Values *values, int index, Data_Asset *val)Obtains the asset from an OH_Data_Values instance.
int OH_Values_GetAssetsCount(OH_Data_Values *values, int index, size_t *length)Obtains the length of the asset in an OH_Data_Values instance.
int OH_Values_GetAssets(OH_Data_Values *values, int index, Data_Asset **val, size_t inLen, size_t *outLen)Obtains the assets from an OH_Data_Values instance.
int OH_Values_GetFloatVectorCount(OH_Data_Values *values, int index, size_t *length)Obtains the length of the float array in an OH_Data_Values instance.
int OH_Values_GetFloatVector(OH_Data_Values *values, int index, float *val, size_t inLen, size_t *outLen)Obtains the float array from an OH_Data_Values instance.
int OH_Values_GetUnlimitedIntBand(OH_Data_Values *values, int index, size_t *length)Obtains the length of the unlimited integer from an OH_Data_Values instance.
int OH_Values_GetUnlimitedInt(OH_Data_Values *values, int index, int *sign, uint64_t *trueForm, size_t inLen,size_t *outLen)Obtains the unlimited integer from an OH_Data_Values instance.

Function Description

OH_Values_Create()

OH_Data_Values *OH_Values_Create(void)

Description

Creates an OH_Data_Values instance to store multiple KV pairs.

Since: 18

Returns

TypeDescription
OH_Data_ValuesReturns a pointer to the OH_Data_Values instance created if the operation is successful; returns nullptr otherwise.
Use OH_Values_Destroy to release the memory in time.

OH_Values_Destroy()

int OH_Values_Destroy(OH_Data_Values *values)

Description

Destroys an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_Put()

int OH_Values_Put(OH_Data_Values *values, const OH_Data_Value *val)

Description

Adds data of the OH_Data_Value type to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
const OH_Data_Value *valPointer to the OH_Data_Value instance.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_PutNull()

int OH_Values_PutNull(OH_Data_Values *values)

Description

Adds empty data to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_PutInt()

int OH_Values_PutInt(OH_Data_Values *values, int64_t val)

Description

Adds an integer to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int64_t valPointer to the integer to add.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_PutReal()

int OH_Values_PutReal(OH_Data_Values *values, double val)

Description

Adds REAL data to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
double valPointer to the REAL data to add.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_PutText()

int OH_Values_PutText(OH_Data_Values *values, const char *val)

Description

Adds a string to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
const char *valPointer to the string to add.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_PutBlob()

int OH_Values_PutBlob(OH_Data_Values *values, const unsigned char *val, size_t length)

Description

Adds BLOB data to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
const unsigned char *valPointer to the BLOB data to add.
size_t lengthLength of the BLOB data to add.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_PutAsset()

int OH_Values_PutAsset(OH_Data_Values *values, const Data_Asset *val)

Description

Adds an asset to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
const Data_Asset *valPointer to the Data_Asset instance.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_PutAssets()

int OH_Values_PutAssets(OH_Data_Values *values, const Data_Asset * const * val, size_t length)

Description

Adds assets to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
const Data_Asset * const * valPointer to the Data_Asset instance.
size_t lengthNumber of elements in the Data_Asset object to add.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_PutFloatVector()

int OH_Values_PutFloatVector(OH_Data_Values *values, const float *val, size_t length)

Description

Adds a float array to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
const float *valPointer to the float array to add.
size_t lengthLength of the float array to add.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_PutUnlimitedInt()

int OH_Values_PutUnlimitedInt(OH_Data_Values *values, int sign, const uint64_t *trueForm, size_t length)

Description

Adds an integer array of any length to an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int signSign notation of the integer array to add. The value 0 indicates a positive integer, and the value 1 indicates a negative integer.
const uint64_t *trueFormPointer to the integer array to add.
size_t lengthLength of the integer array to add.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_Count()

int OH_Values_Count(OH_Data_Values *values, size_t *count)

Description

Obtains the number of records in an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
size_t *countPointer to the number of values contained in values obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_GetType()

int OH_Values_GetType(OH_Data_Values *values, int index, OH_ColumnType *type)

Description

Obtains the data type.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
OH_ColumnType *typePointer to the data type obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_Get()

int OH_Values_Get(OH_Data_Values *values, int index, OH_Data_Value **val)

Description

Obtains data of the OH_Data_Value type.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
OH_Data_Value **valDouble pointer to the OH_Data_Value instance.
You do not need to apply for or release memory for it.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_IsNull()

int OH_Values_IsNull(OH_Data_Values *values, int index, bool *val)

Description

Checks whether a value is null.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
bool *valPointer to the check result. The value true means the value is empty, and the value false means the opposite.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Values_GetInt()

int OH_Values_GetInt(OH_Data_Values *values, int index, int64_t *val)

Description

Obtains the integer from an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
int64_t *valPointer to the integer data obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetReal()

int OH_Values_GetReal(OH_Data_Values *values, int index, double *val)

Description

Obtains the REAL data from an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
double *valPointer to the REAL data obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetText()

int OH_Values_GetText(OH_Data_Values *values, int index, const char **val)

Description

Obtains the string from an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
const char **valPointer to the string obtained.
You do not need to apply for or release memory for it.
The lifecycle of val complies with the value of index in values.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetBlob()

int OH_Values_GetBlob(OH_Data_Values *values, int index, const uint8_t **val, size_t *length)

Description

Obtains the BLOB data from an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
const uint8_t **valDouble pointer to the BLOB data obtained.
You do not need to apply for or release memory for it.
The lifecycle of val complies with the value of index in values.
size_t *lengthPointer to the length of the BLOB data obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetAsset()

int OH_Values_GetAsset(OH_Data_Values *values, int index, Data_Asset *val)

Description

Obtains the asset from an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
Data_Asset *valPointer to the Data_Asset instance.
Data memory should be requested.
This function is used to fill in data only. Otherwise, the execution fails.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetAssetsCount()

int OH_Values_GetAssetsCount(OH_Data_Values *values, int index, size_t *length)

Description

Obtains the length of the asset in an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
size_t *lengthPointer to the length of the ASSETS data obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetAssets()

int OH_Values_GetAssets(OH_Data_Values *values, int index, Data_Asset **val, size_t inLen, size_t *outLen)

Description

Obtains the assets from an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
Data_Asset **valDouble pointer to the Data_Asset instance.
Data memory should be requested.
This function is used to fill in data only. Otherwise, the execution fails.
size_t inLenSize of val, which can be obtained using OH_Values_GetAssetsCount.
size_t *outLenPointer to the actual length of the data obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetFloatVectorCount()

int OH_Values_GetFloatVectorCount(OH_Data_Values *values, int index, size_t *length)

Description

Obtains the length of the float array in an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
size_t *lengthPointer to the length of the float data obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetFloatVector()

int OH_Values_GetFloatVector(OH_Data_Values *values, int index, float *val, size_t inLen, size_t *outLen)

Description

Obtains the float array from an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
float *valPointer to the float array obtained.
Data memory should be requested.
This function is used to fill in data only. Otherwise, the execution fails.
size_t inLenSize of val, which can be obtained using OH_Values_GetFloatVectorCount.
size_t *outLenPointer to the actual length of the data obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetUnlimitedIntBand()

int OH_Values_GetUnlimitedIntBand(OH_Data_Values *values, int index, size_t *length)

Description

Obtains the length of the unlimited integer from an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
size_t *lengthPointer to the length of the integer obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

OH_Values_GetUnlimitedInt()

int OH_Values_GetUnlimitedInt(OH_Data_Values *values, int index, int *sign, uint64_t *trueForm, size_t inLen, size_t *outLen)

Description

Obtains the unlimited integer from an OH_Data_Values instance.

Since: 18

Parameters

NameDescription
OH_Data_Values *valuesPointer to the OH_Data_Values instance.
int indexIndex of the value to check, which starts from 0 in values.
int *signPointer to the sign notation of the integer obtained. The value 0 indicates a positive integer, and the value 1 indicates a negative integer.
uint64_t *trueFormPointer to the integer array obtained.
Data memory should be requested.
This function is used to fill in data only. Otherwise, the execution fails.
size_t inLentrueForm length, which can be obtained using OH_Values_GetUnlimitedIntBand.
size_t *outLenPointer to the actual length of the data obtained.

Returns

TypeDescription
intReturns an error code.
RDB_OK indicates the operation is successful.
RDB_E_INVALID_ARGS indicates invalid parameters are specified.
RDB_E_DATA_TYPE_NULL indicates the stored data is empty.
RDB_E_TYPE_MISMATCH indicates the data types do not match.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 js-apis-distributedKVStore-sys

openharmony 鸿蒙 capi-oh-preferences-h

openharmony 鸿蒙 capi-udmf-oh-udshyperlink

openharmony 鸿蒙 js-apis-data-dataSharePredicates

openharmony 鸿蒙 capi-udmf-oh-udsappitem

openharmony 鸿蒙 capi-rdb-oh-data-vbuckets

openharmony 鸿蒙 capi-rdb-oh-predicates

openharmony 鸿蒙 capi-rdb-oh-data-value

openharmony 鸿蒙 capi-preferences-oh-preferencespair

openharmony 鸿蒙 errorcode-datashare

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/4bFmbw2j