forked from p-ranav/cppgit2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_buffer.hpp
More file actions
50 lines (37 loc) · 1.15 KB
/
Copy pathdata_buffer.hpp
File metadata and controls
50 lines (37 loc) · 1.15 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
#pragma once
#include <git2.h>
#include <cppgit2/git_exception.hpp>
#include <cppgit2/libgit2_api.hpp>
#include <cstdlib>
#include <cstring>
#include <string>
namespace cppgit2 {
class data_buffer : public libgit2_api {
public:
// Default construct a data buffer using GIT_BUF_INIT
data_buffer();
// Construct buffer of size n
// Contains a git_buf with char buffer of size n
data_buffer(size_t n);
// Construct buffer from libgit2 C ptr
data_buffer(const git_buf* c_ptr);
// Dispose internal buffer
~data_buffer();
// Check quickly if buffer contains a NUL byte
bool contains_nul() const;
// Resize buffer allocation to make more space
// Currently, this will never shrink a buffer, only expand it
void grow_to_size(size_t target_size);
// Check quickly if buffer looks like it contains binary data
bool is_binary() const;
// Set buffer to a copy of some raw data
void set_buffer(const std::string& buffer);
// Get string representation of data buffer
std::string to_string() const;
// Access libgit2 C ptr
git_buf* c_ptr();
const git_buf* c_ptr() const;
private:
git_buf c_struct_;
};
} // namespace cppgit2