From db449ae8d38bcd208d0bdeba1376fc501d27ba10 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Mon, 23 Nov 2020 20:50:13 +0100 Subject: [PATCH] Add output stream overload for file_order_mode --- CMakeLists.txt | 1 + include/dwarfs/options.h | 4 ++++ src/dwarfs/options.cpp | 49 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/dwarfs/options.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bfea17d..cb15a02b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,7 @@ list( src/dwarfs/metadata.cpp src/dwarfs/metadata_writer.cpp src/dwarfs/mmap.cpp + src/dwarfs/options.cpp src/dwarfs/os_access_posix.cpp src/dwarfs/progress.cpp src/dwarfs/scanner.cpp diff --git a/include/dwarfs/options.h b/include/dwarfs/options.h index 5def84fe..01fdba22 100644 --- a/include/dwarfs/options.h +++ b/include/dwarfs/options.h @@ -21,6 +21,8 @@ #pragma once +#include + namespace dwarfs { struct block_cache_options { @@ -31,6 +33,8 @@ struct block_cache_options { enum class file_order_mode { NONE, PATH, SCRIPT, SIMILARITY }; +std::ostream& operator<<(std::ostream& os, file_order_mode mode); + struct scanner_options { file_order_mode file_order; }; diff --git a/src/dwarfs/options.cpp b/src/dwarfs/options.cpp new file mode 100644 index 00000000..ad02f85b --- /dev/null +++ b/src/dwarfs/options.cpp @@ -0,0 +1,49 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/** + * \author Marcus Holland-Moritz (github@mhxnet.de) + * \copyright Copyright (c) Marcus Holland-Moritz + * + * This file is part of dwarfs. + * + * dwarfs is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * dwarfs is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with dwarfs. If not, see . + */ + +#include "dwarfs/options.h" + +namespace dwarfs { + +std::ostream& operator<<(std::ostream& os, file_order_mode mode) { + std::string modestr{"unknown"}; + + switch (mode) { + case file_order_mode::NONE: + modestr = "none"; + break; + case file_order_mode::PATH: + modestr = "path"; + break; + case file_order_mode::SCRIPT: + modestr = "script"; + break; + case file_order_mode::SIMILARITY: + modestr = "similarity"; + break; + default: + break; + } + + return os << modestr; +} + +} // namespace dwarfs