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)
{}