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_RESULT_SET_H 17 #define NATIVE_RDB_RESULT_SET_H 18 19 #include <string> 20 #include <vector> 21 #include <map> 22 #include "remote_result_set.h" 23 #include "value_object.h" 24 25 namespace OHOS { 26 namespace NativeRdb { 27 struct API_EXPORT RowEntity { 28 public: 29 API_EXPORT void Put(const std::string &name, const ValueObject &value); 30 API_EXPORT ValueObject Get(const std::string &name) const; 31 API_EXPORT ValueObject Get(int index) const; 32 API_EXPORT const std::map<std::string, ValueObject> &Get() const; 33 API_EXPORT std::map<std::string, ValueObject> Steal(); 34 API_EXPORT void Clear(); 35 36 private: 37 std::map<std::string, ValueObject> values_; 38 std::vector<decltype(values_)::iterator> indexs_; 39 }; 40 41 /** 42 * The ResultSet class of RDB. 43 * Provides methods for accessing a database result set generated by querying the database. 44 */ 45 class API_EXPORT ResultSet : public RemoteResultSet { 46 public: 47 /** 48 * @brief Destructor. 49 */ ~ResultSet()50 virtual ~ResultSet() {} 51 52 virtual int GetAsset(int32_t col, ValueObject::Asset &value) = 0; 53 virtual int GetAssets(int32_t col, ValueObject::Assets &value) = 0; 54 virtual int Get(int32_t col, ValueObject &value) = 0; 55 /** 56 * @brief Gets the entire row of data for the current row from the result set. 57 */ 58 virtual int GetRow(RowEntity &rowEntity) = 0; 59 virtual int GetModifyTime(std::string &modifyTime) = 0; 60 61 /** 62 * @brief Get the size of blob or text. 63 * 64 * @param columnIndex Indicates the zero-based index of the target column. 65 */ 66 API_EXPORT virtual int GetSize(int columnIndex, size_t &size) = 0; 67 }; 68 69 } // namespace NativeRdb 70 } // namespace OHOS 71 #endif 72