mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-18 17:00:30 -04:00
refactor: factor out pair formatter from file_scanner
This commit is contained in:
parent
b273e2fd3d
commit
f700ff5cb3
34
include/dwarfs/format.h
Normal file
34
include/dwarfs/format.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
template <typename T, typename U>
|
||||
struct fmt::formatter<std::pair<T, U>> {
|
||||
public:
|
||||
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
|
||||
template <typename Context>
|
||||
constexpr auto format(std::pair<T, U> const& foo, Context& ctx) const {
|
||||
return fmt::format_to(ctx.out(), "({}, {})", foo.first, foo.second);
|
||||
}
|
||||
};
|
@ -28,8 +28,6 @@
|
||||
#include <folly/String.h>
|
||||
#include <folly/container/F14Map.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <range/v3/view/drop.hpp>
|
||||
@ -37,6 +35,7 @@
|
||||
#include <dwarfs/checksum.h>
|
||||
#include <dwarfs/entry.h>
|
||||
#include <dwarfs/file_scanner.h>
|
||||
#include <dwarfs/format.h>
|
||||
#include <dwarfs/inode.h>
|
||||
#include <dwarfs/inode_manager.h>
|
||||
#include <dwarfs/internal/worker_group.h>
|
||||
@ -47,16 +46,6 @@
|
||||
#include <dwarfs/progress.h>
|
||||
#include <dwarfs/util.h>
|
||||
|
||||
template <typename T, typename U>
|
||||
class fmt::formatter<std::pair<T, U>> {
|
||||
public:
|
||||
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
|
||||
template <typename Context>
|
||||
constexpr auto format(std::pair<T, U> const& foo, Context& ctx) const {
|
||||
return fmt::format_to(ctx.out(), "({}, {})", foo.first, foo.second);
|
||||
}
|
||||
};
|
||||
|
||||
namespace dwarfs::detail {
|
||||
|
||||
namespace {
|
||||
|
Loading…
x
Reference in New Issue
Block a user