|
| 1 | +/* |
| 2 | + * Copyright © Canonical Ltd. |
| 3 | + * |
| 4 | + * This program is free software: you can redistribute it and/or modify it |
| 5 | + * under the terms of the GNU General Public License version 2 or 3 as |
| 6 | + * published by the Free Software Foundation. |
| 7 | + * |
| 8 | + * This program is distributed in the hope that it will be useful, |
| 9 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | + * GNU General Public License for more details. |
| 12 | + * |
| 13 | + * You should have received a copy of the GNU General Public License |
| 14 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + */ |
| 16 | + |
| 17 | +#include "file_changes_builder.h" |
| 18 | + |
| 19 | +namespace mlc = miral::live_config; |
| 20 | + |
| 21 | +mlc::FileChangesBuilder::FileChangesBuilder() : |
| 22 | + changes_{} |
| 23 | +{ |
| 24 | +} |
| 25 | + |
| 26 | +auto mlc::FileChangesBuilder::push_unchanged( |
| 27 | + std::filesystem::path filepath, |
| 28 | + std::function<std::unique_ptr<std::istream>()> stream) -> FileChangesBuilder& |
| 29 | +{ |
| 30 | + changes_.push_unchanged(std::move(filepath), std::move(stream)); |
| 31 | + return *this; |
| 32 | +} |
| 33 | + |
| 34 | +auto mlc::FileChangesBuilder::push_moved_or_new( |
| 35 | + std::filesystem::path filepath, |
| 36 | + std::function<std::unique_ptr<std::istream>()> stream) -> FileChangesBuilder& |
| 37 | +{ |
| 38 | + changes_.push_moved_or_new(std::move(filepath), std::move(stream)); |
| 39 | + return *this; |
| 40 | +} |
| 41 | + |
| 42 | +auto mlc::FileChangesBuilder::push_modified( |
| 43 | + std::filesystem::path filepath, |
| 44 | + std::function<std::unique_ptr<std::istream>()> stream) -> FileChangesBuilder& |
| 45 | +{ |
| 46 | + changes_.push_modified(std::move(filepath), std::move(stream)); |
| 47 | + return *this; |
| 48 | +} |
| 49 | + |
| 50 | +auto mlc::FileChangesBuilder::push_dropped(std::filesystem::path filepath) -> FileChangesBuilder& |
| 51 | +{ |
| 52 | + changes_.push_dropped(std::move(filepath)); |
| 53 | + return *this; |
| 54 | +} |
| 55 | + |
| 56 | +auto mlc::FileChangesBuilder::push_renamed( |
| 57 | + std::filesystem::path old_filepath, |
| 58 | + std::filesystem::path new_filepath, |
| 59 | + std::function<std::unique_ptr<std::istream>()> stream) -> FileChangesBuilder& |
| 60 | +{ |
| 61 | + changes_.push_renamed(std::move(old_filepath), std::move(new_filepath), std::move(stream)); |
| 62 | + return *this; |
| 63 | +} |
| 64 | + |
| 65 | +mlc::FileChangesBuilder::operator mlc::FileChanges const&() const |
| 66 | +{ |
| 67 | + return changes_; |
| 68 | +} |
0 commit comments