Make config-store more robust for missing XML libraries

This commit is contained in:
Mitch Watrous
2011-08-18 14:14:52 -07:00
parent d8334ab53d
commit 72df156f34
2 changed files with 16 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ int main (int argc, char *argv[])
// 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 @@ int main (int argc, char *argv[])
ConfigStore outputConfig;
outputConfig.ConfigureDefaults ();
outputConfig.ConfigureAttributes ();
#endif /* HAVE_LIBXML2 */
// Output config store to txt format
Config::SetDefault ("ns3::ConfigStore::Filename", StringValue ("output-attributes.txt"));

View File

@@ -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 @@ ConfigStore::ConfigStore ()
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)