forked from QuantStack/git2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrarray_wrapper.hpp
More file actions
70 lines (47 loc) · 1.55 KB
/
Copy pathstrarray_wrapper.hpp
File metadata and controls
70 lines (47 loc) · 1.55 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
#pragma once
#include <string>
#include <vector>
#include <git2.h>
// Wrapper of git_strarray that frees the contained
// strings (i.e. calls git_strarray_dispose) upon destruction.
class strarray_owned_wrapper
{
public:
strarray_owned_wrapper();
explicit strarray_owned_wrapper(git_strarray&& arr);
strarray_owned_wrapper(const strarray_owned_wrapper&) = delete;
strarray_owned_wrapper operator=(const strarray_owned_wrapper&) = delete;
strarray_owned_wrapper(strarray_owned_wrapper&& rhs);
strarray_owned_wrapper& operator=(strarray_owned_wrapper&& rhs);
~strarray_owned_wrapper();
operator git_strarray*();
size_t size() const;
std::string operator[](size_t i) const;
private:
git_strarray m_array;
};
// Wrapper of git_strarray containing pointers to strings
// stored in a stnadard container. Does not free them upon
// destruction.
class strarray_view_wrapper
{
public:
strarray_view_wrapper()
: m_patterns{}
, m_array{nullptr, 0}
{
}
strarray_view_wrapper(std::vector<std::string> patterns);
strarray_view_wrapper(const strarray_view_wrapper&) = delete;
strarray_view_wrapper& operator=(const strarray_view_wrapper&) = delete;
strarray_view_wrapper(strarray_view_wrapper&& rhs);
strarray_view_wrapper& operator=(strarray_view_wrapper&& rhs);
~strarray_view_wrapper();
operator git_strarray*();
size_t size() const;
private:
std::vector<std::string> m_patterns;
git_strarray m_array;
void reset_str_array();
void init_str_array();
};