SlHelpers
Toggle main menu visibility
Loading...
Searching...
No Matches
Patch.h
1
// SPDX-License-Identifier: GPL-2.0-only
2
3
#pragma once
4
5
#include <filesystem>
6
#include <istream>
7
#include <optional>
8
#include <set>
9
#include <string>
10
#include <vector>
11
12
#include "../helpers/LastError.h"
13
14
namespace
SlKernCVS {
15
19
class
Patch {
20
public
:
22
using
Header
= std::vector<std::string>;
24
using
Paths
= std::set<std::filesystem::path>;
25
26
Patch() =
delete
;
27
29
static
std::optional<Patch>
create
(
const
std::filesystem::path &path);
31
static
std::optional<Patch>
create
(std::istream &is);
32
34
const
auto
&
header
() const noexcept {
return
m_header; }
36
const
auto
&
paths
() const noexcept {
return
m_paths; }
37
39
static
auto
lastError
() noexcept {
return
m_lastError.lastError(); }
40
private
:
41
Patch
(
Header
&&
header
,
Paths
&&
paths
) : m_header(std::move(
header
)),
42
m_paths(std::move(
paths
)) {}
43
44
Header
m_header;
45
Paths
m_paths;
46
47
using
LastError =
SlHelpers::LastErrorStream<>
;
48
static
thread_local
LastError m_lastError;
49
};
50
51
}
SlHelpers::LastErrorStream<>
SlKernCVS::Patch
Parses a patch into header and files patched.
Definition
Patch.h:19
SlKernCVS::Patch::create
static std::optional< Patch > create(std::istream &is)
Create a new Patch from stream is.
SlKernCVS::Patch::paths
const auto & paths() const noexcept
Get paths this Patch touches.
Definition
Patch.h:36
SlKernCVS::Patch::Paths
std::set< std::filesystem::path > Paths
Type for patched paths.
Definition
Patch.h:24
SlKernCVS::Patch::lastError
static auto lastError() noexcept
Return the last error string if any.
Definition
Patch.h:39
SlKernCVS::Patch::Header
std::vector< std::string > Header
Type for a patch header.
Definition
Patch.h:22
SlKernCVS::Patch::create
static std::optional< Patch > create(const std::filesystem::path &path)
Create a new Patch from file at path.
SlKernCVS::Patch::header
const auto & header() const noexcept
Get header of this Patch.
Definition
Patch.h:34
include
kerncvs
Patch.h
Generated by
1.17.0