Pass whole Config object to Document.

This commit is contained in:
tastytea 2019-12-25 06:26:20 +01:00
parent ed14492b46
commit d08bb95fbd
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 8 additions and 5 deletions

View File

@ -39,8 +39,9 @@ using std::istringstream;
using std::string; using std::string;
using std::move; using std::move;
Document::Document(const ProfileData &data) Document::Document(Config &cfg)
: _data{data} : _cfg{cfg}
, _data{cfg.data}
{ {
RestClient::init(); RestClient::init();

View File

@ -51,7 +51,7 @@ struct Item
class Document class Document
{ {
public: public:
explicit Document(const ProfileData &data); explicit Document(Config &cfg);
~Document(); ~Document();
Document(const Document &other) = default; Document(const Document &other) = default;
Document &operator=(const Document &other) = delete; Document &operator=(const Document &other) = delete;
@ -64,7 +64,8 @@ public:
void parse(); void parse();
private: private:
const ProfileData &_data; Config &_cfg;
ProfileData &_data;
string _raw_doc; string _raw_doc;
void parse_rss(const pt::ptree &tree); void parse_rss(const pt::ptree &tree);

View File

@ -91,8 +91,9 @@ int main(int argc, char *argv[])
try try
{ {
Config cfg{profile.data()}; Config cfg{profile.data()};
Document doc{cfg.data}; Document doc{cfg};
doc.parse(); doc.parse();
for (const auto &item : doc.new_items) for (const auto &item : doc.new_items)
{ {
cout << "--\n" << item.description.substr(0, 200) << "\n"; cout << "--\n" << item.description.substr(0, 200) << "\n";