add method to read hash tag
[ecparse.git] / CollectionReader.cpp
index ffbb89c..00427ff 100644 (file)
@@ -83,6 +83,21 @@ BlobTag* CollectionReader::readBlobTag(bool header) {
        return blobTag;
 }
 
+HashTag* CollectionReader::readHashTag() {
+       if (!ensureBufferCapacity(1)) {
+               return NULL;
+       }
+       uint8_t tagId = 0;
+       growingBuffer.read(&tagId, 1);
+       GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] read tag id %d.\n", __FILE__, __LINE__, tagId);
+       if (!ensureBufferCapacity(16)) {
+               return NULL;
+       }
+       char hash[16];
+       growingBuffer.read(hash, 16);
+       return new HashTag(tagId, hash);
+}
+
 ED2KLink* CollectionReader::getNextLink() {
        if (readerInput->isEOF() && !growingBuffer.getRemaining()) {
                GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] readInput EOF reached.\n", __FILE__, __LINE__);