forked from AndreyG/libgit2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.h
More file actions
65 lines (50 loc) · 1.42 KB
/
Copy pathtree.h
File metadata and controls
65 lines (50 loc) · 1.42 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
#pragma once
#include "diff_list.h"
#include "pathspec.h"
namespace git
{
struct Tree
{
git_tree const * ptr() const { return tree_; }
git_tree * ptr() { return tree_; }
int pathspec_match(uint32_t flags, Pathspec const & ps)
{
return git_pathspec_match_tree(NULL, tree_, flags, ps.ptr());
}
size_t entrycount() const
{
return git_tree_entrycount(tree_);
}
git_tree_entry const * operator[] (size_t i) const
{
return git_tree_entry_byindex(tree_, i);
}
git_tree_entry const * operator[] (std::string const & filename) const
{
return git_tree_entry_byname(tree_, filename.c_str());
}
Tree(git_oid const * oid, git_repository * repo);
explicit Tree(git_tree * tree = nullptr)
: tree_(tree)
{}
Tree(Tree && other)
: tree_(other.tree_)
{
other.tree_ = nullptr;
}
Tree& operator =(Tree && other)
{
tree_ = other.tree_;
other.tree_ = nullptr;
}
Tree (Tree const &) = delete;
Tree& operator = (Tree const &) = delete;
~Tree()
{
git_tree_free(tree_);
}
explicit operator bool() const { return tree_; }
private:
git_tree * tree_;
};
}