DER encoding: added PrintVisitor.
diff --git a/Makefile.am b/Makefile.am
index f2e717f..46d6352 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -121,6 +121,7 @@
ndn-cpp/encoding/der/der.cpp ndn-cpp/encoding/der/der.hpp \
ndn-cpp/encoding/der/visitor/certificate-data-visitor.cpp ndn-cpp/encoding/der/visitor/certificate-data-visitor.hpp \
ndn-cpp/encoding/der/visitor/no-arguments-visitor.cpp ndn-cpp/encoding/der/visitor/no-arguments-visitor.hpp \
+ ndn-cpp/encoding/der/visitor/print-visitor.cpp ndn-cpp/encoding/der/visitor/print-visitor.hpp \
ndn-cpp/encoding/der/visitor/public-key-visitor.cpp ndn-cpp/encoding/der/visitor/public-key-visitor.hpp \
ndn-cpp/encoding/der/visitor/simple-visitor.cpp ndn-cpp/encoding/der/visitor/simple-visitor.hpp \
ndn-cpp/encoding/der/visitor/visitor.hpp \
diff --git a/Makefile.in b/Makefile.in
index 387f29d..b10f072 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -188,6 +188,7 @@
ndn-cpp/encoding/der/der.lo \
ndn-cpp/encoding/der/visitor/certificate-data-visitor.lo \
ndn-cpp/encoding/der/visitor/no-arguments-visitor.lo \
+ ndn-cpp/encoding/der/visitor/print-visitor.lo \
ndn-cpp/encoding/der/visitor/public-key-visitor.lo \
ndn-cpp/encoding/der/visitor/simple-visitor.lo \
ndn-cpp/encoding/der/visitor/void-visitor.lo \
@@ -672,6 +673,7 @@
ndn-cpp/encoding/der/der.cpp ndn-cpp/encoding/der/der.hpp \
ndn-cpp/encoding/der/visitor/certificate-data-visitor.cpp ndn-cpp/encoding/der/visitor/certificate-data-visitor.hpp \
ndn-cpp/encoding/der/visitor/no-arguments-visitor.cpp ndn-cpp/encoding/der/visitor/no-arguments-visitor.hpp \
+ ndn-cpp/encoding/der/visitor/print-visitor.cpp ndn-cpp/encoding/der/visitor/print-visitor.hpp \
ndn-cpp/encoding/der/visitor/public-key-visitor.cpp ndn-cpp/encoding/der/visitor/public-key-visitor.hpp \
ndn-cpp/encoding/der/visitor/simple-visitor.cpp ndn-cpp/encoding/der/visitor/simple-visitor.hpp \
ndn-cpp/encoding/der/visitor/visitor.hpp \
@@ -927,6 +929,9 @@
ndn-cpp/encoding/der/visitor/no-arguments-visitor.lo: \
ndn-cpp/encoding/der/visitor/$(am__dirstamp) \
ndn-cpp/encoding/der/visitor/$(DEPDIR)/$(am__dirstamp)
+ndn-cpp/encoding/der/visitor/print-visitor.lo: \
+ ndn-cpp/encoding/der/visitor/$(am__dirstamp) \
+ ndn-cpp/encoding/der/visitor/$(DEPDIR)/$(am__dirstamp)
ndn-cpp/encoding/der/visitor/public-key-visitor.lo: \
ndn-cpp/encoding/der/visitor/$(am__dirstamp) \
ndn-cpp/encoding/der/visitor/$(DEPDIR)/$(am__dirstamp)
@@ -1149,6 +1154,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/encoding/der/$(DEPDIR)/der.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/encoding/der/visitor/$(DEPDIR)/certificate-data-visitor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/encoding/der/visitor/$(DEPDIR)/no-arguments-visitor.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/encoding/der/visitor/$(DEPDIR)/print-visitor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/encoding/der/visitor/$(DEPDIR)/public-key-visitor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/encoding/der/visitor/$(DEPDIR)/simple-visitor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/encoding/der/visitor/$(DEPDIR)/void-visitor.Plo@am__quote@
diff --git a/ndn-cpp/encoding/der/visitor/print-visitor.cpp b/ndn-cpp/encoding/der/visitor/print-visitor.cpp
new file mode 100644
index 0000000..ab56b5d
--- /dev/null
+++ b/ndn-cpp/encoding/der/visitor/print-visitor.cpp
@@ -0,0 +1,131 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Yingdi Yu <yingdi@cs.ucla.edu>
+ * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "print-visitor.hpp"
+#include "../der.hpp"
+#include <iostream>
+#include <iomanip>
+
+using namespace std;
+
+namespace ndn {
+
+namespace der {
+
+void
+PrintVisitor::visit(DerBool& derBool, ndnboost::any param)
+{
+ const string& indent = ndnboost::any_cast<const string&>(param);
+
+ printData(derBool.getHeader(), indent);
+ printData(derBool.getPayload(), indent + " ");
+}
+
+void
+PrintVisitor::visit(DerInteger& derInteger, ndnboost::any param)
+{
+ const string& indent = ndnboost::any_cast<const string&>(param);
+
+ printData(derInteger.getHeader(), indent);
+ printData(derInteger.getPayload(), indent + " ");
+}
+
+void
+PrintVisitor::visit(DerPrintableString& derPStr, ndnboost::any param)
+{
+ const string& indent = ndnboost::any_cast<const string&>(param);
+
+ printData(derPStr.getHeader(), indent);
+ printData(derPStr.getPayload(), indent + " ");
+}
+
+void
+PrintVisitor::visit(DerBitString& derBStr, ndnboost::any param)
+{
+ const string& indent = ndnboost::any_cast<const string&>(param);
+
+ printData(derBStr.getHeader(), indent);
+ const std::vector<uint8_t>& payload = derBStr.getPayload();
+ cout << indent << " " << " " << hex << setw(2) << setfill('0') << (int)(uint8_t)payload[0] << endl;
+ printData(payload, indent + " ", 1);
+}
+
+void
+PrintVisitor::visit(DerNull& derNull, ndnboost::any param)
+{
+ const string& indent = ndnboost::any_cast<const string&>(param);
+
+ printData(derNull.getHeader(), indent);
+ printData(derNull.getPayload(), indent + " ");
+
+}
+
+void
+PrintVisitor::visit(DerOctetString& derOStr, ndnboost::any param)
+{
+ const string& indent = ndnboost::any_cast<const string&>(param);
+
+ printData(derOStr.getHeader(), indent);
+ printData(derOStr.getPayload(), indent + " ");
+}
+
+void
+PrintVisitor::visit(DerOid& derOid, ndnboost::any param)
+{
+ const string& indent = ndnboost::any_cast<const string&>(param);
+
+ printData(derOid.getHeader(), indent);
+ printData(derOid.getPayload(), indent + " ");
+
+}
+
+void
+PrintVisitor::visit(DerGtime& derGtime, ndnboost::any param)
+{
+ const string& indent = ndnboost::any_cast<const string&>(param);
+
+ printData(derGtime.getHeader(), indent);
+ printData(derGtime.getPayload(), indent + " ");
+}
+
+void
+PrintVisitor::visit(DerSequence& derSequence, ndnboost::any param)
+{
+ const string& indent = ndnboost::any_cast<const string&>(param);
+
+ printData(derSequence.getHeader(), indent);
+
+ const DerNodePtrList& children = derSequence.getChildren();
+ DerNodePtrList::const_iterator it = children.begin();
+ for(; it != children.end(); it++)
+ (*it)->accept(*this, indent + " | ");
+}
+
+
+void
+PrintVisitor::printData(const vector<uint8_t>& blob, const string& indent, int offset)
+{
+ cout << indent;
+
+ int count = 0;
+ for(int i = offset; i < blob.size(); i++)
+ {
+ cout << " " << hex << setw(2) << setfill('0') << (int)blob[i];
+ count++;
+ if(8 == count)
+ {
+ count = 0;
+ cout << "\n" << indent;
+ }
+ }
+ cout << endl;
+}
+
+} // der
+
+}
diff --git a/ndn-cpp/encoding/der/visitor/print-visitor.hpp b/ndn-cpp/encoding/der/visitor/print-visitor.hpp
new file mode 100644
index 0000000..45d0bfd
--- /dev/null
+++ b/ndn-cpp/encoding/der/visitor/print-visitor.hpp
@@ -0,0 +1,40 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Yingdi Yu <yingdi@cs.ucla.edu>
+ * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_PRINT_VISITOR_HPP
+#define NDN_PRINT_VISITOR_HPP
+
+#include <vector>
+#include <string>
+#include "void-visitor.hpp"
+
+namespace ndn {
+
+namespace der {
+
+class PrintVisitor : public VoidVisitor {
+public:
+ virtual void visit(DerBool&, ndnboost::any);
+ virtual void visit(DerInteger&, ndnboost::any);
+ virtual void visit(DerPrintableString&, ndnboost::any);
+ virtual void visit(DerBitString&, ndnboost::any);
+ virtual void visit(DerNull&, ndnboost::any);
+ virtual void visit(DerOctetString&, ndnboost::any);
+ virtual void visit(DerOid&, ndnboost::any);
+ virtual void visit(DerSequence&, ndnboost::any);
+ virtual void visit(DerGtime&, ndnboost::any);
+
+private:
+ static void printData(const std::vector<uint8_t>& blob, const std::string& indent, int offset = 0);
+};
+
+} // der
+
+}
+
+#endif
diff --git a/ndn-cpp/util/blob-stream.hpp b/ndn-cpp/util/blob-stream.hpp
index 21a039a..53d7e52 100644
--- a/ndn-cpp/util/blob-stream.hpp
+++ b/ndn-cpp/util/blob-stream.hpp
@@ -1,6 +1,7 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/**
* Copyright (C) 2013 Regents of the University of California.
+ * @author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* @author: Jeff Thompson <jefft0@remap.ucla.edu>
* See COPYING for copyright and distribution information.
*/