1 /*
2  * Copyright (c) 2022 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 DATASHARE_ABS_RESULT_SET_H
17 #define DATASHARE_ABS_RESULT_SET_H
18 
19 #include <map>
20 #include <string>
21 #include "basic/result_set.h"
22 
23 namespace OHOS {
24 namespace DataShare {
25 class DataShareAbsResultSet : public ResultSet {
26 public:
27     DataShareAbsResultSet();
28     virtual ~DataShareAbsResultSet();
29     virtual int GetRowCount(int &count) override;
30     virtual int GetAllColumnNames(std::vector<std::string> &columnNames) override;
31     virtual int GetBlob(int columnIndex, std::vector<uint8_t> &blob) override;
32     virtual int GetString(int columnIndex, std::string &value) override;
33     virtual int GetInt(int columnIndex, int &value) override;
34     virtual int GetLong(int columnIndex, int64_t &value) override;
35     virtual int GetDouble(int columnIndex, double &value) override;
36     virtual int IsColumnNull(int columnIndex, bool &isNull) override;
37     virtual int GoToRow(int position) override;
38     virtual int GetDataType(int columnIndex, DataType &dataType) override;
39     int GetRowIndex(int &position) const override;
40     int GoTo(int offset) override;
41     int GoToFirstRow() override;
42     int GoToLastRow() override;
43     int GoToNextRow() override;
44     int GoToPreviousRow() override;
45     int IsAtFirstRow(bool &result) const override;
46     int IsAtLastRow(bool &result) override;
47     int IsStarted(bool &result) const override;
48     int IsEnded(bool &result) override;
49     int GetColumnCount(int &count) override;
50     int GetColumnIndex(const std::string &columnName, int &columnIndex) override;
51     int GetColumnName(int columnIndex, std::string &columnName) override;
52     bool IsClosed() const override;
53     int Close() override;
54 
55 protected:
56     // The default position of the result set
57     static const int INIT_POS = -1;
58     // Current row position
59     int rowPos_;
60     int count_;
61     // Indicates whether the result set is closed
62     bool isClosed_;
63     std::map<std::string, int> indexCache_;
64 };
65 } // namespace DataShare
66 } // namespace OHOS
67 
68 #endif
69