add blob tag
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Jul 2008 09:30:36 +0000 (11:30 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Jul 2008 09:30:36 +0000 (11:30 +0200)
BlobTag.cpp [new file with mode: 0644]
BlobTag.h [new file with mode: 0644]

diff --git a/BlobTag.cpp b/BlobTag.cpp
new file mode 100644 (file)
index 0000000..0bf4bda
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * © 2008 by David Roden <droden@gmail.com>
+ */
+
+#include "BlobTag.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+BlobTag::BlobTag(int id, void* value, int length): Tag(Blob, id) {
+       this->length = length;
+       this->value = malloc(length);
+       memcpy(this->value, value, length);
+}
+
+BlobTag::~BlobTag() {
+       if (value) {
+               free(value);
+       }
+}
+
+int BlobTag::getSize() {
+       return length;
+}
+
+void* BlobTag::getValue() {
+       return value;
+}
+
diff --git a/BlobTag.h b/BlobTag.h
new file mode 100644 (file)
index 0000000..5a9963b
--- /dev/null
+++ b/BlobTag.h
@@ -0,0 +1,23 @@
+/**
+ * © 2008 by David Roden <droden@gmail.com>
+ */
+
+#pragma once
+
+#include "Tag.h"
+
+class BlobTag: public Tag {
+
+public:
+       BlobTag(int id, void* value, int length);
+       ~BlobTag();
+
+       int getSize();
+       void* getValue();
+
+private:
+       int length;
+       void* value;
+
+};
+