Signed-off-by: lihuihui <lihuihui29@huawei.com>
This commit is contained in:
lihuihui 2023-05-12 10:09:01 +08:00
parent 7a609a2c2d
commit ada708a2bd
22 changed files with 284 additions and 293 deletions

View File

@ -328,14 +328,14 @@ int AbsSharedResultSet::GetSize(int columnIndex, size_t &size)
}
AppDataFwk::SharedBlock::CellUnit *cellUnit = sharedBlock_->GetCellUnit(sharedBlock_->GetBlockPos(), columnIndex);
if (!cellUnit) {
if (cellUnit == nullptr) {
LOG_ERROR("cellUnit is null!");
return E_ERROR;
}
int type = cellUnit->type;
if (type == AppDataFwk::SharedBlock::CELL_UNIT_TYPE_BLOB
|| type == AppDataFwk::SharedBlock::CELL_UNIT_TYPE_STRING
if (type == AppDataFwk::SharedBlock::CELL_UNIT_TYPE_STRING
|| type == AppDataFwk::SharedBlock::CELL_UNIT_TYPE_BLOB
|| type == AppDataFwk::SharedBlock::CELL_UNIT_TYPE_NULL) {
sharedBlock_->GetCellUnitValueBlob(cellUnit, &size);
return E_OK;

View File

@ -409,7 +409,7 @@ int SqliteStatement::GetSize(int index, size_t &size) const
size = sqlite3_column_bytes(stmtHandle, index);
return E_OK;
}
return E_INVALID_COLUMN_TYPE;
}

View File

@ -115,7 +115,7 @@ public:
RDB_API_EXPORT int GetDouble(int columnIndex, double &value) override;
/**
* @brief Get the size of blob or the text.
* @brief Get the size of blob or text.
*
* @param columnIndex Indicates the zero-based index of the target column.
*/

View File

@ -53,7 +53,7 @@ public:
API_EXPORT virtual int GetRow(RowEntity &rowEntity) = 0;
/**
* @brief Get the size of blob or the text.
* @brief Get the size of blob or text.
*
* @param columnIndex Indicates the zero-based index of the target column.
*/

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -39,12 +39,6 @@ ohos_shared_library("native_rdb_ndk") {
"./include",
"${relational_store_base_path}/frameworks/ndk/include",
]
if (relational_store_rdb_support_icu) {
include_dirs += [
"//third_party/icu/icu4c/source/i18n",
"//third_party/icu/icu4c/source/common",
]
}
sources = [
"${relational_store_base_path}/interfaces/ndk/src/relational_cursor.cpp",
"${relational_store_base_path}/interfaces/ndk/src/relational_predicates.cpp",
@ -57,14 +51,11 @@ ohos_shared_library("native_rdb_ndk") {
deps = [ "//third_party/sqlite:sqlite" ]
external_deps = [
"ability_runtime:abilitykit_native",
"c_utils:utils",
"hilog_native:libhilog",
"ipc:ipc_single",
"relational_store:native_rdb",
]
innerapi_tags = [ "platformsdk" ]
part_name = "relational_store"
subsystem_name = "distributeddatamgr"
}

View File

@ -22,18 +22,18 @@
extern "C" {
#endif
enum ColumnType {
TYPE_NULL = 0,
TYPE_INT64,
TYPE_REAL,
TYPE_TEXT,
TYPE_BLOB,
enum OH_Rdb_ColumnType {
RDB_TYPE_NULL = 0,
RDB_TYPE_INT64,
RDB_TYPE_REAL,
RDB_TYPE_TEXT,
RDB_TYPE_BLOB,
};
struct OH_Cursor{
typedef struct OH_Cursor{
int id;
int (*OH_Cursor_GetColumnCount)(OH_Cursor *, int *);
int (*OH_Cursor_GetColumnType)(OH_Cursor *, int32_t, ColumnType *);
int (*OH_Cursor_GetColumnType)(OH_Cursor *, int32_t, OH_Rdb_ColumnType *);
int (*OH_Cursor_GetColumnIndex)(OH_Cursor *, const char *, int *);
int (*OH_Cursor_GetColumnName)(OH_Cursor *, int32_t, char *, int);
int (*OH_Cursor_GetRowCount)(OH_Cursor *, int *);
@ -45,11 +45,11 @@ struct OH_Cursor{
int (*OH_Cursor_GetBlob)(OH_Cursor *, int32_t, unsigned char *, int);
int (*OH_Cursor_IsNull)(OH_Cursor *, int32_t, bool *);
int (*OH_Cursor_Close)(OH_Cursor *);
};
} OH_Cursor;
int CURSOR_GetColumnCount(OH_Cursor *cursor, int *count);
int CURSOR_GetColumnType(OH_Cursor *cursor, int32_t columnIndex, ColumnType *columnType);
int CURSOR_GetColumnIndex(OH_Cursor *cursor, const char *names, int *columnIndex);
int CURSOR_GetColumnType(OH_Cursor *cursor, int32_t columnIndex, OH_Rdb_ColumnType *columnType);
int CURSOR_GetColumnIndex(OH_Cursor *cursor, const char *name, int *columnIndex);
int CURSOR_GetColumnName(OH_Cursor *cursor, int32_t columnIndex, char *name, int length);
int CURSOR_GetRowCount(OH_Cursor *cursor, int *count);
int CURSOR_GoToNextRow(OH_Cursor *cursor);
@ -65,4 +65,4 @@ int CURSOR_Close(OH_Cursor *cursor);
};
#endif
#endif //RELATIONAL_CURSOR_H
#endif // RELATIONAL_CURSOR_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -20,14 +20,14 @@
extern "C" {
#endif
enum RDB_ErrCode {
E_INVALID_ARG = -2,
E_ERROR = -1,
E_OK = 0,
enum OH_Rdb_ErrCode {
RDB_ERR_INVALID_ARGS = -2,
RDB_ERR = -1,
RDB_ERR_OK = 0
};
#ifdef __cplusplus
};
#endif
#endif //RELATIONAL_ERRNO_CODE_H
#endif // RELATIONAL_ERRNO_CODE_H

View File

@ -20,12 +20,12 @@
extern "C" {
#endif
enum OrderByType {
ASC = 0,
DESC = 1,
enum OH_Rdb_OrderByType {
RDB_PRE_ASC = 0,
RDB_PRE_DESC = 1,
};
struct OH_Predicates{
typedef struct OH_Predicates{
int id;
int (*OH_Predicates_EqualTo)(OH_Predicates *, const char *, const char *);
int (*OH_Predicates_NotEqualTo)(OH_Predicates *, const char *, const char *);
@ -42,7 +42,7 @@ struct OH_Predicates{
int (*OH_Predicates_LessThan)(OH_Predicates *, const char *, const char *);
int (*OH_Predicates_GreaterThanOrEqualTo)(OH_Predicates *, const char *, const char *);
int (*OH_Predicates_LessThanOrEqualTo)(OH_Predicates *, const char *, const char *);
int (*OH_Predicates_OrderBy)(OH_Predicates *, const char *, OrderByType);
int (*OH_Predicates_OrderBy)(OH_Predicates *, const char *, OH_Rdb_OrderByType);
int (*OH_Predicates_Distinct)(OH_Predicates *);
int (*OH_Predicates_Limit)(OH_Predicates *, unsigned int);
int (*OH_Predicates_Offset)(OH_Predicates *, unsigned int);
@ -50,7 +50,7 @@ struct OH_Predicates{
int (*OH_Predicates_In)(OH_Predicates *, char const *, char const *const *, const int);
int (*OH_Predicates_NotIn)(OH_Predicates *, char const *, char const *const *, const int);
int (*OH_Predicates_Clear)(OH_Predicates *);
};
} OH_Predicates;
OH_Predicates *OH_Rdb_CreatePredicates(char const *table);
int OH_Rdb_DestroyPredicates(OH_Predicates *predicates);
@ -70,7 +70,7 @@ int PREDICATES_GreaterThan(OH_Predicates *predicates, const char *field, const c
int PREDICATES_LessThan(OH_Predicates *predicates, const char *field, const char *value);
int PREDICATES_GreaterThanOrEqualTo(OH_Predicates *predicates, const char *field, const char *value);
int PREDICATES_LessThanOrEqualTo(OH_Predicates *predicates, const char *field, const char *value);
int PREDICATES_OrderBy(OH_Predicates *predicates, const char *field, OrderByType type);
int PREDICATES_OrderBy(OH_Predicates *predicates, const char *field, OH_Rdb_OrderByType type);
int PREDICATES_Distinct(OH_Predicates *predicates);
int PREDICATES_Limit(OH_Predicates *predicates, unsigned int value);
int PREDICATES_Offset(OH_Predicates *predicates, unsigned int rowOffset);
@ -83,4 +83,4 @@ int PREDICATES_Clear(OH_Predicates *predicates);
};
#endif
#endif //RELATIONAL_PREDICATES_H
#endif // RELATIONAL_PREDICATES_H

View File

@ -24,55 +24,55 @@
extern "C" {
#endif
enum SecurityLevel {
S1 = 1,
S2,
S3,
S4,
LAST
enum OH_Rdb_SecurityLevel {
RDB_S1 = 1,
RDB_S2,
RDB_S3,
RDB_S4,
RDB_LAST
};
enum Bool {
FALSE,
TRUE
};
struct RDB_Config {
const char *path;
enum Bool isEncrypt;
enum SecurityLevel securityLevel;
};
struct RDB_Store {
int id;
enum OH_Rdb_Bool {
RDB_FALSE,
RDB_TRUE
};
typedef struct {
int (*OH_Callback_OnCreate)(RDB_Store *);
int (*OH_Callback_OnUpgrade)(RDB_Store *, int, int);
int (*OH_Callback_OnDowngrade)(RDB_Store *, int, int);
int (*OH_Callback_OnOpen)(RDB_Store *);
int (*OH_Callback_OnCorruption)(const char *);
} RDB_OpenCallback;
const char *path;
enum OH_Rdb_Bool isEncrypt;
enum OH_Rdb_SecurityLevel securityLevel;
} OH_Rdb_Config;
RDB_Store *OH_Rdb_GetOrOpen(RDB_Config const *config, int version, RDB_OpenCallback *openCallback, int *errCode);
int OH_Rdb_CloseStore(RDB_Store *store);
typedef struct {
int id;
} OH_Rdb_Store;
typedef struct {
int (*OH_Callback_OnCreate)(OH_Rdb_Store *);
int (*OH_Callback_OnUpgrade)(OH_Rdb_Store *, int, int);
int (*OH_Callback_OnDowngrade)(OH_Rdb_Store *, int, int);
int (*OH_Callback_OnOpen)(OH_Rdb_Store *);
int (*OH_Callback_OnCorruption)(const char *);
} OH_Rdb_OpenCallback;
OH_Rdb_Store *OH_Rdb_GetOrOpen(OH_Rdb_Config const *config, int version, OH_Rdb_OpenCallback *openCallback, int *errCode);
int OH_Rdb_CloseStore(OH_Rdb_Store *store);
int OH_Rdb_ClearCache();
int OH_Rdb_DeleteStore(const char *path);
int OH_Rdb_Insert(RDB_Store *store, char const *table, RDB_ValuesBucket *valuesBucket);
int OH_Rdb_Update(RDB_Store *store, RDB_ValuesBucket *valuesBucket, OH_Predicates *predicates);
int OH_Rdb_Delete(RDB_Store *store, OH_Predicates *predicate);
OH_Cursor *OH_Rdb_Query(RDB_Store *store, OH_Predicates *predicate, const char **columnNames, int length);
int OH_Rdb_Execute(RDB_Store *store, char const *sql);
OH_Cursor *OH_Rdb_ExecuteQuery(RDB_Store *store, char const *sql);
int OH_Rdb_Transaction(RDB_Store *store);
int OH_Rdb_RollBack(RDB_Store *store);
int OH_Rdb_Commit(RDB_Store *store);
int OH_Rdb_Backup(RDB_Store *store, const char *databasePath);
int OH_Rdb_Restore(RDB_Store *store, const char *databasePath);
int OH_Rdb_GetVersion(RDB_Store *store, int *version);
int OH_Rdb_SetVersion(RDB_Store *store, const int version);
int OH_Rdb_Insert(OH_Rdb_Store *store, char const *table, OH_Rdb_ValuesBucket *valuesBucket);
int OH_Rdb_Update(OH_Rdb_Store *store, OH_Rdb_ValuesBucket *valuesBucket, OH_Predicates *predicates);
int OH_Rdb_Delete(OH_Rdb_Store *store, OH_Predicates *predicate);
OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicate, char const *const *columnNames, int length);
int OH_Rdb_Execute(OH_Rdb_Store *store, char const *sql);
OH_Cursor *OH_Rdb_ExecuteQuery(OH_Rdb_Store *store, char const *sql);
int OH_Rdb_Transaction(OH_Rdb_Store *store);
int OH_Rdb_RollBack(OH_Rdb_Store *store);
int OH_Rdb_Commit(OH_Rdb_Store *store);
int OH_Rdb_Backup(OH_Rdb_Store *store, const char *databasePath);
int OH_Rdb_Restore(OH_Rdb_Store *store, const char *databasePath);
int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version);
int OH_Rdb_SetVersion(OH_Rdb_Store *store, const int version);
#ifdef __cplusplus
};

View File

@ -21,23 +21,23 @@
extern "C" {
#endif
struct RDB_ValuesBucket {
typedef struct {
int id;
uint16_t capability;
};
} OH_Rdb_ValuesBucket;
RDB_ValuesBucket *OH_Rdb_CreateValuesBucket();
int OH_Rdb_DestroyValuesBucket(RDB_ValuesBucket *bucket);
OH_Rdb_ValuesBucket *OH_Rdb_CreateValuesBucket();
int OH_Rdb_DestroyValuesBucket(OH_Rdb_ValuesBucket *bucket);
int OH_VBucket_PutText(RDB_ValuesBucket *bucket, const char *name, const char *value);
int OH_VBucket_PutInt64(RDB_ValuesBucket *bucket, const char *name, int64_t value);
int OH_VBucket_PutReal(RDB_ValuesBucket *bucket, const char *name, double value);
int OH_VBucket_PutBlob(RDB_ValuesBucket *bucket, const char *name, const uint8_t *value, uint32_t size);
int OH_VBucket_PutNull(RDB_ValuesBucket *bucket, const char *name);
int OH_VBucket_Clear(RDB_ValuesBucket *bucket);
int OH_VBucket_PutText(OH_Rdb_ValuesBucket *bucket, const char *name, const char *value);
int OH_VBucket_PutInt64(OH_Rdb_ValuesBucket *bucket, const char *name, int64_t value);
int OH_VBucket_PutReal(OH_Rdb_ValuesBucket *bucket, const char *name, double value);
int OH_VBucket_PutBlob(OH_Rdb_ValuesBucket *bucket, const char *name, const uint8_t *value, uint32_t size);
int OH_VBucket_PutNull(OH_Rdb_ValuesBucket *bucket, const char *name);
int OH_VBucket_Clear(OH_Rdb_ValuesBucket *bucket);
#ifdef __cplusplus
};
#endif
#endif //RELATIONAL_VALUES_BUCKET_H
#endif // RELATIONAL_VALUES_BUCKET_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -47,37 +47,37 @@ std::shared_ptr<OHOS::NativeRdb::ResultSet> OHOS::NativeRdb::CursorImpl::GetResu
int CURSOR_GetColumnCount(OH_Cursor *cursor, int *count)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
return tempCursor->GetResultSet()->GetColumnCount(*count);
}
int CURSOR_GetColumnType(OH_Cursor *cursor, int32_t columnIndex, ColumnType *columnType)
int CURSOR_GetColumnType(OH_Cursor *cursor, int32_t columnIndex, OH_Rdb_ColumnType *columnType)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
OHOS::NativeRdb::ColumnType type;
int error = tempCursor->GetResultSet()->GetColumnType(columnIndex, type);
*columnType = ColumnType((int)type);
*columnType = OH_Rdb_ColumnType((int)type);
return error;
}
int CURSOR_GetColumnIndex(OH_Cursor *cursor, const char *names, int *columnIndex)
int CURSOR_GetColumnIndex(OH_Cursor *cursor, const char *name, int *columnIndex)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
return tempCursor->GetResultSet()->GetColumnIndex(names, *columnIndex);
return tempCursor->GetResultSet()->GetColumnIndex(name, *columnIndex);
}
int CURSOR_GetColumnName(OH_Cursor *cursor, int32_t columnIndex, char *name, int length)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
std::string str;
@ -87,7 +87,7 @@ int CURSOR_GetColumnName(OH_Cursor *cursor, int32_t columnIndex, char *name, int
}
errno_t result = memcpy_s(name, length, str.c_str(), str.length());
if (result != EOK) {
return E_ERROR;
return OH_Rdb_ErrCode::RDB_ERR;
}
return errCode;
}
@ -95,7 +95,7 @@ int CURSOR_GetColumnName(OH_Cursor *cursor, int32_t columnIndex, char *name, int
int CURSOR_GetRowCount(OH_Cursor *cursor, int *count)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
return tempCursor->GetResultSet()->GetRowCount(*count);
@ -104,7 +104,7 @@ int CURSOR_GetRowCount(OH_Cursor *cursor, int *count)
int CURSOR_GoToNextRow(OH_Cursor *cursor)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
return tempCursor->GetResultSet()->GoToNextRow();
@ -113,7 +113,7 @@ int CURSOR_GoToNextRow(OH_Cursor *cursor)
int CURSOR_GetSize(OH_Cursor *cursor, int32_t columnIndex, size_t *size)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
return tempCursor->GetResultSet()->GetSize(columnIndex, *size);
@ -122,7 +122,7 @@ int CURSOR_GetSize(OH_Cursor *cursor, int32_t columnIndex, size_t *size)
int CURSOR_GetText(OH_Cursor *cursor, int32_t columnIndex, char *value, int length)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
std::string str;
@ -132,7 +132,7 @@ int CURSOR_GetText(OH_Cursor *cursor, int32_t columnIndex, char *value, int leng
}
errno_t result = memcpy_s(value, length, str.c_str(), str.length());
if (result != EOK) {
return E_ERROR;
return OH_Rdb_ErrCode::RDB_ERR;
}
return errCode;
}
@ -140,7 +140,7 @@ int CURSOR_GetText(OH_Cursor *cursor, int32_t columnIndex, char *value, int leng
int CURSOR_GetInt64(OH_Cursor *cursor, int32_t columnIndex, int64_t *value)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
int errCode = tempCursor->GetResultSet()->GetLong(columnIndex, *value);
@ -150,7 +150,7 @@ int CURSOR_GetInt64(OH_Cursor *cursor, int32_t columnIndex, int64_t *value)
int CURSOR_GetReal(OH_Cursor *cursor, int32_t columnIndex, double *value)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
return tempCursor->GetResultSet()->GetDouble(columnIndex, *value);
@ -159,7 +159,7 @@ int CURSOR_GetReal(OH_Cursor *cursor, int32_t columnIndex, double *value)
int CURSOR_GetBlob(OH_Cursor *cursor, int32_t columnIndex, unsigned char *value, int length)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
std::vector<uint8_t> vec;
@ -169,7 +169,7 @@ int CURSOR_GetBlob(OH_Cursor *cursor, int32_t columnIndex, unsigned char *value,
}
errno_t result = memcpy_s(value, length, vec.data(), vec.size());
if (result != EOK) {
return E_ERROR;
return OH_Rdb_ErrCode::RDB_ERR;
}
return errCode;
}
@ -177,7 +177,7 @@ int CURSOR_GetBlob(OH_Cursor *cursor, int32_t columnIndex, unsigned char *value,
int CURSOR_IsNull(OH_Cursor *cursor, int32_t columnIndex, bool *isNull)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
return tempCursor->GetResultSet()->IsColumnNull(columnIndex, *isNull);
@ -186,7 +186,7 @@ int CURSOR_IsNull(OH_Cursor *cursor, int32_t columnIndex, bool *isNull)
int CURSOR_Close(OH_Cursor *cursor)
{
if (cursor == nullptr || cursor->id != OHOS::NativeRdb::RDB_CURSOR_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::CursorImpl *tempCursor = static_cast<OHOS::NativeRdb::CursorImpl *>(cursor);
int errCode = tempCursor->GetResultSet()->Close();

View File

@ -31,4 +31,4 @@ private:
};
} // namespace NativeRdb
} // namespace OHOS
#endif //RELATIONAL_CURSOR_IMPL_H
#endif // RELATIONAL_CURSOR_IMPL_H

View File

@ -33,210 +33,210 @@ OH_Predicates *OH_Rdb_CreatePredicates(char const *table)
int OH_Rdb_DestroyPredicates(OH_Predicates *predicate)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
delete tempPredicates;
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_EqualTo(OH_Predicates *predicate, char const *field, char const *value)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().EqualTo(field, value);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_NotEqualTo(OH_Predicates *predicate, char const *field, char const *value)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().NotEqualTo(field, value);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_BeginWrap(OH_Predicates *predicate)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().BeginWrap();
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_EndWrap(OH_Predicates *predicate)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().EndWrap();
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_Or(OH_Predicates *predicate)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().Or();
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_And(OH_Predicates *predicate)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().And();
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_IsNull(OH_Predicates *predicate, const char *field)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().IsNull(field);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_IsNotNull(OH_Predicates *predicate, const char *field)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().IsNotNull(field);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_Like(OH_Predicates *predicate, const char *field, const char *value)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().Like(field, value);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_Between(OH_Predicates *predicate, const char *field, const char *betweenValue, const char *andValue)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().Between(field, betweenValue, andValue);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_NotBetween(OH_Predicates *predicate, const char *field, const char *betweenValue, const char *andValue)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().NotBetween(field, betweenValue, andValue);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_GreaterThan(OH_Predicates *predicate, const char *field, const char *value)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().GreaterThan(field, value);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_LessThan(OH_Predicates *predicate, const char *field, const char *value)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().LessThan(field, value);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_GreaterThanOrEqualTo(OH_Predicates *predicate, const char *field, const char *value)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().GreaterThanOrEqualTo(field, value);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_LessThanOrEqualTo(OH_Predicates *predicate, const char *field, const char *value)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().LessThanOrEqualTo(field, value);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_OrderBy(OH_Predicates *predicate, const char *field, OrderByType type)
int PREDICATES_OrderBy(OH_Predicates *predicate, const char *field, OH_Rdb_OrderByType type)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
if (type == OrderByType::DESC) {
if (type == OH_Rdb_OrderByType::RDB_PRE_DESC) {
tempPredicates->GetPredicates().OrderByDesc(field);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
tempPredicates->GetPredicates().OrderByAsc(field);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_Distinct(OH_Predicates *predicate)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().Distinct();
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_Limit(OH_Predicates *predicate, unsigned int value)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().Limit(value);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_Offset(OH_Predicates *predicate, unsigned int rowOffset)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().Offset(rowOffset);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_GroupBy(OH_Predicates *predicate, char const *const *field, const int length)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
std::vector<std::string> vec;
@ -247,13 +247,13 @@ int PREDICATES_GroupBy(OH_Predicates *predicate, char const *const *field, const
}
tempPredicates->GetPredicates().GroupBy(vec);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_In(OH_Predicates *predicate, char const *filed, char const *const *values, const int length)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
std::vector<std::string> vec;
@ -264,13 +264,13 @@ int PREDICATES_In(OH_Predicates *predicate, char const *filed, char const *const
}
tempPredicates->GetPredicates().In(filed, vec);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_NotIn(OH_Predicates *predicate, char const *filed, char const *const *values, const int length)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
std::vector<std::string> vec;
@ -281,15 +281,15 @@ int PREDICATES_NotIn(OH_Predicates *predicate, char const *filed, char const *co
}
tempPredicates->GetPredicates().NotIn(filed, vec);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int PREDICATES_Clear(OH_Predicates *predicate)
{
if (predicate == nullptr || predicate->id != OHOS::NativeRdb::RDB_PREDICATES_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::PredicateImpl *tempPredicates = static_cast<OHOS::NativeRdb::PredicateImpl *>(predicate);
tempPredicates->GetPredicates().Clear();
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}

View File

@ -53,9 +53,9 @@ public:
}
RdbPredicates &GetPredicates();
//private:
private:
RdbPredicates predicates_;
};
} // namespace NativeRdb
} // namespace OHOS
#endif //RELATIONAL_PREDICATES_IMPL_H
#endif // RELATIONAL_PREDICATES_IMPL_H

View File

@ -44,7 +44,7 @@ public:
int OnOpen(OHOS::NativeRdb::RdbStore &rdbStore) override;
int onCorruption(std::string databaseFile) override;
RDB_OpenCallback rdbStoreOpenCallback;
OH_Rdb_OpenCallback rdbStoreOpenCallback;
};
@ -54,7 +54,7 @@ int MainOpenCallback::OnCreate(OHOS::NativeRdb::RdbStore &store)
return OHOS::NativeRdb::E_OK;
}
std::shared_ptr<OHOS::NativeRdb::RdbStore> storeTemp(&store);
RDB_Store *rdbStore = new OHOS::NativeRdb::StoreImpl(storeTemp);
OH_Rdb_Store *rdbStore = new OHOS::NativeRdb::StoreImpl(storeTemp);
int ret = rdbStoreOpenCallback.OH_Callback_OnCreate(rdbStore);
delete rdbStore;
rdbStore = nullptr;
@ -67,7 +67,7 @@ int MainOpenCallback::OnUpgrade(OHOS::NativeRdb::RdbStore &store, int oldVersion
return OHOS::NativeRdb::E_OK;
}
std::shared_ptr<OHOS::NativeRdb::RdbStore> storeTemp(&store);
RDB_Store *rdbStore = new OHOS::NativeRdb::StoreImpl(storeTemp);
OH_Rdb_Store *rdbStore = new OHOS::NativeRdb::StoreImpl(storeTemp);
int ret = rdbStoreOpenCallback.OH_Callback_OnUpgrade(rdbStore, oldVersion, newVersion);
delete rdbStore;
rdbStore = nullptr;
@ -80,7 +80,7 @@ int MainOpenCallback::OnDowngrade(OHOS::NativeRdb::RdbStore &store, int oldVersi
return OHOS::NativeRdb::E_OK;
}
std::shared_ptr<OHOS::NativeRdb::RdbStore> storeTemp(&store);
RDB_Store *rdbStore = new OHOS::NativeRdb::StoreImpl(storeTemp);
OH_Rdb_Store *rdbStore = new OHOS::NativeRdb::StoreImpl(storeTemp);
int ret = rdbStoreOpenCallback.OH_Callback_OnDowngrade(rdbStore, oldVersion, newVersion);
delete rdbStore;
rdbStore = nullptr;
@ -93,7 +93,7 @@ int MainOpenCallback::OnOpen(OHOS::NativeRdb::RdbStore &store)
return OHOS::NativeRdb::E_OK;
}
std::shared_ptr<OHOS::NativeRdb::RdbStore> storeTemp(&store);
RDB_Store *rdbStore = new OHOS::NativeRdb::StoreImpl(storeTemp);
OH_Rdb_Store *rdbStore = new OHOS::NativeRdb::StoreImpl(storeTemp);
int ret = rdbStoreOpenCallback.OH_Callback_OnOpen(rdbStore);
delete rdbStore;
rdbStore = nullptr;
@ -108,7 +108,7 @@ int MainOpenCallback::onCorruption(std::string databaseFile)
return rdbStoreOpenCallback.OH_Callback_OnCorruption(databaseFile.c_str());
}
RDB_Store *OH_Rdb_GetOrOpen(RDB_Config const *config, int version, RDB_OpenCallback *openCallback, int *errCode)
OH_Rdb_Store *OH_Rdb_GetOrOpen(OH_Rdb_Config const *config, int version, OH_Rdb_OpenCallback *openCallback, int *errCode)
{
OHOS::NativeRdb::RdbStoreConfig rdbStoreConfig(config->path);
rdbStoreConfig.SetSecurityLevel(OHOS::NativeRdb::SecurityLevel(config->securityLevel));
@ -129,39 +129,39 @@ RDB_Store *OH_Rdb_GetOrOpen(RDB_Config const *config, int version, RDB_OpenCallb
return new OHOS::NativeRdb::StoreImpl(store);
}
int OH_Rdb_CloseStore(RDB_Store *store)
int OH_Rdb_CloseStore(OH_Rdb_Store *store)
{
if (store == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
delete tempStore;
tempStore = nullptr;
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OH_Rdb_ClearCache()
{
OHOS::NativeRdb::RdbHelper::ClearCache();
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OH_Rdb_DeleteStore(const char *path)
{
if (path == nullptr) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
int err = OHOS::NativeRdb::RdbHelper::DeleteRdbStore(path);
if (err != OHOS::NativeRdb::E_OK) {
return err;
}
return err;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OH_Rdb_Insert(RDB_Store *store, char const *table, RDB_ValuesBucket *valuesBucket)
int OH_Rdb_Insert(OH_Rdb_Store *store, char const *table, OH_Rdb_ValuesBucket *valuesBucket)
{
if (store == nullptr || table == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
int64_t rowId = -1;
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
@ -174,10 +174,10 @@ int OH_Rdb_Insert(RDB_Store *store, char const *table, RDB_ValuesBucket *valuesB
}
}
int OH_Rdb_Update(RDB_Store *store, RDB_ValuesBucket *valueBucket, OH_Predicates *predicate)
int OH_Rdb_Update(OH_Rdb_Store *store, OH_Rdb_ValuesBucket *valueBucket, OH_Predicates *predicate)
{
if (store == nullptr || predicate == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
int updatedRows = -1;
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
@ -192,10 +192,10 @@ int OH_Rdb_Update(RDB_Store *store, RDB_ValuesBucket *valueBucket, OH_Predicates
}
}
int OH_Rdb_Delete(RDB_Store *store, OH_Predicates *predicate)
int OH_Rdb_Delete(OH_Rdb_Store *store, OH_Predicates *predicate)
{
if (store == nullptr || predicate == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
int deletedRows = -1;
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
@ -208,7 +208,7 @@ int OH_Rdb_Delete(RDB_Store *store, OH_Predicates *predicate)
}
}
OH_Cursor *OH_Rdb_Query(RDB_Store *store, OH_Predicates *predicate, const char **columnNames, int length)
OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicate, char const *const *columnNames, int length)
{
if (store == nullptr || predicate == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return nullptr;
@ -231,7 +231,7 @@ OH_Cursor *OH_Rdb_Query(RDB_Store *store, OH_Predicates *predicate, const char *
return new OHOS::NativeRdb::CursorImpl(retParam);
}
OH_Cursor *OH_Rdb_ExecuteQuery(RDB_Store *store, char const *sql)
OH_Cursor *OH_Rdb_ExecuteQuery(OH_Rdb_Store *store, char const *sql)
{
if (store == nullptr || sql == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return nullptr;
@ -246,46 +246,46 @@ OH_Cursor *OH_Rdb_ExecuteQuery(RDB_Store *store, char const *sql)
return new OHOS::NativeRdb::CursorImpl(retParam);
}
int OH_Rdb_Execute(RDB_Store *store, char const *sql)
int OH_Rdb_Execute(OH_Rdb_Store *store, char const *sql)
{
if (store == nullptr || sql == nullptr ||store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
return tempStore->GetStore()->ExecuteSql(sql, std::vector<OHOS::NativeRdb::ValueObject>{});
}
int OH_Rdb_Transaction(RDB_Store *store)
int OH_Rdb_Transaction(OH_Rdb_Store *store)
{
if (store == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
return tempStore->GetStore()->BeginTransaction();
}
int OH_Rdb_RollBack(RDB_Store *store)
int OH_Rdb_RollBack(OH_Rdb_Store *store)
{
if (store == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
return tempStore->GetStore()->RollBack();
}
int OH_Rdb_Commit(RDB_Store *store)
int OH_Rdb_Commit(OH_Rdb_Store *store)
{
if (store == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
return tempStore->GetStore()->Commit();
}
int OH_Rdb_Backup(RDB_Store *store, const char *databasePath)
int OH_Rdb_Backup(OH_Rdb_Store *store, const char *databasePath)
{
if (store == nullptr || databasePath == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
std::vector<uint8_t> vec;
@ -293,10 +293,10 @@ int OH_Rdb_Backup(RDB_Store *store, const char *databasePath)
return tempStore->GetStore()->Backup(databasePath, vec);
}
int OH_Rdb_Restore(RDB_Store *store, const char *databasePath)
int OH_Rdb_Restore(OH_Rdb_Store *store, const char *databasePath)
{
if (store == nullptr || databasePath == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
std::vector<uint8_t> vec;
@ -304,19 +304,19 @@ int OH_Rdb_Restore(RDB_Store *store, const char *databasePath)
return tempStore->GetStore()->Restore(databasePath, vec);
}
int OH_Rdb_GetVersion(RDB_Store *store, int *version)
int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version)
{
if (store == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
return tempStore->GetStore()->GetVersion(*version);
}
int OH_Rdb_SetVersion(RDB_Store *store, int version)
int OH_Rdb_SetVersion(OH_Rdb_Store *store, int version)
{
if (store == nullptr || store->id != OHOS::NativeRdb::RDB_STORE_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
OHOS::NativeRdb::StoreImpl *tempStore = static_cast<OHOS::NativeRdb::StoreImpl *>(store);
return tempStore->GetStore()->SetVersion(version);

View File

@ -25,7 +25,7 @@
namespace OHOS {
namespace NativeRdb {
constexpr int RDB_STORE_CID = 1234560;
class StoreImpl : public RDB_Store {
class StoreImpl : public OH_Rdb_Store {
public:
StoreImpl(std::shared_ptr<RdbStore> store);
std::shared_ptr<RdbStore> GetStore();
@ -35,4 +35,4 @@ private:
};
} // namespace NativeRdb
} // namespace OHOS
#endif //RELATIONAL_STORE_IMPL_H
#endif // RELATIONAL_STORE_IMPL_H

View File

@ -20,81 +20,81 @@
#include "value_object.h"
#include "securec.h"
RDB_ValuesBucket *OH_Rdb_CreateValuesBucket()
OH_Rdb_ValuesBucket *OH_Rdb_CreateValuesBucket()
{
return new OHOS::NativeRdb::ValuesBucketImpl();
}
int OH_Rdb_DestroyValuesBucket(RDB_ValuesBucket *bucket)
int OH_Rdb_DestroyValuesBucket(OH_Rdb_ValuesBucket *bucket)
{
if (bucket == nullptr || bucket->id != OHOS::NativeRdb::RDB_VALUESBUCKET_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
delete static_cast<OHOS::NativeRdb::ValuesBucketImpl *>(bucket);
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OH_VBucket_PutText(RDB_ValuesBucket *bucket, const char *name, const char *value)
int OH_VBucket_PutText(OH_Rdb_ValuesBucket *bucket, const char *name, const char *value)
{
if (bucket == nullptr || name == nullptr || bucket->id != OHOS::NativeRdb::RDB_VALUESBUCKET_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
static_cast<OHOS::NativeRdb::ValuesBucketImpl *>(bucket)->valuesBucket_.Put(name, OHOS::NativeRdb::ValueObject(value));
bucket->capability += 1;
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OH_VBucket_PutInt64(RDB_ValuesBucket *bucket, const char *name, int64_t value)
int OH_VBucket_PutInt64(OH_Rdb_ValuesBucket *bucket, const char *name, int64_t value)
{
if (bucket == nullptr || name == nullptr || bucket->id != OHOS::NativeRdb::RDB_VALUESBUCKET_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
static_cast<OHOS::NativeRdb::ValuesBucketImpl *>(bucket)->valuesBucket_.Put(name, OHOS::NativeRdb::ValueObject(value));
bucket->capability += 1;
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OH_VBucket_PutReal(RDB_ValuesBucket *bucket, const char *name, double value)
int OH_VBucket_PutReal(OH_Rdb_ValuesBucket *bucket, const char *name, double value)
{
if (bucket == nullptr || bucket->id != OHOS::NativeRdb::RDB_VALUESBUCKET_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
static_cast<OHOS::NativeRdb::ValuesBucketImpl *>(bucket)->valuesBucket_.Put(name, OHOS::NativeRdb::ValueObject(value));
bucket->capability += 1;
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OH_VBucket_PutBlob(RDB_ValuesBucket *bucket, const char *name, const uint8_t *value, uint32_t size)
int OH_VBucket_PutBlob(OH_Rdb_ValuesBucket *bucket, const char *name, const uint8_t *value, uint32_t size)
{
if (bucket == nullptr || name == nullptr || bucket->id != OHOS::NativeRdb::RDB_VALUESBUCKET_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
std::vector<uint8_t> vector(size);
errno_t result = memcpy_s(vector.data(), size, value, size);
if (result != EOK) {
return E_ERROR;
return OH_Rdb_ErrCode::RDB_ERR;
}
static_cast<OHOS::NativeRdb::ValuesBucketImpl *>(bucket)->valuesBucket_.Put(name, OHOS::NativeRdb::ValueObject(vector));
bucket->capability += 1;
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OH_VBucket_PutNull(RDB_ValuesBucket *bucket, const char *name)
int OH_VBucket_PutNull(OH_Rdb_ValuesBucket *bucket, const char *name)
{
if (bucket == nullptr || name == nullptr || bucket->id != OHOS::NativeRdb::RDB_VALUESBUCKET_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
static_cast<OHOS::NativeRdb::ValuesBucketImpl *>(bucket)->valuesBucket_.Put(name, OHOS::NativeRdb::ValueObject());
bucket->capability += 1;
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OH_VBucket_Clear(RDB_ValuesBucket *bucket)
int OH_VBucket_Clear(OH_Rdb_ValuesBucket *bucket)
{
if (bucket == nullptr || bucket->id != OHOS::NativeRdb::RDB_VALUESBUCKET_CID) {
return E_INVALID_ARG;
return OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS;
}
static_cast<OHOS::NativeRdb::ValuesBucketImpl *>(bucket)->valuesBucket_.Clear();
bucket->capability = 0;
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}

View File

@ -22,7 +22,7 @@
namespace OHOS {
namespace NativeRdb {
constexpr int RDB_VALUESBUCKET_CID = 1234562;
class ValuesBucketImpl : public RDB_ValuesBucket {
class ValuesBucketImpl : public OH_Rdb_ValuesBucket {
public:
ValuesBucketImpl() {
id = RDB_VALUESBUCKET_CID;
@ -32,4 +32,4 @@ public:
};
} // namespace NativeRdb
} // namespace OHOS
#endif //RELATIONAL_VALUES_BUCKET_IMPL_H
#endif // RELATIONAL_VALUES_BUCKET_IMPL_H

View File

@ -31,14 +31,14 @@ public:
};
std::string cursorTestPath_ = RDB_TEST_PATH + "rdb_cursor_test.db";
RDB_Store *cursorTestRdbStore_;
OH_Rdb_Store *cursorTestRdbStore_;
void RdbNdkCursorTest::SetUpTestCase(void)
{
RDB_Config config = {0};
OH_Rdb_Config config = {0};
config.path = cursorTestPath_.c_str();
config.securityLevel = SecurityLevel::S1;
config.isEncrypt = Bool::FALSE;
config.securityLevel = OH_Rdb_SecurityLevel::RDB_S1;
config.isEncrypt = OH_Rdb_Bool::RDB_FALSE;
int version = 1;
int errCode = 0;
@ -50,7 +50,7 @@ void RdbNdkCursorTest::SetUpTestCase(void)
"data3 FLOAT, data4 BLOB, data5 TEXT);";
errCode = OH_Rdb_Execute(cursorTestRdbStore_, createTableSql);
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
@ -108,24 +108,24 @@ HWTEST_F(RdbNdkCursorTest, RDB_NDK_cursor_test_001, TestSize.Level1)
EXPECT_NE(cursor, NULL);
cursor->OH_Cursor_GoToNextRow(cursor);
ColumnType type;
OH_Rdb_ColumnType type;
errCode = cursor->OH_Cursor_GetColumnType(cursor, 0, &type);
EXPECT_EQ(type, ColumnType::TYPE_INT64);
EXPECT_EQ(type, OH_Rdb_ColumnType::RDB_TYPE_INT64);
errCode = cursor->OH_Cursor_GetColumnType(cursor, 1, &type);;
EXPECT_EQ(type, ColumnType::TYPE_TEXT);
EXPECT_EQ(type, OH_Rdb_ColumnType::RDB_TYPE_TEXT);
errCode = cursor->OH_Cursor_GetColumnType(cursor, 2, &type);
EXPECT_EQ(type, ColumnType::TYPE_INT64);
EXPECT_EQ(type, OH_Rdb_ColumnType::RDB_TYPE_INT64);
errCode = cursor->OH_Cursor_GetColumnType(cursor, 3, &type);
EXPECT_EQ(type, ColumnType::TYPE_REAL);
EXPECT_EQ(type, OH_Rdb_ColumnType::RDB_TYPE_REAL);
errCode = cursor->OH_Cursor_GetColumnType(cursor, 4, &type);
EXPECT_EQ(type, ColumnType::TYPE_BLOB);
EXPECT_EQ(type, OH_Rdb_ColumnType::RDB_TYPE_BLOB);
errCode = cursor->OH_Cursor_GetColumnType(cursor, 5, &type);
EXPECT_EQ(type, ColumnType::TYPE_TEXT);
EXPECT_EQ(type, OH_Rdb_ColumnType::RDB_TYPE_TEXT);
cursor->OH_Cursor_Close(cursor);
}

View File

@ -31,14 +31,14 @@ public:
};
std::string predicatesTestPath_ = RDB_TEST_PATH + "rdb_predicates_test.db";
RDB_Store *predicatesTestRdbStore_;
OH_Rdb_Store *predicatesTestRdbStore_;
void RdbNdkPredicatesTest::SetUpTestCase(void)
{
RDB_Config config;
OH_Rdb_Config config;
config.path = predicatesTestPath_.c_str();
config.securityLevel = SecurityLevel::S1;
config.isEncrypt = Bool::FALSE;
config.securityLevel = OH_Rdb_SecurityLevel::RDB_S1;
config.isEncrypt = OH_Rdb_Bool::RDB_FALSE;
int version = 1;
int errCode = 0;
@ -50,7 +50,7 @@ void RdbNdkPredicatesTest::SetUpTestCase(void)
"data3 FLOAT, data4 BLOB, data5 TEXT);";
errCode = OH_Rdb_Execute(predicatesTestRdbStore_, createTableSql);
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
@ -356,7 +356,7 @@ HWTEST_F(RdbNdkPredicatesTest, RDB_NDK_predicates_test_011, TestSize.Level1)
{
int errCode = 0;
OH_Predicates *predicates = OH_Rdb_CreatePredicates("test");
predicates->OH_Predicates_OrderBy(predicates, "data2", OrderByType::ASC);
predicates->OH_Predicates_OrderBy(predicates, "data2", OH_Rdb_OrderByType::RDB_PRE_ASC);
predicates->OH_Predicates_Limit(predicates, 1);
predicates->OH_Predicates_Offset(predicates, 1);
predicates->OH_Predicates_Distinct(predicates);
@ -452,7 +452,7 @@ HWTEST_F(RdbNdkPredicatesTest, RDB_NDK_predicates_test_015, TestSize.Level1)
predicates->OH_Predicates_GroupBy(predicates, columnNames, len);
OH_Cursor *cursor = OH_Rdb_Query(predicatesTestRdbStore_, predicates, NULL, 0);
EXPECT_NE(cursor, nullptr);
EXPECT_NE(cursor, NULL);
int rowCount = 0;
errCode = cursor->OH_Cursor_GetRowCount(cursor, &rowCount);
EXPECT_EQ(rowCount, 3);

View File

@ -53,14 +53,14 @@ void RdbNdkStoreOpenCallbackTest::TearDown(void)
EXPECT_EQ(errCode, 0);
}
int OnCreate(RDB_Store *store)
int OnCreate(OH_Rdb_Store *store)
{
char createTableSql[] = "CREATE TABLE test1 (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT, data2 INTEGER, "
"data3 FLOAT, data4 BLOB, data5 TEXT);";
return OH_Rdb_Execute(store, createTableSql);
}
int OnUpgrade(RDB_Store *store, int oldVersion, int newVersion)
int OnUpgrade(OH_Rdb_Store *store, int oldVersion, int newVersion)
{
if (oldVersion < newVersion) {
if (oldVersion <= 1) {
@ -69,10 +69,10 @@ int OnUpgrade(RDB_Store *store, int oldVersion, int newVersion)
return OH_Rdb_Execute(store, createTableSql);
}
}
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OnDowngrade(RDB_Store *store, int oldVersion, int newVersion)
int OnDowngrade(OH_Rdb_Store *store, int oldVersion, int newVersion)
{
if (oldVersion > newVersion) {
if (oldVersion >= 2) {
@ -80,12 +80,12 @@ int OnDowngrade(RDB_Store *store, int oldVersion, int newVersion)
OH_Rdb_Execute(store, dropTableSql);
}
}
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OnOpen(RDB_Store *store)
int OnOpen(OH_Rdb_Store *store)
{
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
OH_VBucket_PutReal(valueBucket, "data3", 100.1);
@ -107,19 +107,19 @@ int OnOpen(RDB_Store *store)
if (errCode == -1) {
return errCode;
}
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
int OnCorruption(const char *databaseFile)
{
int errCode = OH_Rdb_DeleteStore(databaseFile);
if (errCode != E_OK) {
if (errCode != OH_Rdb_ErrCode::RDB_ERR_OK) {
return errCode;
}
return E_OK;
return OH_Rdb_ErrCode::RDB_ERR_OK;
}
void InitRdbOpenCallback(RDB_OpenCallback *rdbOpenCallback)
void InitRdbOpenCallback(OH_Rdb_OpenCallback *rdbOpenCallback)
{
rdbOpenCallback->OH_Callback_OnCreate = OnCreate;
rdbOpenCallback->OH_Callback_OnUpgrade = OnUpgrade;
@ -135,16 +135,16 @@ void InitRdbOpenCallback(RDB_OpenCallback *rdbOpenCallback)
*/
HWTEST_F(RdbNdkStoreOpenCallbackTest, RDB_NDK_store_open_callback_test_001, TestSize.Level1)
{
RDB_OpenCallback callback;
OH_Rdb_OpenCallback callback;
InitRdbOpenCallback(&callback);
RDB_Config config;
OH_Rdb_Config config;
config.path = storeOpenCallbackTestPath_.c_str();
config.securityLevel = SecurityLevel::S1;
config.isEncrypt = Bool::FALSE;
config.securityLevel = OH_Rdb_SecurityLevel::RDB_S1;
config.isEncrypt = OH_Rdb_Bool::RDB_FALSE;
int errCode = 0;
RDB_Store *store = OH_Rdb_GetOrOpen(&config, 1, &callback, &errCode);
OH_Rdb_Store *store = OH_Rdb_GetOrOpen(&config, 1, &callback, &errCode);
EXPECT_NE(store, NULL);
int version = 0;
@ -152,7 +152,7 @@ HWTEST_F(RdbNdkStoreOpenCallbackTest, RDB_NDK_store_open_callback_test_001, Test
EXPECT_EQ(errCode, 0);
EXPECT_EQ(version, 1);
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutText(valueBucket, "data1", "wangWu");
OH_VBucket_PutInt64(valueBucket, "data2", 14800);
OH_VBucket_PutReal(valueBucket, "data3", 300.1);
@ -180,16 +180,16 @@ HWTEST_F(RdbNdkStoreOpenCallbackTest, RDB_NDK_store_open_callback_test_001, Test
*/
HWTEST_F(RdbNdkStoreOpenCallbackTest, RDB_NDK_store_open_callback_test_002, TestSize.Level1)
{
RDB_OpenCallback callback;
OH_Rdb_OpenCallback callback;
InitRdbOpenCallback(&callback);
RDB_Config config;
OH_Rdb_Config config;
config.path = storeOpenCallbackTestPath_.c_str();
config.securityLevel = SecurityLevel::S1;
config.isEncrypt = Bool::FALSE;
config.securityLevel = OH_Rdb_SecurityLevel::RDB_S1;
config.isEncrypt = OH_Rdb_Bool::RDB_FALSE;
int errCode = 0;
RDB_Store *store = OH_Rdb_GetOrOpen(&config, 2, &callback, &errCode);
OH_Rdb_Store *store = OH_Rdb_GetOrOpen(&config, 2, &callback, &errCode);
EXPECT_NE(store, NULL);
int version = 0;
@ -197,7 +197,7 @@ HWTEST_F(RdbNdkStoreOpenCallbackTest, RDB_NDK_store_open_callback_test_002, Test
EXPECT_EQ(errCode, 0);
EXPECT_EQ(version, 2);
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
OH_VBucket_PutReal(valueBucket, "data3", 100.1);
@ -224,16 +224,16 @@ HWTEST_F(RdbNdkStoreOpenCallbackTest, RDB_NDK_store_open_callback_test_002, Test
*/
HWTEST_F(RdbNdkStoreOpenCallbackTest, RDB_NDK_store_open_callback_test_003, TestSize.Level1)
{
RDB_OpenCallback callback;
OH_Rdb_OpenCallback callback;
InitRdbOpenCallback(&callback);
RDB_Config config;
OH_Rdb_Config config;
config.path = storeOpenCallbackTestPath_.c_str();
config.securityLevel = SecurityLevel::S1;
config.isEncrypt = Bool::FALSE;
config.securityLevel = OH_Rdb_SecurityLevel::RDB_S1;
config.isEncrypt = OH_Rdb_Bool::RDB_FALSE;
int errCode = 0;
RDB_Store *store = OH_Rdb_GetOrOpen(&config, 1, &callback, &errCode);
OH_Rdb_Store *store = OH_Rdb_GetOrOpen(&config, 1, &callback, &errCode);
EXPECT_NE(store, NULL);
int version = 0;
@ -241,7 +241,7 @@ HWTEST_F(RdbNdkStoreOpenCallbackTest, RDB_NDK_store_open_callback_test_003, Test
EXPECT_EQ(errCode, 0);
EXPECT_EQ(version, 1);
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
OH_VBucket_PutReal(valueBucket, "data3", 100.1);

View File

@ -32,14 +32,14 @@ public:
};
std::string storeTestPath_ = RDB_TEST_PATH + "rdb_store_test.db";
RDB_Store *storeTestRdbStore_;
OH_Rdb_Store *storeTestRdbStore_;
void RdbNdkStoreTest::SetUpTestCase(void)
{
RDB_Config config;
OH_Rdb_Config config;
config.path = storeTestPath_.c_str();
config.securityLevel = SecurityLevel::S1;
config.isEncrypt = Bool::FALSE;
config.securityLevel = OH_Rdb_SecurityLevel::RDB_S1;
config.isEncrypt = OH_Rdb_Bool::RDB_FALSE;
int version = 1;
int errCode = 0;
@ -77,7 +77,7 @@ void RdbNdkStoreTest::TearDown(void)
HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_001, TestSize.Level1)
{
int errCode = 0;
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
@ -145,7 +145,7 @@ HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_001, TestSize.Level1)
HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_002, TestSize.Level1)
{
int errCode = 0;
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
@ -217,7 +217,7 @@ HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_003, TestSize.Level1)
OH_Rdb_Transaction(storeTestRdbStore_);
int errCode = 0;
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
@ -259,7 +259,7 @@ HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_004, TestSize.Level1)
OH_Rdb_Transaction(storeTestRdbStore_);
int errCode = 0;
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
@ -299,7 +299,7 @@ HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_004, TestSize.Level1)
HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_005, TestSize.Level1)
{
int errCode = 0;
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
@ -388,7 +388,7 @@ HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_006, TestSize.Level1)
HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_007, TestSize.Level1)
{
int errCode = 0;
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
@ -417,7 +417,7 @@ HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_007, TestSize.Level1)
OH_VBucket_PutText(valueBucket, "data5", "ABCDEFGHI");
char *table = NULL;
errCode = OH_Rdb_Insert(storeTestRdbStore_, table, valueBucket);
EXPECT_EQ(errCode, RDB_ErrCode::E_INVALID_ARG);
EXPECT_EQ(errCode, OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS);
char querySql[] = "SELECT * FROM test";
OH_Cursor *cursor = OH_Rdb_ExecuteQuery(storeTestRdbStore_, querySql);
@ -436,7 +436,7 @@ HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_007, TestSize.Level1)
HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_008, TestSize.Level1)
{
int errCode = 0;
RDB_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket* valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);
@ -463,7 +463,7 @@ HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_008, TestSize.Level1)
OH_Predicates *predicates1 = OH_Rdb_CreatePredicates(table);
EXPECT_EQ(predicates1, NULL);
errCode = OH_Rdb_Update(storeTestRdbStore_, valueBucket, predicates1);
EXPECT_EQ(errCode, RDB_ErrCode::E_INVALID_ARG);
EXPECT_EQ(errCode, OH_Rdb_ErrCode::RDB_ERR_INVALID_ARGS);
OH_Predicates *predicates2 = OH_Rdb_CreatePredicates("test");
OH_Cursor *cursor = OH_Rdb_Query(storeTestRdbStore_, predicates2, NULL, 0);
@ -511,7 +511,7 @@ HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_008, TestSize.Level1)
HWTEST_F(RdbNdkStoreTest, RDB_NDK_store_test_009, TestSize.Level1)
{
int errCode = 0;
RDB_ValuesBucket *valueBucket = OH_Rdb_CreateValuesBucket();
OH_Rdb_ValuesBucket *valueBucket = OH_Rdb_CreateValuesBucket();
OH_VBucket_PutInt64(valueBucket, "id", 1);
OH_VBucket_PutText(valueBucket, "data1", "zhangSan");
OH_VBucket_PutInt64(valueBucket, "data2", 12800);