-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.h
More file actions
65 lines (54 loc) · 1.56 KB
/
config.h
File metadata and controls
65 lines (54 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef CONFIG_H
#define CONFIG_H
#include <filesystem>
#include <vector>
#include <string>
class Config {
public:
Config()
: m_projectFilePath("")
, m_logFilePath("")
, m_configPath("")
, m_loggingEnabled(true)
, m_cppcheck("cppcheck")
, m_filename("")
, m_args({})
, m_printVersion(false)
{
}
/* Load config file.
* Returns an empty string on success, or an error message
* on failure. */
std::string load(const std::filesystem::path &path);
/* Construct cppcheck command string */
std::string command() const;
/* Read command line arguments.
* Returns an empty string on success, or an error message
* on failure. */
std::string parseArgs(int argc, char **argv);
const std::filesystem::path logFilePath() const
{
return m_logFilePath;
}
const std::filesystem::path configPath() const
{
return m_configPath;
}
bool printVersion() const
{
return m_printVersion;
}
private:
static std::filesystem::path findFile(const std::filesystem::path &input_path, const std::string &filename);
static std::string getDefaultLogFilePath(std::filesystem::path &path);
std::string matchFilenameFromCompileCommand();
std::filesystem::path m_projectFilePath;
std::filesystem::path m_logFilePath;
std::filesystem::path m_configPath;
bool m_loggingEnabled;
std::string m_cppcheck;
std::filesystem::path m_filename;
std::vector<std::string> m_args;
bool m_printVersion;
};
#endif