fixed strage release build bug

development
Michael Ochmann 8 years ago
parent fa2a65d6c1
commit 02d1f7f6c8
  1. 4
      src/Editor.cpp
  2. 18
      src/config/ConfigParser.cpp
  3. 10
      src/config/ConfigParser.hpp

@ -9,7 +9,7 @@ namespace groove {
Editor::Editor(std::string filename) : x(0), y(0),
buffer(std::make_unique<Buffer>()), mode_(Mode::EDIT),
filename(filename), offset(0), voffset(0),
history(History()), inComment(false), config(config::ConfigParser()) {
history(History()), inComment(false) {
this->modes.emplace(Mode::INSERT, std::make_unique<modes::Insert>(*this));
this->modes.emplace(Mode::EDIT, std::make_unique<modes::Edit>(*this));
this->modes.emplace(Mode::QUIT, std::make_unique<modes::Quit>(*this));
@ -17,7 +17,7 @@ namespace groove {
this->modes.emplace(Mode::EXIT, std::make_unique<modes::Exit>(*this));
this->lineMode = this->config.get<std::string>("linenumbers") == "relative" ? LineMode::RELATIVE :
this->config.get<std::string>("linenumbers") == "none" ? LineMode::NONE : LineMode::NUMBERS;
(this->config.get<std::string>("linenumbers") == "none" ? LineMode::NONE : LineMode::NUMBERS);
this->overlay = newwin(LINES * 0.9, COLS * 0.9, (LINES * 0.1f) / 2.0f, (COLS * 0.1f) / 2.0f);
box(this->overlay, 0, 0);

@ -32,7 +32,7 @@ namespace groove {
std::string value = pair.at(1);
std::trim(key);
std::trim(value);
this->params.emplace(key, ConfigValue(value));
this->params->emplace(key, ConfigValue(value));
}
}
else {
@ -42,30 +42,30 @@ namespace groove {
template<>
std::string ConfigParser::get<std::string>(const std::string& key) {
if (this->params.find(key) == this->params.end())
if (this->params->find(key) == this->params->end())
return "";
return this->params.at(key).strVal;
return this->params->at(key).strVal;
}
template<>
int ConfigParser::get<int>(const std::string& key) {
if (this->params.find(key) == this->params.end())
if (this->params->find(key) == this->params->end())
return 0;
return this->params.at(key).intVal;
return this->params->at(key).intVal;
}
template<>
float ConfigParser::get<float>(const std::string& key) {
if (this->params.find(key) == this->params.end())
if (this->params->find(key) == this->params->end())
return 0.0f;
return this->params.at(key).floatVal;
return this->params->at(key).floatVal;
}
template<>
bool ConfigParser::get<bool>(const std::string& key) {
if (this->params.find(key) == this->params.end())
if (this->params->find(key) == this->params->end())
return false;
return this->params.at(key).boolVal;
return this->params->at(key).boolVal;
}
}

@ -9,6 +9,7 @@
#include <pwd.h>
#include <unistd.h>
#include <sys/types.h>
#include <memory>
namespace std {
static inline std::vector<std::string> explode(const std::string &str, char delimiter) {
@ -54,24 +55,25 @@ namespace groove {
class ConfigParser {
private:
std::unordered_map<std::string, ConfigValue> params;
std::unique_ptr<std::unordered_map<std::string, ConfigValue>> params;
std::string filename;
void parse();
public:
ConfigParser() {
ConfigParser() : params(std::make_unique<std::unordered_map<std::string, ConfigValue>>()) {
this->filename = getenv("HOME");
this->filename += "/.grooverc";
this->parse();
}
ConfigParser(const ConfigParser&) = delete;
template <typename T>
T get(const std::string& key) {}
T get(const std::string& key);
template<typename T>
void set(std::string key, T value) {
std::string newValue = std::to_string(value);
this->params.at(key).set(newValue);
this->params->at(key).set(newValue);
}
};

Loading…
Cancel
Save