-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbranch_wrapper.hpp
More file actions
57 lines (36 loc) · 1.23 KB
/
branch_wrapper.hpp
File metadata and controls
57 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <optional>
#include <string_view>
#include <git2.h>
#include "../wrapper/wrapper_base.hpp"
class commit_wrapper;
class branch_wrapper : public wrapper_base<git_reference>
{
public:
using base_type = wrapper_base<git_reference>;
~branch_wrapper();
branch_wrapper(branch_wrapper&&) = default;
branch_wrapper& operator=(branch_wrapper&&) = default;
std::string_view name() const;
std::string_view reference_name() const;
private:
explicit branch_wrapper(git_reference* ref);
friend class repository_wrapper;
friend class branch_iterator;
};
void delete_branch(branch_wrapper&& br);
// Rust / Python-like iterator instead of regular C++ iterator,
// because of the libgit2 API. Implementing the postfix increment
// operator of an input iterator would be overcomplicated.
class branch_iterator : public wrapper_base<git_branch_iterator>
{
public:
using base_type = wrapper_base<git_branch_iterator>;
~branch_iterator();
branch_iterator(branch_iterator&&) = default;
branch_iterator& operator=(branch_iterator&&) = default;
std::optional<branch_wrapper> next();
private:
explicit branch_iterator(git_branch_iterator* iter);
friend class repository_wrapper;
};