working on the model...

This commit is contained in:
Marcel Otte 2016-07-24 21:52:05 +02:00
parent 1304cb314c
commit 6337b7dfb5
3 changed files with 37 additions and 10 deletions

View File

@ -1,11 +1,34 @@
#include "packetelement.h" #include "packetelement.h"
#include <memory>
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<uint8_t> PacketElement::getBytes()
{
std::list<uint8_t> 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<uint8_t>();
} }

View File

@ -16,7 +16,7 @@ typedef
/** /**
@brief The ValueType enum @brief The ValueType enum
*/ */
enum class ValueType { hexBinary, integer, text, base64 }; enum class ValueType { hexBinary, integer, text };
class ElementSyntax class ElementSyntax
{ {
@ -74,13 +74,15 @@ public:
void addSyntax(std::string minimalRegex, std::string completeRegex, std::string example) void addSyntax(std::string minimalRegex, std::string completeRegex, std::string example)
{ {
ElementSyntax syntax; std::shared_ptr<ElementSyntax> syntax = std::make_shared<ElementSyntax>();
syntax.triggerRegex = minimalRegex; syntax->triggerRegex = minimalRegex;
syntax.completeRegex = completeRegex; syntax->completeRegex = completeRegex;
syntax.example = example; syntax->example = example;
syntaxes.push_back(syntax); syntaxes.push_back(syntax);
} }
std::list<uint8_t> getBytes();
private: private:
std::string name; std::string name;
uint32_t sizeInBit; uint32_t sizeInBit;
@ -92,7 +94,7 @@ private:
//additional data //additional data
std::string description; std::string description;
std::list<ElementSyntax> syntaxes; std::list<std::shared_ptr<ElementSyntax>> syntaxes;
}; };

View File

@ -13,6 +13,8 @@ public:
PacketModel(); PacketModel();
const std::shared_ptr<PacketElementList_t> getList(); const std::shared_ptr<PacketElementList_t> getList();
bool validate();
private: private:
std::shared_ptr<PacketElementList_t> elementList; std::shared_ptr<PacketElementList_t> elementList;
}; };