• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #define LOG_TAG "AniResultSet"
17 #include <ani.h>
18 #include <iostream>
19 #include "ani_rdb_predicates.h"
20 #include "ani_rdb_store_helper.h"
21 #include "ani_result_set.h"
22 #include "ani_utils.h"
23 #include "logger.h"
24 
25 using namespace OHOS::Rdb;
26 using namespace OHOS::RelationalStoreAniKit;
27 
ANI_Constructor(ani_vm * vm,uint32_t * result)28 ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result)
29 {
30     if (vm == nullptr) {
31         LOG_ERROR("vm is nullptr.");
32         return ANI_ERROR;
33     }
34 
35     ani_env *env;
36     auto status = vm->GetEnv(ANI_VERSION_1, &env);
37     if (ANI_OK != status) {
38         LOG_ERROR("Unsupported ANI_VERSION_1 errcode %{public}d", status);
39         return ANI_ERROR;
40     }
41 
42     status = ResultSetInit(env);
43     if (ANI_OK != status) {
44         LOG_ERROR("ResultSetInit failed errcode %{public}d", status);
45         return ANI_ERROR;
46     }
47 
48     status = RdbStoreHelperInit(env);
49     if (ANI_OK != status) {
50         LOG_ERROR("RdbStoreHelperInit failed errcode %{public}d", status);
51         return ANI_ERROR;
52     }
53 
54     status = RdbStoreInit(env);
55     if (ANI_OK != status) {
56         LOG_ERROR("RdbStoreInit failed errcode %{public}d", status);
57         return ANI_ERROR;
58     }
59 
60     status = PredicatesInit(env);
61     if (ANI_OK != status) {
62         LOG_ERROR("PredicatesInit failed errcode %{public}d", status);
63         return ANI_ERROR;
64     }
65 
66     status = CleanerInit(env);
67     if (ANI_OK != status) {
68         LOG_ERROR("CleanerInit failed errcode %{public}d", status);
69         return ANI_ERROR;
70     }
71 
72     *result = ANI_VERSION_1;
73     return ANI_OK;
74 }
75 
76