FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
git2cpp/src/wrapper/strarray_wrapper.cpp at main · QuantStack/git2cpp · GitHub
QuantStack
git2cpp
Repository navigation
Code
Issues
6
(6)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
git2cpp
/
src
/
wrapper
/
strarray_wrapper.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
97 lines (81 loc) · 2.07 KB
Breadcrumbs
git2cpp
/
src
/
wrapper
/
strarray_wrapper.cpp
Copy path
File metadata and controls
97 lines (81 loc) · 2.07 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
90
91
92
93
94
95
96
97
#
include
"
strarray_wrapper.hpp
"
strarray_owned_wrapper::strarray_owned_wrapper
()
: m_array{
nullptr
,
0
}
{
}
strarray_owned_wrapper::strarray_owned_wrapper
(git_strarray&& arr)
: m_array(std::move(arr))
{
}
strarray_owned_wrapper::strarray_owned_wrapper
(strarray_owned_wrapper&& rhs)
: m_array(std::move(rhs.m_array))
{
rhs.
m_array
= git_strarray{
nullptr
,
0
};
}
strarray_owned_wrapper& strarray_owned_wrapper::
operator
=(strarray_owned_wrapper&& rhs)
{
std::swap
(m_array.
strings
, rhs.
m_array
.
strings
);
std::swap
(m_array.
count
, rhs.
m_array
.
count
);
return
*
this
;
}
strarray_owned_wrapper::~strarray_owned_wrapper
()
{
git_strarray_dispose
(&m_array);
}
strarray_owned_wrapper::
operator
git_strarray*()
{
return
&m_array;
}
size_t
strarray_owned_wrapper::size
()
const
{
return
m_array.
count
;
}
std::string strarray_owned_wrapper::
operator
[](
size_t
i)
const
{
return
{m_array.
strings
[i]};
}
strarray_view_wrapper::strarray_view_wrapper
(std::vector<std::string> patterns)
: m_patterns(std::move(patterns))
{
init_str_array
();
}
strarray_view_wrapper::strarray_view_wrapper
(strarray_view_wrapper&& rhs)
: m_patterns(std::move(rhs.m_patterns))
{
init_str_array
();
rhs.
reset_str_array
();
}
strarray_view_wrapper& strarray_view_wrapper::
operator
=(strarray_view_wrapper&& rhs)
{
using
std::swap;
swap
(m_patterns, rhs.
m_patterns
);
swap
(m_array.
strings
, rhs.
m_array
.
strings
);
swap
(m_array.
count
, rhs.
m_array
.
count
);
return
*
this
;
}
strarray_view_wrapper::~strarray_view_wrapper
()
{
reset_str_array
();
}
strarray_view_wrapper::
operator
git_strarray*()
{
return
&m_array;
}
void
strarray_view_wrapper::reset_str_array
()
{
delete[]
m_array.
strings
;
m_array = {
nullptr
,
0
};
}
void
strarray_view_wrapper::init_str_array
()
{
m_array.
strings
=
new
char
*[m_patterns.
size
()];
m_array.
count
= m_patterns.
size
();
for
(
size_t
i =
0
; i < m_patterns.
size
(); ++i)
{
m_array.
strings
[i] =
const_cast
<
char
*>(m_patterns[i].
c_str
());
}
}
size_t
strarray_view_wrapper::size
()
const
{
return
m_patterns.
size
();
}
Back
|
FazBrowse Home
|
New Git URL