diff --git a/src/model/packetelement.cpp b/src/model/packetelement.cpp index 2772ef3..e9578a9 100644 --- a/src/model/packetelement.cpp +++ b/src/model/packetelement.cpp @@ -1,11 +1,34 @@ #include "packetelement.h" +#include -PacketElement::PacketElement(std::__cxx11::string name, uint32_t sizeInBit, uint16_t layer): name(name), sizeInBit(sizeInBit), layer(layer) +PacketElement::PacketElement(std::string name, uint32_t sizeInBit, uint16_t layer): name(name), sizeInBit(sizeInBit), layer(layer) { - } -void PacketElement::setValue(std::__cxx11::string &value, ValueType type) +void PacketElement::setValue(std::string &value, ValueType type) { - + this->value = std::string(value); + this->valueType = type; +} + +std::list PacketElement::getBytes() +{ + std::list result; + switch(this->valueType) { + case ValueType::text: + for(uint8_t c : this->value) + result.push_back(c); + break; + case ValueType::integer: + break; + case ValueType::hexBinary: + + break; + default: + //wtf? + break; + } + + + return std::list(); } diff --git a/src/model/packetelement.h b/src/model/packetelement.h index b34edea..4d97328 100644 --- a/src/model/packetelement.h +++ b/src/model/packetelement.h @@ -16,7 +16,7 @@ typedef /** @brief The ValueType enum */ -enum class ValueType { hexBinary, integer, text, base64 }; +enum class ValueType { hexBinary, integer, text }; class ElementSyntax { @@ -74,13 +74,15 @@ public: void addSyntax(std::string minimalRegex, std::string completeRegex, std::string example) { - ElementSyntax syntax; - syntax.triggerRegex = minimalRegex; - syntax.completeRegex = completeRegex; - syntax.example = example; + std::shared_ptr syntax = std::make_shared(); + syntax->triggerRegex = minimalRegex; + syntax->completeRegex = completeRegex; + syntax->example = example; syntaxes.push_back(syntax); } + std::list getBytes(); + private: std::string name; uint32_t sizeInBit; @@ -92,7 +94,7 @@ private: //additional data std::string description; - std::list syntaxes; + std::list> syntaxes; }; diff --git a/src/model/packetmodel.h b/src/model/packetmodel.h index d90c197..ca26067 100644 --- a/src/model/packetmodel.h +++ b/src/model/packetmodel.h @@ -13,6 +13,8 @@ public: PacketModel(); const std::shared_ptr getList(); + bool validate(); + private: std::shared_ptr elementList; };