#ifndef NEWSBOAT_CONFIGPARSER_H_ #define NEWSBOAT_CONFIGPARSER_H_ #include #include #include "configactionhandler.h" namespace newsboat { enum class ActionHandlerStatus { INVALID_PARAMS, TOO_FEW_PARAMS, TOO_MANY_PARAMS, INVALID_COMMAND, FILENOTFOUND }; class ConfigParser : public ConfigActionHandler { public: ConfigParser(); ~ConfigParser() override; void register_handler(const std::string& cmd, ConfigActionHandler& handler); void handle_action(const std::string& action, const std::vector& params) override; void dump_config(std::vector&) const override { /* nothing because ConfigParser itself only handles include */ } /// Processes configuration commands from a file at \a filename. /// /// Returns: /// - `false` if the file couldn't be opened; /// - `true` if the whole file was processed completely. /// /// If the file contains any errors, throws `ConfigException` with /// a message explaining the problem. bool parse_file(const std::string& filename); void parse_line(const std::string& line, const std::string& location); static std::string evaluate_backticks(std::string token); private: static std::string evaluate_cmd(const std::string& cmd); std::vector> parsed_content; std::map> action_handlers; std::vector included_files; }; } // namespace newsboat #endif /* NEWSBOAT_CONFIGPARSER_H_ */