[pan] data-impl done



commit fb2a5d8ac659b538e9f84753c188313c9a36501d
Author: Thomas Tanner <thosrtanner googlemail com>
Date:   Thu Sep 29 22:16:52 2022 +0100

    data-impl done

 pan/data-impl/data-io.cc  |  4 ++--
 pan/data-impl/groups.cc   |  6 +++---
 pan/data-impl/headers.cc  | 44 ++++++++++++++++++++++----------------------
 pan/data-impl/memchunk.h  |  4 ++--
 pan/data-impl/my-tree.cc  | 18 +++++++++---------
 pan/data-impl/profiles.cc |  8 ++++----
 pan/data-impl/server.cc   | 12 ++++++------
 pan/data-impl/xover.cc    | 26 +++++++++++++-------------
 8 files changed, 61 insertions(+), 61 deletions(-)
---
diff --git a/pan/data-impl/data-io.cc b/pan/data-impl/data-io.cc
index 864cc8d..c47b46f 100644
--- a/pan/data-impl/data-io.cc
+++ b/pan/data-impl/data-io.cc
@@ -221,7 +221,7 @@ LineReader*
 DataIO :: read_tasks () const
 {
   const std::string filename (get_tasks_filename ());
-  return file::file_exists(filename.c_str()) ? read_file(filename) : 0;
+  return file::file_exists(filename.c_str()) ? read_file(filename) : nullptr;
 }
 
 LineReader*
@@ -252,7 +252,7 @@ LineReader*
 DataIO :: read_group_headers (const Quark& group) const
 {
   const std::string filename (get_group_headers_filename (group));
-  return file::file_exists(filename.c_str()) ? read_file(filename) : 0;
+  return file::file_exists(filename.c_str()) ? read_file(filename) : nullptr;
 }
 
 LineReader*
diff --git a/pan/data-impl/groups.cc b/pan/data-impl/groups.cc
index 31ae2c5..f58ad23 100644
--- a/pan/data-impl/groups.cc
+++ b/pan/data-impl/groups.cc
@@ -241,7 +241,7 @@ DataImpl :: save_newsrc_files (DataIO& data_io) const
 
       // if the group's been read, save its read number ranges...
       const ReadGroup::Server * rgs (find_read_group_server (group, server));
-      if (rgs != 0) {
+      if (rgs != nullptr) {
         newsrc_string.clear ();
         rgs->_read.to_string (newsrc_string);
         if (!newsrc_string.empty()) {
@@ -501,7 +501,7 @@ DataImpl :: add_groups (const Quark       & server,
   ensure_descriptions_are_loaded ();
 
   Server * s (find_server (server));
-  assert (s != 0);
+  assert (s != nullptr);
 
   {
     AlphabeticalQuarkOrdering o;
@@ -584,7 +584,7 @@ void
 DataImpl :: mark_group_read (const Quark& groupname)
 {
   ReadGroup * rg (find_read_group (groupname));
-  if (rg != 0) {
+  if (rg != nullptr) {
     foreach (ReadGroup::servers_t, rg->_servers, it) {
       //std::cerr << LINE_ID << " marking read range [0..." << it->second._xover_high << "] in " << 
get_server_address(it->first) << ']' << std::endl;
       it->second._read.mark_range (static_cast<Article_Number>(0), it->second._xover_high, true);
diff --git a/pan/data-impl/headers.cc b/pan/data-impl/headers.cc
index febdee1..c12dc24 100644
--- a/pan/data-impl/headers.cc
+++ b/pan/data-impl/headers.cc
@@ -58,7 +58,7 @@ DataImpl :: GroupHeaders :: ~GroupHeaders ()
 DataImpl :: ArticleNode*
 DataImpl :: GroupHeaders :: find_node (const Quark& mid)
 {
-  ArticleNode * node (0);
+  ArticleNode * node (nullptr);
   nodes_t::iterator it (_nodes.find (mid));
   if (it != _nodes.end())
     node = it->second;
@@ -68,7 +68,7 @@ DataImpl :: GroupHeaders :: find_node (const Quark& mid)
 const DataImpl :: ArticleNode*
 DataImpl :: GroupHeaders :: find_node (const Quark& mid) const
 {
-  const ArticleNode * node (0);
+  const ArticleNode * node (nullptr);
   nodes_t::const_iterator it (_nodes.find (mid));
   if (it != _nodes.end())
     node = it->second;
@@ -89,7 +89,7 @@ DataImpl :: GroupHeaders :: find_parent_message_id (const Quark& mid) const
 const Article*
 DataImpl :: GroupHeaders :: find_article (const Quark& message_id) const
 {
-  Article *a (0);
+  Article *a (nullptr);
 
   const ArticleNode * node (find_node (message_id));
   if (node)
@@ -101,7 +101,7 @@ DataImpl :: GroupHeaders :: find_article (const Quark& message_id) const
 Article*
 DataImpl :: GroupHeaders :: find_article (const Quark& message_id)
 {
-  Article *a(0);
+  Article *a(nullptr);
 
   const ArticleNode * node (find_node (message_id));
   if (node)
@@ -116,7 +116,7 @@ DataImpl :: GroupHeaders :: remove_articles (const quarks_t& mids)
   nodes_v nodes;
   find_nodes (mids, _nodes, nodes);
   foreach (nodes_v, nodes, it)
-    (*it)->_article = 0;
+    (*it)->_article = nullptr;
   _dirty = true;
 }
 
@@ -124,14 +124,14 @@ const DataImpl :: GroupHeaders*
 DataImpl :: get_group_headers (const Quark& group) const
 {
    group_to_headers_t::const_iterator it (_group_to_headers.find(group));
-   return it==_group_to_headers.end() ? 0 : it->second;
+   return it==_group_to_headers.end() ? nullptr : it->second;
 }
 
 DataImpl :: GroupHeaders*
 DataImpl :: get_group_headers (const Quark& group)
 {
    group_to_headers_t::iterator it (_group_to_headers.find(group));
-   return it==_group_to_headers.end() ? 0 : it->second;
+   return it==_group_to_headers.end() ? nullptr : it->second;
 }
 
 void
@@ -186,7 +186,7 @@ void
 DataImpl :: unref_group   (const Quark& group)
 {
   GroupHeaders * h (get_group_headers (group));
-  pan_return_if_fail (h != 0);
+  pan_return_if_fail (h != nullptr);
 
   --h->_ref;
 //  std::cerr << LINE_ID << " group " << group << " refcount down to " << h->_ref << std::endl;
@@ -260,7 +260,7 @@ DataImpl :: load_article (const Quark       & group,
 #endif
 
   GroupHeaders * h (get_group_headers (group));
-  pan_return_if_fail (h!=0);
+  pan_return_if_fail (h!=nullptr);
 
   // populate the current node
   const Quark& mid (article->message_id);
@@ -301,7 +301,7 @@ DataImpl :: load_article (const Quark       & group,
     {
       //std::cerr << LINE_ID << " haven't mapped " << new_parent_mid << " before..." << std::endl;
       ArticleNode * new_parent_node (h->_nodes[new_parent_mid]);
-      const bool found (new_parent_node != 0);
+      const bool found (new_parent_node != nullptr);
       if (!found) {
         //std::cerr << LINE_ID << " didn't find it; adding new node for " << new_parent_mid << std::endl;
         static const ArticleNode blank_node;
@@ -311,7 +311,7 @@ DataImpl :: load_article (const Quark       & group,
       }
       node->_parent = new_parent_node;
       if (find_ancestor (new_parent_node, new_parent_mid)) {
-        node->_parent = 0;
+        node->_parent = nullptr;
         //std::cerr << LINE_ID << " someone's been munging References headers to cause trouble!" << 
std::endl;
         break;
       }
@@ -335,11 +335,11 @@ DataImpl :: load_article (const Quark       & group,
 
       // unlink from old parent
       old_parent_node->_children.remove (node);
-      node->_parent = 0;
+      node->_parent = nullptr;
 
       // link to new parent
       ArticleNode * new_parent_node (h->_nodes[new_parent_mid]);
-      const bool found (new_parent_node != 0);
+      const bool found (new_parent_node != nullptr);
       if (!found) {
         //std::cerr << LINE_ID << " didn't find it; adding new node for " << new_parent_mid << std::endl;
         static const ArticleNode blank_node;
@@ -348,8 +348,8 @@ DataImpl :: load_article (const Quark       & group,
         new_parent_node->_mid = new_parent_mid;
       }
       node->_parent = new_parent_node;
-      if (find_ancestor (new_parent_node, new_parent_mid) != 0) {
-        node->_parent = 0;
+      if (find_ancestor (new_parent_node, new_parent_mid) != nullptr) {
+        node->_parent = nullptr;
         //std::cerr << LINE_ID << " someone's been munging References headers to cause trouble!" << 
std::endl;
         break;
       }
@@ -360,7 +360,7 @@ DataImpl :: load_article (const Quark       & group,
   }
 
   // recursion?
-  assert (find_ancestor(article_node, article->message_id) == 0);
+  assert (find_ancestor(article_node, article->message_id) == nullptr);
 }
 
 #if 0
@@ -397,7 +397,7 @@ DataImpl :: load_part (const Quark          & group,
 {
    GroupHeaders * h = get_group_headers (group);
    Article * a (h->find_article (mid));
-   pan_return_if_fail (a != 0);
+   pan_return_if_fail (a != nullptr);
 
    if (a->add_part (number, part_mid, bytes))
      a->lines += lines;
@@ -410,7 +410,7 @@ namespace
     unsigned long long val (0ull);
     if (!view.empty()) {
       errno = 0;
-      val = strtoull (view.str, 0, 10);
+      val = strtoull (view.str, nullptr, 10);
       if (errno) val = 0ull;
     }
     return val;
@@ -424,7 +424,7 @@ DataImpl :: load_headers (const DataIO   & data_io,
   TimeElapsed timer;
 
   GroupHeaders * h (get_group_headers (group));
-  assert (h != 0);
+  assert (h != nullptr);
 
   Article_Count article_count (0);
   Article_Count unread_count (0);
@@ -479,7 +479,7 @@ DataImpl :: load_headers (const DataIO   & data_io,
       unsigned int expire_count (0);
       in->getline (line);
       //const unsigned long article_qty = view_to_ul (line); /* unused */
-      const time_t now (time (0));
+      const time_t now (time (nullptr));
       PartBatch part_batch;
       for (;;)
       {
@@ -700,7 +700,7 @@ DataImpl :: save_headers (DataIO                       & data_io,
 {
   const char endl ('\n');
   const GroupHeaders * h (get_group_headers (group));
-  assert (h != 0);
+  assert (h != nullptr);
 
   part_count = 0;
   article_count = 0;
@@ -926,7 +926,7 @@ bool
 DataImpl :: is_read (const Article* a) const
 {
   // if it's read on any server, the whole thing is read.
-  if (a != 0)  {
+  if (a != nullptr)  {
     foreach_const (Xref, a->xref, xit) {
       const ReadGroup::Server * rgs (find_read_group_server (xit->group, xit->server));
       if (rgs && rgs->_read.is_marked (xit->number))
diff --git a/pan/data-impl/memchunk.h b/pan/data-impl/memchunk.h
index 6679f5e..a61a687 100644
--- a/pan/data-impl/memchunk.h
+++ b/pan/data-impl/memchunk.h
@@ -45,7 +45,7 @@ namespace pan {
         return phead;
       }
 
-      MemChunk():chunks(0),phead(0),head(0),nelem(Chunk::size/sizeof(T)),count(0)
+      MemChunk():chunks(nullptr),phead(nullptr),head(nullptr),nelem(Chunk::size/sizeof(T)),count(0)
       {grow();}
 
       ~MemChunk()
@@ -63,7 +63,7 @@ namespace pan {
         chunks=chunks->next;
         delete p;
 
-        while(chunks!=0)
+        while(chunks!=nullptr)
         {
           t=reinterpret_cast<T*>(chunks->mem);
           for (i=0;i<nelem;i++)
diff --git a/pan/data-impl/my-tree.cc b/pan/data-impl/my-tree.cc
index e64b105..cb453c6 100644
--- a/pan/data-impl/my-tree.cc
+++ b/pan/data-impl/my-tree.cc
@@ -59,8 +59,8 @@ DataImpl :: MyTree :: get_children (const Quark& mid, articles_t & setme) const
 const Article*
 DataImpl :: MyTree :: get_parent (const Quark& mid) const
 {
-  const Article * parent (0);
-  const ArticleNode * parent_node (0);
+  const Article * parent (nullptr);
+  const ArticleNode * parent_node (nullptr);
 
   nodes_t::const_iterator child_it (_nodes.find (mid));
   if (child_it != _nodes.end())
@@ -75,7 +75,7 @@ const Article*
 DataImpl :: MyTree :: get_article (const Quark& mid) const
 {
   nodes_t::const_iterator it (_nodes.find (mid));
-  return it==_nodes.end() ? 0 : it->second->_article;
+  return it==_nodes.end() ? nullptr : it->second->_article;
 }
 
 size_t
@@ -102,7 +102,7 @@ DataImpl :: MyTree :: set_rules (const Data::ShowType    show_type,
   _show_type = show_type;
 
   const GroupHeaders * h (_data.get_group_headers (_group));
-  g_assert (h != 0);
+  g_assert (h != nullptr);
   const_nodes_v candidates;
   candidates.reserve (h->_nodes.size());
   foreach_const (nodes_t, h->_nodes, it) {
@@ -127,7 +127,7 @@ DataImpl :: MyTree :: set_filter (const Data::ShowType    show_type,
 
   // refilter all the articles in the group...
   const GroupHeaders * h (_data.get_group_headers (_group));
-  g_assert (h != 0);
+  g_assert (h != nullptr);
   const_nodes_v candidates;
   candidates.reserve (h->_nodes.size());
   foreach_const (nodes_t, h->_nodes, it) {
@@ -281,7 +281,7 @@ DataImpl :: MyTree :: download_articles (std::set<const Article*> s)
     if (!_data.is_read(*it))
       tasks.push_back (new TaskArticle (_data, _data, **it, cache, _data,
                                         always ? TaskArticle::ALWAYS_MARK : action ? 
TaskArticle::ACTION_TRUE : TaskArticle::ACTION_FALSE,
-                                        0, TaskArticle::DECODE, _save_path));
+                                        nullptr, TaskArticle::DECODE, _save_path));
   if (!tasks.empty())
     queue->add_tasks (tasks, Queue::BOTTOM);
 }
@@ -390,7 +390,7 @@ DataImpl :: MyTree :: remove_articles (const quarks_t& mids)
     const Quark& mid (node->_mid);
 
     if (node->_article) {
-        node->_article = 0;
+        node->_article = nullptr;
         diffs.removed.insert (diffs.removed.end(), mid);
     }
 
@@ -560,7 +560,7 @@ DataImpl :: MyTree :: add_articles (const const_nodes_v& nodes_in)
     added.message_id = tree_node->_mid;
 
     // find the first ancestor that's present in our tree
-    ArticleNode * parent (0);
+    ArticleNode * parent (nullptr);
     const nodes_t::const_iterator nend (_nodes.end());
     for (const ArticleNode *it(node->_parent); it && !parent; it=it->_parent) {
       nodes_t::iterator nit (_nodes.find (it->_mid));
@@ -635,7 +635,7 @@ DataImpl :: MyTree :: add_articles (const const_nodes_v& nodes_in)
 
     //std::cerr << LINE_ID << " looking for a new parent for "
     //          << tree_node->_mid << std::endl;
-    ArticleNode * new_parent (0);
+    ArticleNode * new_parent (nullptr);
     node = node->_parent;
     while (node && !new_parent) {
       //std::cerr << LINE_ID << " maybe " << node->_mid
diff --git a/pan/data-impl/profiles.cc b/pan/data-impl/profiles.cc
index b7fde93..a6c52d3 100644
--- a/pan/data-impl/profiles.cc
+++ b/pan/data-impl/profiles.cc
@@ -166,10 +166,10 @@ ProfilesImpl :: load (const StringView& filename)
     p.start_element = start_element;
     p.end_element = end_element;
     p.text = text;
-    p.passthrough = 0;
-    p.error = 0;
-    GError * gerr (0);
-    GMarkupParseContext* c (g_markup_parse_context_new (&p, (GMarkupParseFlags)0, &mc, 0));
+    p.passthrough = nullptr;
+    p.error = nullptr;
+    GError * gerr (nullptr);
+    GMarkupParseContext* c (g_markup_parse_context_new (&p, (GMarkupParseFlags)0, &mc, nullptr));
     g_markup_parse_context_parse (c, txt.c_str(), txt.size(), &gerr);
     if (gerr) {
       Log::add_err_va (_("Error reading file \"%s\": %s"), filename.to_string().c_str(), gerr->message);
diff --git a/pan/data-impl/server.cc b/pan/data-impl/server.cc
index b9860f9..78978df 100644
--- a/pan/data-impl/server.cc
+++ b/pan/data-impl/server.cc
@@ -78,7 +78,7 @@ DataImpl :: add_new_server ()
 Data :: Server*
 DataImpl :: find_server (const Quark& server)
 {
-  Server * retval (0);
+  Server * retval (nullptr);
 
   servers_t::iterator it (_servers.find (server));
   if (it != _servers.end())
@@ -89,7 +89,7 @@ DataImpl :: find_server (const Quark& server)
 const Data :: Server*
 DataImpl :: find_server (const Quark& server) const
 {
-  const Server * retval (0);
+  const Server * retval (nullptr);
 
   servers_t::const_iterator it (_servers.find (server));
   if (it != _servers.end())
@@ -515,10 +515,10 @@ DataImpl :: load_server_properties (const DataIO& source)
   p.start_element = start_element;
   p.end_element = end_element;
   p.text = text;
-  p.passthrough = 0;
-  p.error = 0;
-  GMarkupParseContext* c = g_markup_parse_context_new (&p, (GMarkupParseFlags)0, &spc, 0);
-  GError * gerr (0);
+  p.passthrough = nullptr;
+  p.error = nullptr;
+  GMarkupParseContext* c = g_markup_parse_context_new (&p, (GMarkupParseFlags)0, &spc, nullptr);
+  GError * gerr (nullptr);
   if (!txt.empty())
     g_markup_parse_context_parse (c, txt.c_str(), txt.size(), &gerr);
   if (gerr) {
diff --git a/pan/data-impl/xover.cc b/pan/data-impl/xover.cc
index dfd2fda..011c3ae 100644
--- a/pan/data-impl/xover.cc
+++ b/pan/data-impl/xover.cc
@@ -41,8 +41,8 @@ namespace
                                 int                & parts,
                                 std::string        & no_part)
   {
-    const char * numerator = 0;
-    const char * denominator = 0;
+    const char * numerator = nullptr;
+    const char * denominator = nullptr;
 
     const char * s (subj.begin());
     const char * pch (subj.end());
@@ -67,19 +67,19 @@ namespace
       while (s!=pch && isdigit(*pch))
         --pch;
       if (s==pch || (*pch!='(' && *pch!='[')) {
-        denominator = 0;
+        denominator = nullptr;
         continue;
       }
 
       // N -> part
       numerator = pch+1;
-      char * numerator_end (0);
+      char * numerator_end (nullptr);
       part = (int) strtol (numerator, &numerator_end, 10);
       parts = atoi (denominator);
 
       if (part > parts) {
         // false positive...
-        numerator = denominator = 0;
+        numerator = denominator = nullptr;
         part = parts = 0;
         continue;
       }
@@ -144,14 +144,14 @@ DataImpl :: xover_clear_workarea (const Quark& group)
    _xovers.erase (group);
    if (group == _cached_xover_group) {
       _cached_xover_group.clear ();
-      _cached_xover_entry = 0;
+      _cached_xover_entry = nullptr;
    }
 }
 
 DataImpl :: XOverEntry&
 DataImpl :: xover_get_workarea (const Quark& group)
 {
-   XOverEntry * entry (0);
+   XOverEntry * entry (nullptr);
    if (group == _cached_xover_group)
       entry = _cached_xover_entry;
    else {
@@ -179,7 +179,7 @@ DataImpl :: xover_ref (const Quark& group)
   foreach_const (nodes_t, h->_nodes, it) {
     const Quark& mid (it->first);
     const Article * a (it->second->_article);
-    if (a != 0)
+    if (a != nullptr)
       workarea._subject_lookup.insert (std::pair<Quark,Quark>(a->subject,mid));
   }
 }
@@ -193,7 +193,7 @@ DataImpl :: xover_flush (const Quark& group)
   workarea._added_batch.clear();
   on_articles_changed (group, workarea._changed_batch, true);
   workarea._changed_batch.clear();
-  workarea._last_flush_time = time(0);
+  workarea._last_flush_time = time(nullptr);
 }
 
 void
@@ -216,7 +216,7 @@ DataImpl :: set_xover_low (const Quark   & group,
                            const Article_Number   low)
 {
   ReadGroup::Server * rgs (find_read_group_server (group, server));
-  if (rgs != 0)
+  if (rgs != nullptr)
     rgs->_read.mark_range (static_cast<Article_Number>(0), low, true);
 }
 
@@ -241,13 +241,13 @@ DataImpl :: xover_add (const Quark         & server,
     Log::add_err_va (_("Error reading from %s: unknown group \"%s\""),
                      get_server_address(server).c_str(),
                      group.c_str());
-    return 0;
+    return nullptr;
   }
 
 
 //  std::cerr<<"xover add : "<<subject<<" "<<author<<" "<<message_id<<" lines "<<line_count<<" bytes 
"<<byte_count<<std::endl;
 
-  const Article* new_article (0);
+  const Article* new_article (nullptr);
 
   XOverEntry& workarea (xover_get_workarea (group));
   const std::string references (
@@ -325,7 +325,7 @@ DataImpl :: xover_add (const Quark         & server,
     workarea._changed_batch.insert(art_mid);
 
   // maybe flush the batched changes
-  if ((time(0) - workarea._last_flush_time) >= 10)
+  if ((time(nullptr) - workarea._last_flush_time) >= 10)
     xover_flush (group);
 
   if (is_virtual)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]