#ifndef CONFIGFILEPARSER_H #define CONFIGFILEPARSER_H #include #include #include #include #include struct mosquitto_auth_opt { char *key = nullptr; char *value = nullptr; mosquitto_auth_opt(const std::string &key, const std::string &value); mosquitto_auth_opt(mosquitto_auth_opt &&other); mosquitto_auth_opt(const mosquitto_auth_opt &other) = delete; ~mosquitto_auth_opt(); }; struct AuthOptCompatWrap { std::vector optArray; AuthOptCompatWrap(const std::unordered_map &authOpts); AuthOptCompatWrap(const AuthOptCompatWrap &other) = delete; AuthOptCompatWrap(AuthOptCompatWrap &&other) = delete; struct mosquitto_auth_opt *head() { return &optArray[0]; } int size() { return optArray.size(); } }; class ConfigFileParser { const std::string path; std::set validKeys; std::unordered_map authOpts; std::unique_ptr authOptCompatWrap; public: ConfigFileParser(const std::string &path); void loadFile(); AuthOptCompatWrap &getAuthOptsCompat(); // Actual config options with their defaults. Just making them public, I can retrain myself misuing them. std::string authPluginPath; std::string logPath; }; #endif // CONFIGFILEPARSER_H