From: David ‘Bombe’ Roden Date: Sun, 6 Jul 2008 10:59:19 +0000 (+0200) Subject: add method to read hash tag X-Git-Tag: 0.1~3 X-Git-Url: https://git.pterodactylus.net/?p=ecparse.git;a=commitdiff_plain;h=e4f9c67cc94df1e370846b19ddedd4365df7b638 add method to read hash tag --- diff --git a/CollectionReader.cpp b/CollectionReader.cpp index ffbb89c..00427ff 100644 --- a/CollectionReader.cpp +++ b/CollectionReader.cpp @@ -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__); diff --git a/CollectionReader.h b/CollectionReader.h index 770c2a8..023b226 100644 --- a/CollectionReader.h +++ b/CollectionReader.h @@ -10,6 +10,7 @@ #include "GrowingBuffer.h" #include "StringTag.h" #include "BlobTag.h" +#include "HashTag.h" class CollectionReader { @@ -25,8 +26,9 @@ private: bool ensureBufferCapacity(size_t byteCount); void readMoreBytes(); - BlobTag* readBlobTag(bool hader); - StringTag* readStringTag(bool header); + BlobTag* readBlobTag(bool header = false); + StringTag* readStringTag(bool header = false); + HashTag* readHashTag(); private: ReaderInput* readerInput;