Make config-store more robust for missing XML libraries
authorMitch Watrous <watrous@u.washington.edu>
Thu, 18 Aug 2011 14:14:52 -0700
changeset 7453 1626895e0ebc
parent 7452 5ad2cbe1d2f6
child 7454 e1bbc514be33
Make config-store more robust for missing XML libraries
src/config-store/examples/config-store-save.cc
src/config-store/model/config-store.cc
--- a/src/config-store/examples/config-store-save.cc	Thu Aug 18 17:13:33 2011 +0100
+++ b/src/config-store/examples/config-store-save.cc	Thu Aug 18 14:14:52 2011 -0700
@@ -49,6 +49,7 @@
   // ConfigureAttributes() will work below.
   Config::RegisterRootNamespaceObject (a2_obj);
   
+#ifdef HAVE_LIBXML2
   // Output config store to XML format
   Config::SetDefault ("ns3::ConfigStore::Filename", StringValue ("output-attributes.xml"));
   Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
@@ -56,6 +57,7 @@
   ConfigStore outputConfig;
   outputConfig.ConfigureDefaults ();
   outputConfig.ConfigureAttributes ();
+#endif /* HAVE_LIBXML2 */
 
   // Output config store to txt format
   Config::SetDefault ("ns3::ConfigStore::Filename", StringValue ("output-attributes.txt"));
--- a/src/config-store/model/config-store.cc	Thu Aug 18 17:13:33 2011 +0100
+++ b/src/config-store/model/config-store.cc	Thu Aug 18 14:14:52 2011 -0700
@@ -1,5 +1,6 @@
 #include "config-store.h"
 #include "raw-text-config.h"
+#include "ns3/abort.h"
 #include "ns3/string.h"
 #include "ns3/log.h"
 #include "ns3/simulator.h"
@@ -77,8 +78,20 @@
           m_file = new NoneFileConfig ();
         }
     }
-  else 
+#else
+  if (m_fileFormat == ConfigStore::XML)
+    {
+      if (m_mode == ConfigStore::SAVE || m_mode == ConfigStore::LOAD)
+        {
+	  NS_ABORT_MSG ("ConfigStore tried to read or write an XML file but XML is not supported.");
+        }
+      else
+        {
+          m_file = new NoneFileConfig ();
+        }
+    }
 #endif /* HAVE_LIBXML2 */
+
   if (m_fileFormat == ConfigStore::RAW_TEXT)
     {
       if (m_mode == ConfigStore::SAVE)