Curl return code handling
[dueringa_WikiWalker.git] / src / ArticleCollection.cpp
blob9cde8a80e37f66673bc98e53dc3c735e3981e7bc
1 #include "ArticleCollection.h"
3 ArticleCollection::~ArticleCollection()
5 /* this is still kinda ugly, since other pointers may exist...
6 * also, deleting stack-created articles is going to get ugly
7 * (although you shouldn't have pointers to stack variables
8 * anyway... */
9 for(auto it = articleSet.rbegin(); it != articleSet.rend(); it++) {
10 /* reverse iteration, forward one could cause us trouble if we
11 * delete and erase */
12 delete it->second;
14 articleSet.clear();
17 Article* ArticleCollection::get(std::string title)
19 auto it = articleSet.find(title);
21 if(articleSet.end() == it) {
22 return nullptr;
25 return it->second;
27 bool ArticleCollection::add(Article* article)
29 auto ret = articleSet.insert(std::make_pair(article->getTitle(), article));
30 return ret.second;