File indexing completed on 2024-04-28 16:53:07
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Ivan Cukic <ivan.cukic(at)kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef ASYNQT_BASE_CAST_H 0008 #define ASYNQT_BASE_CAST_H 0009 0010 #include <QFuture> 0011 #include <QFutureWatcher> 0012 0013 #include <memory> 0014 #include <type_traits> 0015 0016 #include "../private/operations/cast_p.h" 0017 #include "transform.h" 0018 0019 namespace AsynQt 0020 { 0021 /** 0022 * Casts the future result into the specified type. 0023 * 0024 * <code> 0025 * auto future = AsynQt::Process::getOutput("echo", { "Hello KDE" }); 0026 * auto castFuture = AsynQt::qfuture_cast<QString>(future); 0027 * </code> 0028 */ 0029 template<typename _Out, typename _In> 0030 QFuture<_Out> qfuture_cast(const QFuture<_In> &future) 0031 { 0032 return detail::qfuture_cast_impl<_Out>(future); 0033 } 0034 0035 namespace operators 0036 { 0037 template<typename _Out> 0038 detail::operators::CastModifier<_Out> cast() 0039 { 0040 return detail::operators::CastModifier<_Out>(); 0041 } 0042 0043 } // namespace operator 0044 0045 } // namespace AsynQt 0046 0047 #endif // ASYNQT_BASE_CAST_H