File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -23,3 +23,14 @@ std::string get_current_git_path()
23
23
// sub->add_option("directory", directory, "info about directory arg")
24
24
// ->check(CLI::ExistingDirectory | CLI::NonexistentPath)
25
25
// ->default_val(std::filesystem::current_path());
26
+
27
+ git_strarray git_strarray_wrapper::init_str_array ()
28
+ {
29
+ git_strarray_wrapper aw;
30
+ git_strarray array{new char *[aw.m_patterns .size ()], aw.m_patterns .size ()};
31
+ for (size_t i=0 ; i<aw.m_patterns .size (); ++i)
32
+ {
33
+ array.strings [i] = const_cast <char *>(aw.m_patterns [i].c_str ());
34
+ }
35
+ return array;
36
+ }
Original file line number Diff line number Diff line change 2
2
3
3
#include < string>
4
4
#include < utility>
5
+ #include < vector>
6
+
7
+ #include < git2.h>
5
8
6
9
class noncopyable_nonmovable
7
10
{
@@ -57,3 +60,42 @@ class libgit2_object : private noncopyable_nonmovable
57
60
};
58
61
59
62
std::string get_current_git_path ();
63
+
64
+ class git_strarray_wrapper
65
+ {
66
+ public:
67
+ git_strarray_wrapper ()
68
+ : m_patterns{}
69
+ , m_array{nullptr , 0 }
70
+ {}
71
+ git_strarray_wrapper (std::vector<std::string> m_patterns)
72
+ : m_patterns(std::move(m_patterns))
73
+ {
74
+ init_str_array ();
75
+ }
76
+
77
+ git_strarray_wrapper (const git_strarray_wrapper&) = delete ;
78
+ git_strarray_wrapper& operator =(const git_strarray_wrapper&) = delete ;
79
+
80
+ git_strarray_wrapper (git_strarray_wrapper&& rhs)
81
+ : m_patterns(std::move(rhs.m_patterns))
82
+ {
83
+ init_str_array ();
84
+ }
85
+
86
+ ~git_strarray_wrapper ()
87
+ {
88
+ delete[] m_array.strings ;
89
+ }
90
+
91
+ operator git_strarray*()
92
+ {
93
+ return &m_array;
94
+ }
95
+
96
+ static git_strarray init_str_array ();
97
+
98
+ protected:
99
+ std::vector<std::string> m_patterns;
100
+ git_strarray m_array;
101
+ };
You can’t perform that action at this time.
0 commit comments