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 FETCH_RESULT_H 17 #define FETCH_RESULT_H 18 19 #include <variant> 20 #include "file_asset.h" 21 #include "abs_shared_result_set.h" 22 #include "media_lib_service_const.h" 23 #include "media_data_ability_const.h" 24 #include "rdb_errno.h" 25 26 namespace OHOS { 27 namespace Media { 28 enum ResultSetDataType { 29 TYPE_STRING, 30 TYPE_INT32, 31 TYPE_INT64 32 }; 33 34 /** 35 * @brief Class for returing the data cursor to application. 36 * 37 * @since 1.0 38 * @version 1.0 39 */ 40 class FetchResult { 41 public: 42 FetchResult(const std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet>& resultset); 43 FetchResult(); 44 virtual ~FetchResult(); 45 46 void Close(); 47 int32_t GetCount(); 48 bool IsContain(); 49 bool IsClosed(); 50 bool IsAtLastRow(); 51 std::unique_ptr<FileAsset> GetObjectAtPosition(int32_t index); 52 std::unique_ptr<FileAsset> GetFirstObject(); 53 std::unique_ptr<FileAsset> GetNextObject(); 54 std::unique_ptr<FileAsset> GetLastObject(); 55 std::unique_ptr<FileAsset> GetObject(); 56 57 bool isContain_; 58 bool isClosed_; 59 int32_t count_; 60 std::string networkId_; 61 std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet> resultset_ = nullptr; 62 63 private: 64 std::variant<int32_t, int64_t, std::string> GetRowValFromColumnn(std::string columnName, 65 ResultSetDataType dataType); 66 }; 67 } // namespace Media 68 } // namespace OHOS 69 #endif // FETCH_RESULT_H