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 
16 #ifndef OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_CACHE_CURSOR_H
17 #define OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_CACHE_CURSOR_H
18 #include "store/cursor.h"
19 
20 namespace OHOS::DistributedRdb {
21 class CacheCursor : public DistributedData::Cursor {
22 public:
23     explicit CacheCursor(std::vector<DistributedData::VBucket> &&records);
24     ~CacheCursor() = default;
25     int32_t GetColumnNames(std::vector<std::string> &names) const override;
26     int32_t GetColumnName(int32_t col, std::string &name) const override;
27     int32_t GetColumnType(int32_t col) const override;
28     int32_t GetCount() const override;
29     int32_t MoveToFirst() override;
30     int32_t MoveToNext() override;
31     int32_t MoveToPrev() override;
32     int32_t GetEntry(DistributedData::VBucket &entry) override;
33     int32_t GetRow(DistributedData::VBucket &data) override;
34     int32_t Get(int32_t col, DistributedData::Value &value) override;
35     int32_t Get(const std::string &col, DistributedData::Value &value) override;
36     int32_t Close() override;
37     bool IsEnd() override;
38 
39 private:
40     int32_t row_;
41     int32_t maxRow_;
42     int32_t maxCol_;
43     std::vector<DistributedData::VBucket> records_;
44     std::vector<std::string> colNames_;
45     std::vector<int32_t> colTypes_;
46 };
47 } // namespace OHOS::DistributedRdb
48 #endif // OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_CACHE_CURSOR_H
49 
50