Add printing capabilities for Digest
diff --git a/model/sync-digest.cc b/model/sync-digest.cc
index f6ad110..a6f91f7 100644
--- a/model/sync-digest.cc
+++ b/model/sync-digest.cc
@@ -26,7 +26,16 @@
 #include <boost/assert.hpp>
 #include <boost/exception/errinfo_at_line.hpp>
 
+// for printing, may be disabled in optimized build
+#include <boost/archive/iterators/base64_from_binary.hpp>
+#include <boost/archive/iterators/base64_from_binary.hpp>
+#include <boost/archive/iterators/transform_width.hpp>
+
 using namespace boost;
+using namespace std;
+
+using namespace boost::archive::iterators;
+typedef base64_from_binary<transform_width<string::const_iterator, 6, 8> > base64_t;
 
 namespace Sync {
 
@@ -128,5 +137,27 @@
 }
 
 
+std::ostream&
+Digest::print (std::ostream &os) const
+{
+  BOOST_ASSERT (m_hashLength != 0);
+  
+  ostreambuf_iterator<char> out_it (os); // ostream iterator
+  // need to encode to base64
+  copy (base64_t (reinterpret_cast<const char*> (m_buffer)),
+        base64_t (reinterpret_cast<const char*> (m_buffer+m_hashLength)),
+        out_it);
+
+  return os;
+}
+
+std::ostream &
+operator << (std::ostream &os, const Digest &digest)
+{
+  digest.print (os);
+  return os;
+}
+
+
 } // Sync
 
diff --git a/model/sync-digest.h b/model/sync-digest.h
index adf4d96..7c7174c 100644
--- a/model/sync-digest.h
+++ b/model/sync-digest.h
@@ -96,6 +96,9 @@
   // template<class INT>
   // inline Digest &
   // operator << (INT value);
+
+  std::ostream&
+  print (std::ostream &os) const;
   
 private:
   /**
@@ -141,6 +144,9 @@
   return *this;
 }
 
+std::ostream &
+operator << (std::ostream &os, const Digest &digest);
+
 // template<class INT>
 // Digest &
 // Digest::operator << (INT value)