Update TODO
[dueringa_WikiWalker.git] / src / Article.cpp
blobf6ec48b6ab9401b7203e2a15c24112e322851486
1 //! \file Article.cpp
3 #include "Article.h"
5 #include <algorithm>
7 #include "WalkerException.h"
9 namespace WikiWalker
11 size_t Article::countLinks() const
13 if(!analyzed_ && links_.empty()) {
14 throw WalkerException("Article not analyzed yet!");
17 return links_.size();
20 Article::ArticleLinkConstIterator Article::linkBegin() const
22 return links_.cbegin();
25 Article::ArticleLinkConstIterator Article::linkEnd() const
27 return links_.cend();
30 bool Article::addLink(link article)
32 auto newTitle = article.lock()->title();
34 // check for duplicates using title
35 //! \todo Or rather compare pointers again?
36 bool isNewLink =
37 std::none_of(links_.cbegin(), links_.cend(), [&newTitle](const link x) {
38 auto p = x.lock();
39 return p == nullptr ? false : p->title() == newTitle;
40 });
42 if(isNewLink) {
43 links_.push_back(article);
44 analyzed_ = true;
47 return isNewLink;
50 void Article::analyzed(bool analyzed)
52 analyzed_ = analyzed;
55 bool Article::analyzed() const
57 return analyzed_;
60 void Article::marked(bool marked)
62 marked_ = marked;
65 bool Article::marked() const
67 return marked_;
69 } // namespace WikiWalker