9 #include "../helpers/Unique.h" 22 virtual ~
Object() =
default;
25 const git_oid *
id() const noexcept {
return git_object_id(
object()); }
30 git_object_t
type() const noexcept {
return git_object_type(
object()); }
32 std::string
typeStr() const noexcept {
return git_object_type2string(
type()); }
35 virtual git_object *
object() const noexcept {
return nullptr; }
42 if (
object() == other.object())
44 if (!
object() || !other.object())
46 return git_oid_equal(
id(), other.id());
70 git_object *
object() const noexcept
override {
71 return reinterpret_cast<git_object *
>(
typed());
75 operator T *()
const noexcept {
return typed(); }
83 T *
typed() const noexcept {
return m_typed.get(); }
Wrapper around std::unique_ptr for easier re-definition of free.
Definition: Unique.h:41
git_object_t type() const noexcept
Get Type of this Object.
Definition: Object.h:30
Git Object class – base for Blob, Commit, Tag, Tree.
Definition: Object.h:65
git_object * object() const noexcept override
Get a pointer to the generic git_object.
Definition: Object.h:70
bool operator==(const Object &other) const noexcept
Compare two Objects (their SHAs)
Definition: Object.h:41
const git_oid * id() const noexcept
Get OID (SHA) of this Object.
Definition: Object.h:25
static std::string oidToStr(const git_oid &id)
Convert OID id to string.
Definition: Helpers.h:20
std::string idStr() const noexcept
Get OID (SHA) of this Object – as a string.
Definition: Object.h:27
The most important Git class.
Definition: Repo.h:45
virtual git_object * object() const noexcept
Get the libgit2's git_object pointer of this Object.
Definition: Object.h:35
Git Object class – base for Blob, Commit, Tag, Tree.
Definition: Object.h:20
TypedObject(const Repo &repo, T *typed) noexcept
Construct a new TypedObject.
Definition: Object.h:79
T * typed() const noexcept
Get the stored pointer typed to one of libgit2's types.
Definition: Object.h:83
std::string typeStr() const noexcept
Get Type of this Object – as a string.
Definition: Object.h:32
bool operator!=(const Object &other) const noexcept
Compare two Objects (their SHAs)
Definition: Object.h:50
Object(const Repo &repo)
Constuct a new Object.
Definition: Object.h:54
const Repo & repo() const
Get the Repo this Object lives in.
Definition: Object.h:38