1 /*
2  * Copyright (c) 2024 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 #ifndef RELATIONAL_STORE_IMPL_RESULTSET_FFI_H
17 #define RELATIONAL_STORE_IMPL_RESULTSET_FFI_H
18 
19 #include "relational_store_impl_rdbpredicatesproxy.h"
20 #include "relational_store_utils.h"
21 #include "ffi_remote_data.h"
22 #include "result_set.h"
23 #include <memory>
24 
25 namespace OHOS {
26 namespace Relational {
27 
28 class ResultSetImpl : public OHOS::FFI::FFIData {
29 public:
GetRuntimeType()30     OHOS::FFI::RuntimeType* GetRuntimeType() override
31     {
32         return GetClassType();
33     }
34 
35     explicit ResultSetImpl(std::shared_ptr<NativeRdb::ResultSet> resultSet);
36 
37     CArrStr GetAllColumnNames();
38 
39     int32_t GetColumnCount();
40 
41     int32_t GetRowCount();
42 
43     int32_t GetRowIndex();
44 
45     bool IsAtFirstRow();
46 
47     bool IsAtLastRow();
48 
49     bool IsEnded();
50 
51     bool IsStarted();
52 
53     bool IsClosed();
54 
55     double GetDouble(int32_t columnIndex, int32_t* rtnCode);
56 
57     bool GoToRow(int32_t position, int32_t* rtnCode);
58 
59     bool GoToPreviousRow(int32_t* rtnCode);
60 
61     bool GoToLastRow(int32_t* rtnCode);
62 
63     char* GetColumnName(int32_t columnIndex, int32_t* rtnCode);
64 
65     bool IsColumnNull(int32_t columnIndex, int32_t* rtnCode);
66 
67     Asset GetAsset(int32_t columnIndex, int32_t* rtnCode);
68 
69     int32_t Close();
70 
71     int32_t GetColumnIndex(char* columnName, int32_t* rtnCode);
72 
73     char* GetString(int32_t columnIndex, int32_t* rtnCode);
74 
75     bool GoToFirstRow(int32_t* rtnCode);
76 
77     int64_t GetLong(int32_t columnIndex, int32_t* rtnCode);
78 
79     bool GoToNextRow(int32_t* rtnCode);
80 
81     CArrUI8 GetBlob(int32_t columnIndex, int32_t* rtnCode);
82 
83     bool GoTo(int32_t offset, int32_t* rtnCode);
84 
85     Assets GetAssets(int32_t columnIndex, int32_t* rtnCode);
86 
87     ValuesBucket GetRow(int32_t* rtnCode);
88 
89     std::shared_ptr<NativeRdb::ResultSet> resultSetValue;
90 
91 private:
92     friend class OHOS::FFI::RuntimeType;
93     friend class OHOS::FFI::TypeBase;
94     static OHOS::FFI::RuntimeType* GetClassType();
95 };
96 }
97 }
98 
99 #endif