This repository was archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathproxy.hpp
More file actions
58 lines (48 loc) · 1.5 KB
/
Copy pathproxy.hpp
File metadata and controls
58 lines (48 loc) · 1.5 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
#pragma once
#include <cppgit2/libgit2_api.hpp>
#include <git2.h>
namespace cppgit2 {
class proxy : public libgit2_api {
public:
// The type of proxy to use.
enum class proxy_type {
none, // Do not attempt to connect through a proxy
auto_, // Try to auto-detect the proxy from the git configuration.
specified // Connect via the URL given in the options
};
class options : public libgit2_api {
public:
options() {
auto ret =
git_proxy_init_options(&default_options_, GIT_PROXY_OPTIONS_VERSION);
c_ptr_ = &default_options_;
if (ret != 0)
throw git_exception();
}
options(git_proxy_options *c_ptr) : c_ptr_(c_ptr) {}
// Version
unsigned int version() const { return c_ptr_->version; }
void set_version(unsigned int value) { c_ptr_->version = value; }
// The type of proxy to use, by URL, auto-detect.
proxy::proxy_type proxy_type() const {
return static_cast<proxy::proxy_type>(c_ptr_->type);
}
void set_proxy_type(proxy::proxy_type type) {
c_ptr_->type = static_cast<git_proxy_t>(type);
}
// URL
std::string url() const {
if (c_ptr_->url)
return std::string(c_ptr_->url);
return "";
}
void set_url(const std::string &url) { c_ptr_->url = url.c_str(); }
// Access libgit2 C ptr
const git_proxy_options *c_ptr() const { return c_ptr_; }
private:
friend proxy;
git_proxy_options *c_ptr_;
git_proxy_options default_options_;
};
};
} // namespace cppgit2