/* This file is part of mastorss. * Copyright © 2019, 2020 tastytea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef MASTORSS_CONFIG_HPP #define MASTORSS_CONFIG_HPP #include #include #include #include #include #include #include namespace mastorss { namespace fs = boost::filesystem; using std::list; using std::pair; using std::string; using std::string_view; using std::uint32_t; /*! * @brief The configuration for a profile as data structure. * * @since 0.10.0 */ struct ProfileData { string access_token; string append; string feedurl; list fixes; list guids; string instance; bool keep_looking{false}; uint32_t interval{30}; size_t max_size{500}; list skip; bool titles_as_cw{false}; bool titles_only{false}; list> replacements; bool add_hashtags{true}; friend std::ostream &operator<<(std::ostream &out, const ProfileData &data); }; /*! * @brief A configuration file. * * @since 0.10.0 */ class Config { public: explicit Config(string profile_name); const string profile; ProfileData profiledata; constexpr static size_t max_guids{100}; void write(); [[nodiscard]] fs::path get_config_dir() const; private: Json::Value _json; [[nodiscard]] fs::path get_filename() const; void generate(); [[nodiscard]] string get_access_token(const string &instance) const; void parse(); list jsonarray_to_stringlist(const Json::Value &jsonarray) const; Json::Value stringlist_to_jsonarray(const list &stringlist) const; }; } // namespace mastorss #endif // MASTORSS_CONFIG_HPP