DER encoding: Define InputIterator and OutputIterator in der.hpp and use as in the original.
diff --git a/ndn-cpp/encoding/der/der.cpp b/ndn-cpp/encoding/der/der.cpp
index 0b5531e..419ffae 100644
--- a/ndn-cpp/encoding/der/der.cpp
+++ b/ndn-cpp/encoding/der/der.cpp
@@ -34,7 +34,7 @@
    parent_(0)
 {}
 
-DerNode::DerNode(std::istream& start)
+DerNode::DerNode(InputIterator& start)
   :parent_(0)
 {
   decode(start);
@@ -74,14 +74,14 @@
 }
 
 int
-DerNode::decodeHeader(istream& start)
+DerNode::decodeHeader(InputIterator& start)
 {
-  uint8_t type = start.get();
+  uint8_t type = start.ReadU8();
   // char type = start.get();
   header_.push_back(type);
   type_ = static_cast<DerType>((int)type);
 
-  uint8_t sizeLen = start.get(); 
+  uint8_t sizeLen = start.ReadU8(); 
   // char sizeLen = start.get();
   header_.push_back(sizeLen);
 
@@ -102,7 +102,7 @@
     // _LOG_DEBUG("lenCount: " << (int)lenCount);
     int size = 0;
     do {
-      byte = start.get();
+      byte = start.ReadU8();
       header_.push_back(byte);
       size = size * 256 + (int)byte;
       // _LOG_DEBUG("byte: " << (int)byte);
@@ -115,14 +115,14 @@
 }
 
 void
-DerNode::encode(ostream& start)
+DerNode::encode(OutputIterator& start)
 {
   start.write((const char*)&header_[0], header_.size());
   start.write((const char*)&payload_[0], payload_.size());
 }
 
 void 
-DerNode::decode(istream& start)
+DerNode::decode(InputIterator& start)
 {
   int payloadSize = decodeHeader(start);
   // _LOG_DEBUG("payloadSize: " << payloadSize);
@@ -134,9 +134,9 @@
 }
 
 shared_ptr<DerNode>
-DerNode::parse(istream& start)
+DerNode::parse(InputIterator& start)
 {
-  int type = ((uint8_t)start.peek());
+  int type = ((uint8_t)start.PeekU8());
 
   // _LOG_DEBUG("Type: " << hex << setw(2) << setfill('0') << type);
   switch(type) {
@@ -179,7 +179,7 @@
    size_(0)
 {}
 
-DerComplex::DerComplex(istream& start)
+DerComplex::DerComplex(InputIterator& start)
   :DerNode(),
    childChanged_(false),
    size_(0)
@@ -272,7 +272,7 @@
 }
 
 void
-DerComplex::encode(ostream& start)
+DerComplex::encode(OutputIterator& start)
 {
   updateSize();
   header_.clear();
@@ -306,7 +306,7 @@
   DerNode::encodeHeader(payload_.size());
 }
 
-DerByteString::DerByteString(istream& start)
+DerByteString::DerByteString(InputIterator& start)
   :DerNode(start)
 {}
 
@@ -327,7 +327,7 @@
   DerNode::encodeHeader(payload_.size());
 }
 
-DerBool::DerBool(istream& start)
+DerBool::DerBool(InputIterator& start)
   :DerNode(start)
 {}
 
@@ -346,7 +346,7 @@
   DerNode::encodeHeader(payload_.size());
 }
 
-DerInteger::DerInteger(istream& start)
+DerInteger::DerInteger(InputIterator& start)
   :DerNode(start)
 {}
 
@@ -366,7 +366,7 @@
   DerNode::encodeHeader(payload_.size());
 }
 
-DerBitString::DerBitString(istream& start)
+DerBitString::DerBitString(InputIterator& start)
   :DerNode(start)
 {}
 
@@ -385,7 +385,7 @@
   :DerByteString(blob, DER_OCTET_STRING)
 {}
 
-DerOctetString::DerOctetString(istream& start)
+DerOctetString::DerOctetString(InputIterator& start)
   :DerByteString(start)
 {}
 
@@ -402,7 +402,7 @@
   DerNode::encodeHeader(0);
 }
 
-DerNull::DerNull(istream& start)
+DerNull::DerNull(InputIterator& start)
   :DerNode(start)
 {}
   
@@ -451,7 +451,7 @@
   prepareEncoding(value);
 }
 
-DerOid::DerOid(istream& start)
+DerOid::DerOid(InputIterator& start)
   :DerNode(start)
 {}
   
@@ -546,7 +546,7 @@
   :DerComplex(DER_SEQUENCE)
 {}
 
-DerSequence::DerSequence(istream& start)
+DerSequence::DerSequence(InputIterator& start)
   :DerComplex(start)
 {}
 
@@ -565,7 +565,7 @@
   :DerByteString(blob, DER_PRINTABLE_STRING)
 {}
 
-DerPrintableString::DerPrintableString(istream& start)
+DerPrintableString::DerPrintableString(InputIterator& start)
   :DerByteString(start)
 {}
 
@@ -587,7 +587,7 @@
   DerNode::encodeHeader(payload_.size());
 }
 
-DerGtime::DerGtime(istream& start)
+DerGtime::DerGtime(InputIterator& start)
   :DerNode(start)
 {}
   
diff --git a/ndn-cpp/encoding/der/der.hpp b/ndn-cpp/encoding/der/der.hpp
index ff92c78..a02a2e9 100644
--- a/ndn-cpp/encoding/der/der.hpp
+++ b/ndn-cpp/encoding/der/der.hpp
@@ -59,6 +59,23 @@
   DER_BMP_STRING = 30,
 };
 
+class InputIterator : public std::istream
+{
+public:
+  uint8_t ReadU8() { return static_cast<uint8_t> (get()); }
+  uint8_t PeekU8() { return static_cast<uint8_t> (peek()); }
+  bool IsEnd() const { return eof(); }
+  void Prev() { seekg(-1, std::ios_base::cur); }
+};
+
+class OutputIterator : public std::ostream
+{
+public:
+  void Write(const uint8_t * s, uint32_t n) { write (reinterpret_cast<const char*>(s),n); }
+  void WriteU8(const uint8_t s) { put (s); }
+  void WriteU8(const uint8_t s, uint32_t n) { for (uint32_t i = 0; i < n; i++) { put(s); } }
+};
+
 class DerComplex;
 
 class DerNode
@@ -68,7 +85,7 @@
 
   DerNode(DerType type);
 
-  DerNode(std::istream& start);
+  DerNode(InputIterator& start);
 
   virtual
   ~DerNode();
@@ -77,13 +94,13 @@
   getSize() { return header_.size() + payload_.size(); }
 
   virtual void 
-  encode(std::ostream& start);
+  encode(OutputIterator& start);
   
   void
   setParent(DerComplex * parent) { parent_ = parent; }
 
   static ptr_lib::shared_ptr<DerNode>
-  parse(std::istream& start);
+  parse(InputIterator& start);
 
   const std::vector<uint8_t>& 
   getHeader() const { return header_; }
@@ -117,13 +134,13 @@
   
 protected:
   void
-  decode(std::istream& start);
+  decode(InputIterator& start);
 
   void
   encodeHeader(int size);
 
   int 
-  decodeHeader(std::istream& start);
+  decodeHeader(InputIterator& start);
 
 protected:
   DerType type_;
@@ -142,7 +159,7 @@
   
   DerComplex(DerType type);
 
-  DerComplex(std::istream& start);
+  DerComplex(InputIterator& start);
 
   virtual 
   ~DerComplex();
@@ -154,7 +171,7 @@
   addChild(ptr_lib::shared_ptr<DerNode> nodePtr, bool notifyParent = true);
 
   virtual void
-  encode(std::ostream& start);
+  encode(OutputIterator& start);
 
   const DerNodePtrList& 
   getChildren() const { return nodeList_; }
@@ -187,7 +204,7 @@
 
   DerByteString(const std::vector<uint8_t>& blob, DerType type);
 
-  DerByteString(std::istream& start);
+  DerByteString(InputIterator& start);
 
   virtual
   ~DerByteString();
@@ -200,7 +217,7 @@
 public:
   DerBool(bool value);
 
-  DerBool(std::istream& start);
+  DerBool(InputIterator& start);
 
   virtual
   ~DerBool();
@@ -217,7 +234,7 @@
 public:
   DerInteger(const std::vector<uint8_t>& blob);
 
-  DerInteger(std::istream& start);
+  DerInteger(InputIterator& start);
 
   virtual 
   ~DerInteger();
@@ -234,7 +251,7 @@
 public:
   DerBitString(const std::vector<uint8_t>& blob, uint8_t paddingLen);
 
-  DerBitString(std::istream& start);
+  DerBitString(InputIterator& start);
   
   virtual
   ~DerBitString();
@@ -253,7 +270,7 @@
   
   DerOctetString(const std::vector<uint8_t>& blob);
 
-  DerOctetString(std::istream& start);
+  DerOctetString(InputIterator& start);
 
   virtual
   ~DerOctetString();
@@ -271,7 +288,7 @@
 public:
   DerNull();
 
-  DerNull(std::istream& start);
+  DerNull(InputIterator& start);
   
   virtual
   ~DerNull();
@@ -293,7 +310,7 @@
 
   DerOid(const std::vector<int>& value);
 
-  DerOid(std::istream& start);
+  DerOid(InputIterator& start);
   
   virtual
   ~DerOid();
@@ -321,7 +338,7 @@
 public:
   DerSequence();
 
-  DerSequence(std::istream& start);
+  DerSequence(InputIterator& start);
   
   virtual
   ~DerSequence();
@@ -340,7 +357,7 @@
 
   DerPrintableString(const std::vector<uint8_t>& blob);
 
-  DerPrintableString(std::istream& start);
+  DerPrintableString(InputIterator& start);
 
   virtual 
   ~DerPrintableString();
@@ -357,7 +374,7 @@
 public:
   DerGtime(const MillisecondsSince1970& time);
 
-  DerGtime(std::istream& start);
+  DerGtime(InputIterator& start);
   
   virtual 
   ~DerGtime();