• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 NATIVE_RDB_ABS_RESULT_SET_H
17 #define NATIVE_RDB_ABS_RESULT_SET_H
18 
19 #include <map>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "result_set.h"
25 
26 namespace OHOS {
27 namespace NativeRdb {
28 class AbsResultSet : public ResultSet {
29 public:
30     AbsResultSet();
31     virtual ~AbsResultSet();
32     int GetRowCount(int &count) override;
33     int GetAllColumnNames(std::vector<std::string> &columnNames) override;
34     int GetBlob(int columnIndex, std::vector<uint8_t> &blob) override;
35     int GetString(int columnIndex, std::string &value) override;
36     int GetInt(int columnIndex, int &value) override;
37     int GetLong(int columnIndex, int64_t &value) override;
38     int GetDouble(int columnIndex, double &value) override;
39     int IsColumnNull(int columnIndex, bool &isNull) override;
40     int GoToRow(int position) override;
41     int GetColumnType(int columnIndex, ColumnType &columnType) override;
42     int GetRowIndex(int &position) const override;
43     int GoTo(int offset) override;
44     int GoToFirstRow() override;
45     int GoToLastRow() override;
46     int GoToNextRow() override;
47     int GoToPreviousRow() override;
48     int IsAtFirstRow(bool &result) const override;
49     int IsAtLastRow(bool &result) override;
50     int IsStarted(bool &result) const override;
51     int IsEnded(bool &result) override;
52     int GetColumnCount(int &count) override;
53     int GetColumnIndex(const std::string &columnName, int &columnIndex) override;
54     int GetColumnName(int columnIndex, std::string &columnName) override;
55     bool IsClosed() const override;
56     int Close() override;
57 
58 protected:
59     std::map<std::string, int> columnMap_;
60     // The default position of the result set
61     static const int INIT_POS = -1;
62     /*
63      * The value can be in the range [-1 ~ n], where -1 represents the start flag position and N represents the data end
64      * flag position, and [0, n-1] represents the real data index.
65      */
66     int rowPos_;
67     std::vector<std::string> columnNames_;
68     // Indicates whether the result set is closed
69     bool isClosed;
70 };
71 } // namespace NativeRdb
72 } // namespace OHOS
73 
74 #endif