From: David ‘Bombe’ Roden Date: Sun, 6 Jul 2008 03:21:49 +0000 (+0200) Subject: add tags X-Git-Tag: 0.1~13 X-Git-Url: https://git.pterodactylus.net/?p=ecparse.git;a=commitdiff_plain;h=5d07c630077c673b5a7ffaa23fcfb11eefe2136f add tags --- diff --git a/StringTag.cpp b/StringTag.cpp new file mode 100644 index 0000000..d7482f0 --- /dev/null +++ b/StringTag.cpp @@ -0,0 +1,24 @@ +/** + * © 2008 by David Roden + */ + +#include "StringTag.h" + +#include +#include + +StringTag::StringTag(int id, const char* value): Tag(String, id) { + this->value = (char*) malloc(strlen(value) + 1); + strcpy(this->value, value); +} + +StringTag::~StringTag() { + if (value) { + free(value); + } +} + +void* StringTag::getValue() { + return value; +} + diff --git a/StringTag.h b/StringTag.h new file mode 100644 index 0000000..9464834 --- /dev/null +++ b/StringTag.h @@ -0,0 +1,21 @@ +/** + * © 2008 by David Roden + */ + +#pragma once + +#include "Tag.h" + +class StringTag: public Tag { + +public: + StringTag(int id, const char* value); + ~StringTag(); + + void* getValue(); + +private: + char* value; + +}; + diff --git a/Tag.cpp b/Tag.cpp new file mode 100644 index 0000000..28c6956 --- /dev/null +++ b/Tag.cpp @@ -0,0 +1,22 @@ +/** + * © 2008 by David Roden + */ + +#include "Tag.h" + +Tag::Tag(TagType type, int id) { + this->type = type; + this->id = id; +} + +Tag::~Tag() { +} + +TagType Tag::getType() { + return type; +} + +int Tag::getId() { + return id; +} + diff --git a/Tag.h b/Tag.h new file mode 100644 index 0000000..926c58a --- /dev/null +++ b/Tag.h @@ -0,0 +1,25 @@ +/** + * © 2008 by David Roden + */ + +#pragma once + +#include "TagType.h" + +class Tag { + +protected: + Tag(TagType type, int id); + virtual ~Tag(); + +public: + TagType getType(); + int getId(); + virtual void* getValue() = 0; + +private: + TagType type; + int id; + +}; + diff --git a/TagType.h b/TagType.h new file mode 100644 index 0000000..cdfd7ff --- /dev/null +++ b/TagType.h @@ -0,0 +1,10 @@ +/** + * © 2008 by David Roden + */ + +#pragma once + +enum TagType { + String, Blob, Hash, UInt32, UInt16, UInt8, UInt64 +}; +