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::move;
Document::Document(const ProfileData &data)
: _data{data}
Document::Document(Config &cfg)
: _cfg{cfg}
, _data{cfg.data}
{
RestClient::init();

View File

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

View File

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