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_resultset_api_inner.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 namespace DocumentDB {
GRD_NextInner(GRD_ResultSet * resultSet)24 int32_t GRD_NextInner(GRD_ResultSet *resultSet)
25 {
26 if (resultSet == nullptr) {
27 GLOGE("resultSet is nullptr");
28 return GRD_INVALID_ARGS;
29 };
30 int ret = resultSet->resultSet_.GetNext(true, true);
31 return TransferDocErr(ret);
32 }
33
GRD_GetValueInner(GRD_ResultSet * resultSet,char ** value)34 int32_t GRD_GetValueInner(GRD_ResultSet *resultSet, char **value)
35 {
36 if (resultSet == nullptr || value == nullptr) {
37 GLOGE("resultSet is nullptr,cant get value from it");
38 return GRD_INVALID_ARGS;
39 };
40 char *val = nullptr;
41 int ret = resultSet->resultSet_.GetValue(&val);
42 if (val == nullptr) {
43 GLOGE("Value that get from resultSet is nullptr");
44 return GRD_NOT_AVAILABLE;
45 }
46 *value = val;
47 return TransferDocErr(ret);
48 }
49
GRD_FreeValueInner(char * value)50 int32_t GRD_FreeValueInner(char *value)
51 {
52 if (value == nullptr) {
53 return GRD_INVALID_ARGS;
54 }
55 delete[] value;
56 return GRD_OK;
57 }
58
GRD_FreeResultSetInner(GRD_ResultSet * resultSet)59 int32_t GRD_FreeResultSetInner(GRD_ResultSet *resultSet)
60 {
61 if (resultSet == nullptr) {
62 return GRD_INVALID_ARGS;
63 }
64 resultSet->resultSet_.EraseCollection();
65 delete resultSet;
66 return GRD_OK;
67 }
68
GRD_PrevInner(GRD_ResultSet * resultSet)69 int32_t GRD_PrevInner(GRD_ResultSet *resultSet)
70 {
71 return GRD_NOT_SUPPORT;
72 }
73
GRD_FetchInner(GRD_ResultSet * resultSet,GRD_KVItemT * key,GRD_KVItemT * value)74 int32_t GRD_FetchInner(GRD_ResultSet *resultSet, GRD_KVItemT *key, GRD_KVItemT *value)
75 {
76 return GRD_NOT_SUPPORT;
77 }
78 } // namespace DocumentDB