Skip to content

Commit

Permalink
Implement env.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Coal committed Feb 22, 2022
1 parent c92deed commit d65c62c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
#include <cstdlib>
#include <string>

class Env {
public:
static std::string get(std::string key, std::string default_value ) {
const char* value = std::getenv(key.c_str());
if (value == NULL) {
return default_value;
}

return value;
}

static int get(std::string key, int default_value) {
const char* value = std::getenv(key.c_str());

if (value == NULL) {
return default_value;
}

return std::atoi(value);
}
};

0 comments on commit d65c62c

Please sign in to comment.