SlHelpers
Toggle main menu visibility
Loading...
Searching...
No Matches
Blob.h
1
// SPDX-License-Identifier: GPL-2.0-only
2
3
#pragma once
4
5
#include <string>
6
7
#include <git2.h>
8
9
#include "Object.h"
10
11
namespace
SlGit {
12
16
class
Blob :
public
TypedObject<git_blob> {
17
using
GitTy = git_blob;
18
19
friend
class
Repo;
20
public
:
21
Blob() =
delete
;
22
24
std::string
content
() const noexcept {
25
return
std::string(
static_cast<
const
char
*
>
(rawcontent()), rawsize());
26
}
27
28
std::string_view
contentView
() const noexcept {
29
return
std::string_view(
static_cast<
const
char
*
>
(rawcontent()), rawsize());
30
}
31
33
GitTy *
blob
() const noexcept {
return
typed
(); }
34
private
:
35
git_object_size_t rawsize() const noexcept {
return
git_blob_rawsize(
blob
()); }
36
const
void
*rawcontent() const noexcept {
return
git_blob_rawcontent(
blob
()); }
37
38
friend
class
Tag;
39
explicit
Blob(
const
Repo &
repo
, GitTy *
blob
)
noexcept
;
40
};
41
42
}
SlGit::Blob::contentView
std::string_view contentView() const noexcept
Get the content of this Blob (as a string_view).
Definition
Blob.h:28
SlGit::Blob::blob
GitTy * blob() const noexcept
Get the stored pointer to libgit2's git_blob.
Definition
Blob.h:33
SlGit::Blob::content
std::string content() const noexcept
Get the content of this Blob (as a string).
Definition
Blob.h:24
SlGit::Object::repo
const Repo & repo() const
Get the Repo this Object lives in.
Definition
Object.h:38
SlGit::TypedObject< git_blob >::typed
git_blob * typed() const noexcept
Definition
Object.h:83
include
git
Blob.h
Generated by
1.17.0