88#pragma once
99
1010#include < cstdio>
11- #include < functional>
1211
1312#include < jansson.h>
1413#include < unistd.h>
@@ -25,71 +24,26 @@ namespace villas {
2524namespace node {
2625
2726class Config {
28-
29- protected:
30- using str_walk_fcn_t = std::function<json_t *(json_t *)>;
31-
27+ private:
3228 Logger logger;
33-
34- std::list<std::string> includeDirectories;
35- std::string configPath;
36-
37- // Check if file exists on local system.
38- static bool isLocalFile (const std::string &uri) {
39- return access (uri.c_str (), F_OK) != -1 ;
40- }
41-
42- // Decode configuration file.
43- json_t *decode (FILE *f);
44-
45- #ifdef WITH_CONFIG
46- // Convert libconfig .conf file to libjansson .json file.
47- json_t *libconfigDecode (FILE *f);
48-
49- static const char **includeFuncStub (config_t *cfg, const char *include_dir,
50- const char *path, const char **error);
51-
52- const char **includeFunc (config_t *cfg, const char *include_dir,
53- const char *path, const char **error);
54- #endif // WITH_CONFIG
55-
56- // Load configuration from standard input (stdim).
57- FILE *loadFromStdio ();
58-
59- // Load configuration from local file.
60- FILE *loadFromLocalFile (const std::string &u);
61-
62- std::list<std::string> resolveIncludes (const std::string &name);
63-
64- void resolveEnvVars (std::string &text);
65-
66- // Resolve custom include directives.
67- json_t *expandIncludes (json_t *in);
68-
69- // To shell-like subsitution of environment variables in strings.
70- json_t *expandEnvVars (json_t *in);
71-
72- // Run a callback function for each string in the config
73- json_t *walkStrings (json_t *in, str_walk_fcn_t cb);
74-
75- // Get the include dirs
76- std::list<std::string> getIncludeDirectories (FILE *f) const ;
29+ fs::path configPath;
7730
7831public:
7932 json_t *root;
8033
8134 Config ();
82- Config (const std::string &u );
35+ Config (fs::path path );
8336
37+ Config (Config const &) = delete ;
38+ Config &operator =(Config const &) = delete ;
39+ Config (Config &&) = delete ;
40+ Config &operator =(Config &&) = delete ;
8441 ~Config ();
8542
86- json_t *load (std::FILE *f, bool resolveIncludes = true ,
87- bool resolveEnvVars = true );
88-
89- json_t *load (const std::string &u, bool resolveIncludes = true ,
43+ json_t *load (fs::path path, bool resolveIncludes = true ,
9044 bool resolveEnvVars = true );
9145
92- std::string const &getConfigPath () const { return configPath; }
46+ fs::path const &getConfigPath () const { return configPath; }
9347};
9448
9549} // namespace node
0 commit comments