/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef NATIVE_RDB_RESULT_SET_H #define NATIVE_RDB_RESULT_SET_H #include #include #include #include "remote_result_set.h" #include "value_object.h" #include "rdb_errno.h" namespace OHOS { namespace NativeRdb { struct API_EXPORT RowEntity { public: API_EXPORT void Put(const std::string &name, int32_t index, ValueObject &&value); API_EXPORT ValueObject Get(const std::string &name) const; API_EXPORT ValueObject Get(int index) const; API_EXPORT const std::map &Get() const; API_EXPORT std::map Steal(); API_EXPORT void Clear(int32_t size); private: std::map values_; std::vector indexs_; }; /** * The ResultSet class of RDB. * Provides methods for accessing a database result set generated by querying the database. */ class API_EXPORT ResultSet : public RemoteResultSet { public: /** * @brief Destructor. */ virtual ~ResultSet() {} virtual int GetAsset(int32_t col, ValueObject::Asset &value) = 0; virtual int GetAssets(int32_t col, ValueObject::Assets &value) = 0; virtual int GetFloat32Array(int32_t index, ValueObject::FloatVector &vecs) { return E_NOT_SUPPORT; } virtual int Get(int32_t col, ValueObject &value) = 0; /** * @brief Gets the entire row of data for the current row from the result set. */ virtual int GetRow(RowEntity &rowEntity) = 0; /** * @brief Get the size of blob or text. * * @param columnIndex Indicates the zero-based index of the target column. */ API_EXPORT virtual int GetSize(int columnIndex, size_t &size) = 0; }; } // namespace NativeRdb } // namespace OHOS #endif