Semi-working (Full|Diff)State -> XML and back conversions
diff --git a/model/sync-diff-state.cc b/model/sync-diff-state.cc
index d0b6f6c..5a53e81 100644
--- a/model/sync-diff-state.cc
+++ b/model/sync-diff-state.cc
@@ -24,6 +24,8 @@
#include "sync-diff-leaf.h"
#include <boost/make_shared.hpp>
+#include <boost/foreach.hpp>
+#include <boost/assert.hpp>
using namespace boost;
@@ -77,5 +79,32 @@
m_leaves.insert (leaf);
}
+#ifdef _DEBUG
+#define DEBUG_ENDL os << "\n";
+#else
+#define DEBUG_ENDL
+#endif
+
+std::ostream &
+operator << (std::ostream &os, const DiffState &state)
+{
+ os << "<state type=\"diff\">"; DEBUG_ENDL;
+
+ BOOST_FOREACH (shared_ptr<const Leaf> _leaf, state.getLeaves ())
+ {
+ shared_ptr<const DiffLeaf> leaf = dynamic_pointer_cast<const DiffLeaf> (_leaf);
+ BOOST_ASSERT (leaf != 0);
+
+ os << "<item action=\"" << leaf->getOperation () << "\">"; DEBUG_ENDL;
+ os << "<name>" << leaf->getInfo () << "</name>"; DEBUG_ENDL;
+ if (leaf->getOperation () == UPDATE)
+ {
+ os << "<seq>" << leaf->getSeq () << "</seq>"; DEBUG_ENDL;
+ }
+ os << "</item>"; DEBUG_ENDL;
+ }
+ os << "</state>";
+}
+
} // ns3