3e74d0d8创建于 2025年12月15日历史提交

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

Name typedef Keyword Description
OH_Data_Values OH_Data_Values Defines the OH_Data_Values struct.

Functions

Name Description
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

Type Description
OH_Data_Values Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
const OH_Data_Value *val Pointer to the OH_Data_Value instance.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int64_t val Pointer to the integer to add.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
double val Pointer to the REAL data to add.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
const char *val Pointer to the string to add.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
const unsigned char *val Pointer to the BLOB data to add.
size_t length Length of the BLOB data to add.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
const Data_Asset *val Pointer to the Data_Asset instance.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
const Data_Asset * const * val Pointer to the Data_Asset instance.
size_t length Number of elements in the Data_Asset object to add.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
const float *val Pointer to the float array to add.
size_t length Length of the float array to add.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int sign Sign 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 *trueForm Pointer to the integer array to add.
size_t length Length of the integer array to add.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
size_t *count Pointer to the number of values contained in values obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
OH_ColumnType *type Pointer to the data type obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
OH_Data_Value **val Double pointer to the OH_Data_Value instance.
You do not need to apply for or release memory for it.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
bool *val Pointer to the check result. The value true means the value is empty, and the value false means the opposite.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
int64_t *val Pointer to the integer data obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
double *val Pointer to the REAL data obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
const char **val Pointer 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

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
const uint8_t **val Double 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 *length Pointer to the length of the BLOB data obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
Data_Asset *val Pointer to the Data_Asset instance.
Data memory should be requested.
This function is used to fill in data only. Otherwise, the execution fails.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
size_t *length Pointer to the length of the ASSETS data obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
Data_Asset **val Double 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 inLen Size of val, which can be obtained using OH_Values_GetAssetsCount.
size_t *outLen Pointer to the actual length of the data obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
size_t *length Pointer to the length of the float data obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
float *val Pointer 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 inLen Size of val, which can be obtained using OH_Values_GetFloatVectorCount.
size_t *outLen Pointer to the actual length of the data obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
size_t *length Pointer to the length of the integer obtained.

Returns

Type Description
int Returns 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

Name Description
OH_Data_Values *values Pointer to the OH_Data_Values instance.
int index Index of the value to check, which starts from 0 in values.
int *sign Pointer 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 *trueForm Pointer 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 inLen trueForm length, which can be obtained using OH_Values_GetUnlimitedIntBand.
size_t *outLen Pointer to the actual length of the data obtained.

Returns

Type Description
int Returns 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.