| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "core/idatasource.h" |
| 7 | #include <filesystem> |
| 8 | |
| 9 | class StringPathDataSourceStub |
| 10 | : public IDataSource<std::string, std::filesystem::path const> |
| 11 | { |
| 12 | public: |
| 13 | StringPathDataSourceStub(std::string_view path = "", |
| 14 | std::string_view data = "", |
| 15 | bool success = true) noexcept |
| 16 | : source_(path) |
| 17 | , data_(data) |
| 18 | , success_(success) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | std::string source() const override |
| 23 | { |
| 24 | return source_; |
| 25 | } |
| 26 | |
| 27 | bool read(std::string &data, std::filesystem::path const &) override |
| 28 | { |
| 29 | data = data_; |
| 30 | return success_; |
| 31 | } |
| 32 | |
| 33 | std::string const source_; |
| 34 | std::string const data_; |
| 35 | bool success_; |
| 36 | }; |