lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [4967] Write only leaf elements to xml, excluding GUI topi


From: Greg Chicares
Subject: [lmi-commits] [4967] Write only leaf elements to xml, excluding GUI topic nodes
Date: Mon, 31 May 2010 13:09:38 +0000

Revision: 4967
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4967
Author:   chicares
Date:     2010-05-31 13:09:37 +0000 (Mon, 31 May 2010)
Log Message:
-----------
Write only leaf elements to xml, excluding GUI topic nodes

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/dbdict.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-05-31 00:02:47 UTC (rev 4966)
+++ lmi/trunk/ChangeLog 2010-05-31 13:09:37 UTC (rev 4967)
@@ -25873,3 +25873,19 @@
   version.hpp
 Mark release candidate.
 
+20100530T2243Z <address@hidden> [704]
+
+  dbdict.cpp
+Improve robustness. Formerly, '--print_db' halted at the first error.
+Now, it reports all errors, and writes all the '.dbt' files it can.
+
+20100531T0002Z <address@hidden> [704]
+
+  dbdict.cpp
+Write '.database' elements in name order.
+
+20100531T1309Z <address@hidden> [704]
+
+  dbdict.cpp
+Write only leaf elements to xml, excluding GUI topic nodes.
+

Modified: lmi/trunk/dbdict.cpp
===================================================================
--- lmi/trunk/dbdict.cpp        2010-05-31 00:02:47 UTC (rev 4966)
+++ lmi/trunk/dbdict.cpp        2010-05-31 13:09:37 UTC (rev 4967)
@@ -49,7 +49,11 @@
 
 std::string DBDictionary::cached_filename_;
 
-int const NumberOfEntries = DB_LAST;
+// '23' is the number of non-leaf entities. Soon it will become
+// unnecessary, so there's no point in deriving it in a more
+// robust way.
+unsigned int const NumberOfEntries = DB_LAST;
+unsigned int const NumberOfLeaves  = DB_LAST - 23;
 
 //============================================================================
 DBDictionary& DBDictionary::instance()
@@ -96,8 +100,14 @@
             LMI_ASSERT(i->first == n.Idx);
             LMI_ASSERT(i->first == i->second.key());
             LMI_ASSERT(n.ShortName == db_name_from_key(i->first));
+            // Only leaf entities are wanted.
+            if(DB_FIRST == n.ParentIdx)
+                {
+                continue;
+                }
             m[n.ShortName] = i->second;
             }
+        LMI_ASSERT(NumberOfLeaves == m.size());
         typedef std::map<std::string,database_entity>::const_iterator mci;
         for(mci i = m.begin(); i != m.end(); ++i)
             {
@@ -168,14 +178,14 @@
 
     xml_serialize::from_xml(root, dictionary_);
 
-    if(NumberOfEntries != static_cast<int>(dictionary_.size()))
+    if(NumberOfLeaves != dictionary_.size())
         {
         InvalidateCache();
         fatal_error()
             << "File '"
             << filename
             << "' is not up to date or is corrupted."
-            << " It should contain " << NumberOfEntries
+            << " It should contain " << NumberOfLeaves
             << " elements, but it actually contains " << dictionary_.size()
             << " elements."
             << LMI_FLUSH
@@ -198,7 +208,7 @@
 void DBDictionary::WriteDB(std::string const& filename)
 {
     InvalidateCache();
-    if(NumberOfEntries != static_cast<int>(dictionary_.size()))
+    if(NumberOfEntries != dictionary_.size())
         {
         fatal_error()
             << "Error writing database '"
@@ -206,7 +216,7 @@
             << "': the database has " << dictionary_.size()
             << " entries, but should have " << NumberOfEntries << '.'
             ;
-        for(int j = 0; j < NumberOfEntries; j++)
+        for(unsigned int j = 0; j < NumberOfEntries; j++)
             {
             if(!dictionary_.count(j))
                 {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]