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
59 lines (48 loc) · 1.32 KB
/
Copy pathcommon.hpp
File metadata and controls
59 lines (48 loc) · 1.32 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
#pragma once
#include <string>
#include <utility>
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_ressource(rhs.p_ressource)
{
rhs.p_ressource = nullptr;
}
wrapper_base& operator=(wrapper_base&& rhs)
{
std::swap(p_ressource, rhs.p_ressource);
return this;
}
operator resource_type*() const noexcept
{
return p_ressource;
}
protected:
// Allocation and deletion of p_ressource must be handled by inheriting class.
wrapper_base() = default;
~wrapper_base() = default;
resource_type* p_ressource = nullptr;
};
class libgit2_object : private noncopyable_nonmovable
{
public:
libgit2_object();
~libgit2_object();
};
std::string get_current_git_path();