inputfile.h Source File

LibRPA: inputfile.h Source File
LibRPA
inputfile.h
1 #pragma once
2 #include <string>
4 
19 {
20  public:
22  static const std::string KV_SEP;
24  static const std::string COMMENTS_IDEN;
25  private:
26  std::string params;
27  public:
28  InputParser() {};
29  InputParser(const std::string &ps): params(ps) {};
30  std::string get_params() const { return params; };
31  void load(const std::string &ps) { params = ps; };
33  void parse_double(const std::string &vname, double &var, double de, int &flag);
35  void parse_int(const std::string &vname, int &var, int de, int &flag);
37  void parse_string(const std::string &vname, std::string &var, const std::string &de, int &flag);
39  void parse_bool(const std::string &vname, bool &var, const bool &de, int &flag);
40 };
41 
43 
46 class InputFile
47 {
48  private:
49  std::string filename;
50  std::string orig_content;
51  public:
52  InputFile() {};
53  InputParser load(const std::string &fn, bool error_if_fail_open = false);
54  std::string get_filename() { return filename; };
55  std::string get_orig_content() { return orig_content; };
56 };
57 
58 void parse_inputfile_to_params(const std::string& fn);
59 
60 extern const std::string input_filename;
Class to represent the input file.
Definition: inputfile.h:47
Class to parse parameters from string.
Definition: inputfile.h:19
static const std::string COMMENTS_IDEN
comments identifier to trim
Definition: inputfile.h:24
void parse_int(const std::string &vname, int &var, int de, int &flag)
parse single integer value to var
Definition: inputfile.cpp:58
void parse_bool(const std::string &vname, bool &var, const bool &de, int &flag)
parse single bool to var
Definition: inputfile.cpp:89
void parse_string(const std::string &vname, std::string &var, const std::string &de, int &flag)
parse single string to var
Definition: inputfile.cpp:78
void parse_double(const std::string &vname, double &var, double de, int &flag)
parse single double value to var
Definition: inputfile.cpp:36
static const std::string KV_SEP
separator between the parameter key and value
Definition: inputfile.h:22