Skip to content

Commit c692454

Browse files
committed
move implementation to cpp file
1 parent 9e04c96 commit c692454

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

src/utils/common.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ std::string get_current_git_path()
2424
// ->check(CLI::ExistingDirectory | CLI::NonexistentPath)
2525
// ->default_val(std::filesystem::current_path());
2626

27-
git_strarray git_strarray_wrapper::init_str_array()
27+
git_strarray_wrapper::git_strarray_wrapper(std::vector<std::string> m_patterns)
28+
: m_patterns(std::move(m_patterns))
29+
{
30+
init_str_array();
31+
}
32+
33+
git_strarray_wrapper::git_strarray_wrapper(git_strarray_wrapper&& rhs)
34+
: m_patterns(std::move(rhs.m_patterns))
35+
{
36+
init_str_array();
37+
}
38+
39+
git_strarray_wrapper::~git_strarray_wrapper()
40+
{
41+
delete[] m_array.strings;
42+
}
43+
44+
git_strarray_wrapper::operator git_strarray*()
45+
{
46+
return &m_array;
47+
}
48+
49+
void git_strarray_wrapper::init_str_array()
2850
{
2951
git_strarray_wrapper aw;
3052
git_strarray array{new char*[aw.m_patterns.size()], aw.m_patterns.size()};
3153
for (size_t i=0; i<aw.m_patterns.size(); ++i)
3254
{
3355
array.strings[i] = const_cast<char*>(aw.m_patterns[i].c_str());
3456
}
35-
return array;
3657
}

src/utils/common.hpp

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,20 @@ class git_strarray_wrapper
6868
: m_patterns{}
6969
, m_array{nullptr, 0}
7070
{}
71-
git_strarray_wrapper(std::vector<std::string> m_patterns)
72-
: m_patterns(std::move(m_patterns))
73-
{
74-
init_str_array();
75-
}
71+
git_strarray_wrapper(std::vector<std::string> m_patterns);
7672

7773
git_strarray_wrapper(const git_strarray_wrapper&) = delete;
7874
git_strarray_wrapper& operator=(const git_strarray_wrapper&) = delete;
7975

80-
git_strarray_wrapper(git_strarray_wrapper&& rhs)
81-
: m_patterns(std::move(rhs.m_patterns))
82-
{
83-
init_str_array();
84-
}
76+
git_strarray_wrapper(git_strarray_wrapper&& rhs);
8577

86-
~git_strarray_wrapper()
87-
{
88-
delete[] m_array.strings;
89-
}
78+
~git_strarray_wrapper();
9079

91-
operator git_strarray*()
92-
{
93-
return &m_array;
94-
}
95-
96-
static git_strarray init_str_array();
80+
operator git_strarray*();
9781

98-
protected:
82+
private:
9983
std::vector<std::string> m_patterns;
10084
git_strarray m_array;
85+
86+
void init_str_array();
10187
};

0 commit comments

Comments
 (0)