<commit_before>#ifndef GCOP_PARAMS_H
#define GCOP_PARAMS_H

#include <map>
#include <cstring>
#include <iostream>
#include <Eigen/Dense>

/*
 *  Provides storage and retrieval for arbitrary 
 *  number of parameters of different types (currently only primitives and strings)
 *  TODO: include matrix parameter
 *  Parameters can be loaded/saved from/to a file, or can be inserted at run-time 
 * 
 *
 *  Author: <NAME> (<EMAIL>)
 */

namespace dsl {

#define DSL_PARAMS_MBL 256
  
  typedef Eigen::Matrix<double, 6, 6> Matrix6d;
  typedef Eigen::Matrix<double, 6, 1> Vector6d;
  typedef Eigen::Matrix<double, 5, 5> Matrix5d;
  typedef Eigen::Matrix<double, 5, 1> Vector5d;


class Params
{
 public:

  Params();
  Params(FILE *file);
  Params(const char *fileName);
  Params(std::iostream &io);

  virtual ~Params();

  void Load(const char *fileName);
  void Load(FILE *file);
  void Load(std::iostream &io);

  void Save(const char *fileName) const;
  void Save(FILE* file) const;
  void Save(std::iostream &io) const;

  bool Exists(const char *name) const { return valueMap.find(std::string(name)) != valueMap.end(); }

  void SetInt(const char *name, int v);
  bool GetInt(const char *name, int &v) const;
  
  void SetFloat(const char *name, float v);
  bool GetFloat(const char *name, float &v) const;

  void SetDouble(const char *name, double v);
  bool GetDouble(const char *name, double &v) const;

  void SetVectorXd(const char *name, const Eigen::VectorXd &v);
  bool GetVectorXd(const char *name, Eigen::VectorXd &v) const;

  void SetVector2d(const char *name, const Eigen::Vector2d &v);
  bool GetVector2d(const char *name, Eigen::Vector2d &v) const;

  void SetVector3d(const char *name, const Eigen::Vector3d &v);
  bool GetVector3d(const char *name, Eigen::Vector3d &v) const;

  void SetVector4d(const char *name, const Eigen::Vector4d &v);
  bool GetVector4d(const char *name, Eigen::Vector4d &v) const;

  void SetVector5d(const char *name, const Vector5d &v);
  bool GetVector5d(const char *name, Vector5d &v) const;

  void SetVector6d(const char *name, const Vector6d &v);
  bool GetVector6d(const char *name, Vector6d &v) const;

  void SetMatrix3d(const char *name, const Eigen::Matrix3d &m);
  bool GetMatrix3d(const char *name, Eigen::Matrix3d &m) const;

  void SetMatrix6d(const char *name, const Matrix6d &m);
  bool GetMatrix6d(const char *name, Matrix6d &m) const;

  void SetDoubleVec(const char *name, const std::vector<double> &v);
  bool GetDoubleVec(const char *name, std::vector<double> &v) const;

  void SetFloatArray(const char *name, int n, const float *v);
  bool GetFloatArray(const char *name, int n, float *v) const;

  void SetDoubleArray(const char *name, int n, const double *v);
  bool GetDoubleArray(const char *name, int n, double *v) const;
  
  void SetString(const char *name, const std::string &v);
  bool GetString(const char *name, std::string &v) const;
  
  void SetBool(const char *name, bool v);
  bool GetBool(const char *name, bool &v) const;

  void SetChar(const char *name, char v);
  char GetChar(const char *name, char &v) const;

  void Print(FILE *file = stdout) const;
  void Print(std::iostream &io) const;

 protected:


  struct RemoveDelimiter
  {
    bool operator()(char c)
    {
      return (c =='\r' || c =='\t' || c == ' ' || c == '\n');
    }
  };
  

  void Parse(char *line);

  std::map<std::string, std::string> valueMap;
  char buf[DSL_PARAMS_MBL];
};

}

#endif
<commit_msg>Updates for compiling with ubuntu 18.04<commit_after>#ifndef GCOP_PARAMS_H
#define GCOP_PARAMS_H

#include <map>
#include <cstring>
#include <iostream>
#include <Eigen/Dense>
#include <vector>

/*
 *  Provides storage and retrieval for arbitrary 
 *  number of parameters of different types (currently only primitives and strings)
 *  TODO: include matrix parameter
 *  Parameters can be loaded/saved from/to a file, or can be inserted at run-time 
 * 
 *
 *  Author: <NAME> (<EMAIL>)
 */

namespace dsl {

#define DSL_PARAMS_MBL 256
  
  typedef Eigen::Matrix<double, 6, 6> Matrix6d;
  typedef Eigen::Matrix<double, 6, 1> Vector6d;
  typedef Eigen::Matrix<double, 5, 5> Matrix5d;
  typedef Eigen::Matrix<double, 5, 1> Vector5d;


class Params
{
 public:

  Params();
  Params(FILE *file);
  Params(const char *fileName);
  Params(std::iostream &io);

  virtual ~Params();

  void Load(const char *fileName);
  void Load(FILE *file);
  void Load(std::iostream &io);

  void Save(const char *fileName) const;
  void Save(FILE* file) const;
  void Save(std::iostream &io) const;

  bool Exists(const char *name) const { return valueMap.find(std::string(name)) != valueMap.end(); }

  void SetInt(const char *name, int v);
  bool GetInt(const char *name, int &v) const;
  
  void SetFloat(const char *name, float v);
  bool GetFloat(const char *name, float &v) const;

  void SetDouble(const char *name, double v);
  bool GetDouble(const char *name, double &v) const;

  void SetVectorXd(const char *name, const Eigen::VectorXd &v);
  bool GetVectorXd(const char *name, Eigen::VectorXd &v) const;

  void SetVector2d(const char *name, const Eigen::Vector2d &v);
  bool GetVector2d(const char *name, Eigen::Vector2d &v) const;

  void SetVector3d(const char *name, const Eigen::Vector3d &v);
  bool GetVector3d(const char *name, Eigen::Vector3d &v) const;

  void SetVector4d(const char *name, const Eigen::Vector4d &v);
  bool GetVector4d(const char *name, Eigen::Vector4d &v) const;

  void SetVector5d(const char *name, const Vector5d &v);
  bool GetVector5d(const char *name, Vector5d &v) const;

  void SetVector6d(const char *name, const Vector6d &v);
  bool GetVector6d(const char *name, Vector6d &v) const;

  void SetMatrix3d(const char *name, const Eigen::Matrix3d &m);
  bool GetMatrix3d(const char *name, Eigen::Matrix3d &m) const;

  void SetMatrix6d(const char *name, const Matrix6d &m);
  bool GetMatrix6d(const char *name, Matrix6d &m) const;

  void SetDoubleVec(const char *name, const std::vector<double> &v);
  bool GetDoubleVec(const char *name, std::vector<double> &v) const;

  void SetFloatArray(const char *name, int n, const float *v);
  bool GetFloatArray(const char *name, int n, float *v) const;

  void SetDoubleArray(const char *name, int n, const double *v);
  bool GetDoubleArray(const char *name, int n, double *v) const;
  
  void SetString(const char *name, const std::string &v);
  bool GetString(const char *name, std::string &v) const;
  
  void SetBool(const char *name, bool v);
  bool GetBool(const char *name, bool &v) const;

  void SetChar(const char *name, char v);
  char GetChar(const char *name, char &v) const;

  void Print(FILE *file = stdout) const;
  void Print(std::iostream &io) const;

 protected:


  struct RemoveDelimiter
  {
    bool operator()(char c)
    {
      return (c =='\r' || c =='\t' || c == ' ' || c == '\n');
    }
  };
  

  void Parse(char *line);

  std::map<std::string, std::string> valueMap;
  char buf[DSL_PARAMS_MBL];
};

}

#endif

{'fraction_non_alphanumeric': 0.12876398049899626, 'fraction_numerical': 0.012905075996558647, 'mean_word_length': 4.49645390070922, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '2038126', 'n_tokens_mistral': 2515, 'n_tokens_neox': 2388, 'n_words': 789}