-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathconfig.cpp
More file actions
36 lines (31 loc) · 829 Bytes
/
Copy pathconfig.cpp
File metadata and controls
36 lines (31 loc) · 829 Bytes
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
#include "git2cpp/config.h"
#include "git2cpp/error.h"
#include <git2/config.h>
namespace git
{
Config::Config(std::string const & filename)
{
git_config * cfg;
if (git_config_open_ondisk(&cfg, filename.c_str()))
throw config_open_error();
cfg_.reset(cfg);
}
void Config::Destroy::operator()(git_config* cfg) const
{
git_config_free(cfg);
}
std::string Config::operator[](const char * key) const
{
const char * res;
if (git_config_get_string(&res, cfg_.get(), key))
throw no_such_key_error(key);
return res;
}
int Config::get_int(const char * key) const
{
int res;
if (git_config_get_int32(&res, cfg_.get(), key))
throw no_such_key_error(key);
return res;
}
}