<commit_before>#include "configuration.h"


#include <iostream>
#include <ios>
#include <sstream>
#include <fstream>
#include <regex>


#include "ext/json/json.hpp"
using json = nlohmann::json;


Configuration::Configuration()
  : filename_{"config.json"}
{
  std::ifstream fs{filename_};
  std::string cfg;
  json settings;

  if (fs.is_open()) {
    std::stringstream ss;
    ss << fs.rdbuf();
    cfg = ss.str();
    fs.close();
    settings = json::parse(cfg);
  }

  auto get = [this, &settings](const std::string& key, auto def)
    -> decltype(def)
  {
    if (settings.count(key)) {
      return settings[key];
    }
    return def;
  };

  gnss_port = get("gnss_port", std::string("/dev/ttyS0"));
  gnss_port_rate = get("gnss_port_rate", 9600);

  use_msg_rmc = get("use_msg_rmc", true);
  use_msg_gga = get("use_msg_gga", false);
  use_msg_gsv = get("use_msg_gsv", false);
  use_msg_other = get("use_msg_other", false);

  trans_ip = get("trans_ip", std::string("192.168.0.1"));
  trans_port = get("trans_port", 30001);

  recv_ip = get("recv_ip", std::string("192.168.0.1"));
  recv_port = get("recv_port", 30001);

  log_recv = get("log_recv", true);
}<commit_msg>Removed unnecesarry this capture<commit_after>#include "configuration.h"


#include <iostream>
#include <ios>
#include <sstream>
#include <fstream>
#include <regex>


#include "ext/json/json.hpp"
using json = nlohmann::json;


Configuration::Configuration()
  : filename_{"config.json"}
{
  std::ifstream fs{filename_};
  std::string cfg;
  json settings;

  if (fs.is_open()) {
    std::stringstream ss;
    ss << fs.rdbuf();
    cfg = ss.str();
    fs.close();
    settings = json::parse(cfg);
  }

  auto get = [&settings](const std::string& key, auto def)
    -> decltype(def)
  {
    if (settings.count(key)) {
      return settings[key];
    }
    return def;
  };

  gnss_port = get("gnss_port", std::string("/dev/ttyS0"));
  gnss_port_rate = get("gnss_port_rate", 9600);

  use_msg_rmc = get("use_msg_rmc", true);
  use_msg_gga = get("use_msg_gga", false);
  use_msg_gsv = get("use_msg_gsv", false);
  use_msg_other = get("use_msg_other", false);

  trans_ip = get("trans_ip", std::string("192.168.0.1"));
  trans_port = get("trans_port", 30001);

  recv_ip = get("recv_ip", std::string("192.168.0.1"));
  recv_port = get("recv_port", 30001);

  log_recv = get("log_recv", true);
}
{'fraction_non_alphanumeric': 0.18224101479915433, 'fraction_numerical': 0.026215644820295984, 'mean_word_length': 4.2694877505567925, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1511287', 'n_tokens_mistral': 966, 'n_tokens_neox': 901, 'n_words': 170}