1 /*
2 * Copyright (c) 2023 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 #include "grd_base/grd_resultset_api.h"
16
17 #include "doc_errno.h"
18 #include "grd_api_manager.h"
19 #include "grd_base/grd_error.h"
20 #include "grd_resultset_inner.h"
21 #include "rd_log_print.h"
22
23 using namespace DocumentDB;
24 static GRD_APIInfo GRD_ResultSetApiInfo;
25
GRD_Next(GRD_ResultSet * resultSet)26 GRD_API int32_t GRD_Next(GRD_ResultSet *resultSet)
27 {
28 if (GRD_ResultSetApiInfo.NextApi == nullptr) {
29 GRD_ResultSetApiInfo = GetApiInfoInstance();
30 }
31 if (GRD_ResultSetApiInfo.NextApi == nullptr) {
32 GLOGE("Fail to dlysm RD api symbol");
33 return GRD_INNER_ERR;
34 }
35 return GRD_ResultSetApiInfo.NextApi(resultSet);
36 }
37
GRD_GetValue(GRD_ResultSet * resultSet,char ** value)38 GRD_API int32_t GRD_GetValue(GRD_ResultSet *resultSet, char **value)
39 {
40 if (GRD_ResultSetApiInfo.GetValueApi == nullptr) {
41 GRD_ResultSetApiInfo = GetApiInfoInstance();
42 }
43 if (GRD_ResultSetApiInfo.GetValueApi == nullptr) {
44 GLOGE("Fail to dlysm RD api symbol");
45 return GRD_INNER_ERR;
46 }
47 return GRD_ResultSetApiInfo.GetValueApi(resultSet, value);
48 }
49
GRD_FreeValue(char * value)50 GRD_API int32_t GRD_FreeValue(char *value)
51 {
52 if (GRD_ResultSetApiInfo.FreeValueApi == nullptr) {
53 GRD_ResultSetApiInfo = GetApiInfoInstance();
54 }
55 if (GRD_ResultSetApiInfo.FreeValueApi == nullptr) {
56 GLOGE("Fail to dlysm RD api symbol");
57 return GRD_INNER_ERR;
58 }
59 return GRD_ResultSetApiInfo.FreeValueApi(value);
60 }
61
GRD_FreeResultSet(GRD_ResultSet * resultSet)62 GRD_API int32_t GRD_FreeResultSet(GRD_ResultSet *resultSet)
63 {
64 if (GRD_ResultSetApiInfo.FreeResultSetApi == nullptr) {
65 GRD_ResultSetApiInfo = GetApiInfoInstance();
66 }
67 if (GRD_ResultSetApiInfo.FreeResultSetApi == nullptr) {
68 GLOGE("Fail to dlysm RD api symbol");
69 return GRD_INNER_ERR;
70 }
71 return GRD_ResultSetApiInfo.FreeResultSetApi(resultSet);
72 }
73
GRD_Prev(GRD_ResultSet * resultSet)74 GRD_API int32_t GRD_Prev(GRD_ResultSet *resultSet)
75 {
76 if (GRD_ResultSetApiInfo.PrevApi == nullptr) {
77 GRD_ResultSetApiInfo = GetApiInfoInstance();
78 }
79 if (GRD_ResultSetApiInfo.PrevApi == nullptr) {
80 GLOGE("Fail to dlysm RD api symbol");
81 return GRD_INNER_ERR;
82 }
83 return GRD_ResultSetApiInfo.PrevApi(resultSet);
84 }
85
GRD_Fetch(GRD_ResultSet * resultSet,GRD_KVItemT * key,GRD_KVItemT * value)86 GRD_API int32_t GRD_Fetch(GRD_ResultSet *resultSet, GRD_KVItemT *key, GRD_KVItemT *value)
87 {
88 if (GRD_ResultSetApiInfo.FetchApi == nullptr) {
89 GRD_ResultSetApiInfo = GetApiInfoInstance();
90 }
91 if (GRD_ResultSetApiInfo.FetchApi == nullptr) {
92 GLOGE("Fail to dlysm RD api symbol");
93 return GRD_INNER_ERR;
94 }
95 return GRD_ResultSetApiInfo.FetchApi(resultSet, key, value);
96 }
97