forked from QuantStack/git2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.hpp
More file actions
89 lines (70 loc) · 1.97 KB
/
common.hpp
File metadata and controls
89 lines (70 loc) · 1.97 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#include <string>
#include <utility>
#include <vector>
#include <git2.h>
class noncopyable_nonmovable
{
public:
noncopyable_nonmovable(const noncopyable_nonmovable&) = delete;
noncopyable_nonmovable& operator=(const noncopyable_nonmovable&) = delete;
noncopyable_nonmovable(noncopyable_nonmovable&&) = delete;
noncopyable_nonmovable& operator=(noncopyable_nonmovable&&) = delete;
protected:
noncopyable_nonmovable() = default;
~noncopyable_nonmovable() = default;
};
template <class T>
class wrapper_base
{
public:
using resource_type = T;
wrapper_base(const wrapper_base&) = delete;
wrapper_base& operator=(const wrapper_base&) = delete;
wrapper_base(wrapper_base&& rhs)
: p_resource(rhs.p_resource)
{
rhs.p_resource = nullptr;
}
wrapper_base& operator=(wrapper_base&& rhs)
{
std::swap(p_resource, rhs.p_resource);
return this;
}
operator resource_type*() const noexcept
{
return p_resource;
}
protected:
// Allocation and deletion of p_resource must be handled by inheriting class.
wrapper_base() = default;
~wrapper_base() = default;
resource_type* p_resource = nullptr;
};
class libgit2_object : private noncopyable_nonmovable
{
public:
libgit2_object();
~libgit2_object();
};
std::string get_current_git_path();
class git_strarray_wrapper
{
public:
git_strarray_wrapper()
: m_patterns{}
, m_array{nullptr, 0}
{}
git_strarray_wrapper(std::vector<std::string> patterns);
git_strarray_wrapper(const git_strarray_wrapper&) = delete;
git_strarray_wrapper& operator=(const git_strarray_wrapper&) = delete;
git_strarray_wrapper(git_strarray_wrapper&& rhs);
git_strarray_wrapper& operator=(git_strarray_wrapper&&);
~git_strarray_wrapper();
operator git_strarray*();
private:
std::vector<std::string> m_patterns;
git_strarray m_array;
void reset_str_array();
void init_str_array();
};