From af87acc86aa550429135b7c2ddd77e8589b24968 Mon Sep 17 00:00:00 2001 From: Marcel Otte Date: Fri, 10 Mar 2017 23:23:53 +0100 Subject: [PATCH] Working on #2. Built graph model, created header and cpp. --- doc/model.graphml | 50 ++++++----- src/core/CMakeLists.txt | 4 + src/core/RandomAccessBinary.cpp | 141 ++++++++++++++++++++++++++++++++ src/core/RandomAccessBinary.h | 67 +++++++++++++++ src/core/model/AStructure.h | 8 +- 5 files changed, 247 insertions(+), 23 deletions(-) create mode 100644 src/core/RandomAccessBinary.cpp create mode 100644 src/core/RandomAccessBinary.h diff --git a/doc/model.graphml b/doc/model.graphml index 098900e..dcf6e12 100644 --- a/doc/model.graphml +++ b/doc/model.graphml @@ -243,10 +243,10 @@ - + - RandomAccessBinary + RandomAccessBinary @@ -255,7 +255,32 @@ - binaryData - + + setBytes(uint position, std::vector<uint8_t> data) ++ setByte(uint position, uint8_t data) + ++ setBit(uint64_t position, bool value) ++ setBit(uint bytePosition, uint bitPosition, bool value) ++ setBits(uint64_t position, uint bits, uint value) ++ setBits(uint bytePosition, uint bitPosition, uint bits, uint value) + ++ getByte(uint position) ++ getBytes(uint position, uint bytes) + ++ getBit(uint64_t position) ++ getBit(uint bytePosition, uint bitPosition) ++ getBits(uint64_t position, uint bits) ++ getBits(uint bytePosition, uint bitPosition, uint bits) + ++ get_uint32(uint position) ++ get_uint16(uint position) ++ get_uint64(uint position) ++ get_float(uint position) ++ get_double(uint position) + ++ get_string(uint position, uint length) + ++ get_hex_string(uint position, uint length) ++ get_hex_string() @@ -328,7 +353,6 @@ - @@ -371,7 +395,6 @@ - @@ -393,7 +416,6 @@ - @@ -415,7 +437,6 @@ - @@ -437,7 +458,6 @@ - @@ -459,7 +479,6 @@ - @@ -481,7 +500,6 @@ - @@ -613,7 +631,6 @@ - @@ -625,7 +642,6 @@ - @@ -637,7 +653,6 @@ - @@ -649,7 +664,6 @@ - @@ -661,7 +675,6 @@ - @@ -673,7 +686,6 @@ - @@ -685,7 +697,6 @@ - @@ -697,7 +708,6 @@ - @@ -709,7 +719,6 @@ - @@ -721,7 +730,6 @@ - @@ -733,7 +741,6 @@ - @@ -745,7 +752,6 @@ - diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b94dca1..dd6217d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -19,6 +19,8 @@ set(HEADERS schemaio/AStructureWriterFactory.h schemaio/AStructureReader.h schemaio/AStructureWriter.h + + RandomAccessBinary.h ) set(SOURCES @@ -39,6 +41,8 @@ set(SOURCES schemaio/AStructureWriterFactory.cpp schemaio/AStructureReader.cpp schemaio/AStructureWriter.cpp + + RandomAccessBinary.cpp ) add_library(core ${HEADERS} ${SOURCES}) diff --git a/src/core/RandomAccessBinary.cpp b/src/core/RandomAccessBinary.cpp new file mode 100644 index 0000000..31970aa --- /dev/null +++ b/src/core/RandomAccessBinary.cpp @@ -0,0 +1,141 @@ +#include "RandomAccessBinary.h" + +RandomAccessBinary::RandomAccessBinary() +{ + +} + +RandomAccessBinary::~RandomAccessBinary() +{ + +} + +void RandomAccessBinary::setEndianess(RandomAccessBinary::Endianness endianess) +{ + +} + +void RandomAccessBinary::setBytes(uint position, const std::vector &data) +{ + +} + +void RandomAccessBinary::setByte(uint position, const uint8_t &data) +{ + +} + +void RandomAccessBinary::setBit(uint64_t position, const bool &value) +{ + +} + +void RandomAccessBinary::setBit(uint bytePosition, uint bitPosition, const bool &value) +{ + +} + +void RandomAccessBinary::setBits(uint64_t position, uint bits, const uint &value) +{ + +} + +void RandomAccessBinary::setBits(uint bytePosition, uint bitPosition, const uint &value) +{ + +} + +void RandomAccessBinary::set_uint16(uint position, uint16_t data) +{ + +} + +void RandomAccessBinary::set_uint32(uint position, uint32_t data) +{ + +} + +void RandomAccessBinary::set_uint64(uint position, uint64_t data) +{ + +} + +void RandomAccessBinary::set_float(uint position, float data) +{ + +} + +void RandomAccessBinary::set_double(uint position, double data) +{ + +} + +const uint8_t RandomAccessBinary::getByte(uint position) +{ + +} + +const std::vector RandomAccessBinary::getBytes(uint position, uint length) +{ + +} + +const bool RandomAccessBinary::getBit(uint byteOffset, uint bitOffset) +{ + +} + +const bool RandomAccessBinary::getBit(uint64_t position) +{ + +} + +const std::vector RandomAccessBinary::getBits(uint byteOffset, uint8_t bitOffset, uint64_t length) +{ + +} + +const std::vector RandomAccessBinary::getBits(uint64_t position, uint64_t length) +{ + +} + +const uint16_t RandomAccessBinary::get_uint16(uint position) +{ + +} + +const uint32_t RandomAccessBinary::get_uint32(uint position) +{ + +} + +const uint64_t RandomAccessBinary::get_uint64(uint position) +{ + +} + +const float RandomAccessBinary::get_float(uint position) +{ + +} + +const double RandomAccessBinary::get_double(uint position) +{ + +} + +std::__cxx11::string RandomAccessBinary::get_string(uint position, uint length) +{ + +} + +std::__cxx11::string RandomAccessBinary::get_hex_string(uint position, uint length) +{ + +} + +std::__cxx11::string RandomAccessBinary::get_hex_string() +{ + +} diff --git a/src/core/RandomAccessBinary.h b/src/core/RandomAccessBinary.h new file mode 100644 index 0000000..e3bc3d5 --- /dev/null +++ b/src/core/RandomAccessBinary.h @@ -0,0 +1,67 @@ +#ifndef RANDOMACCESSBINARY_H +#define RANDOMACCESSBINARY_H + +#include +#include +#include + +class RandomAccessBinary +{ + enum class Endianness{ + BIG, + LITTLE, + MIDDLE + }; + +public: + RandomAccessBinary(); + explicit ~RandomAccessBinary(); + + void setEndianness(Endianness endianess); + const Endianness getEndianness(); + + void setBytes(uint position, const std::vector& data); + void setByte(uint position, const uint8_t& data); + + void setBit(uint64_t position, const bool& value); + void setBit(uint bytePosition, uint bitPosition, const bool& value); + void setBits(uint64_t position, uint bits, const uint& value); + void setBits(uint bytePosition, uint bitPosition, const uint& value); + + void set_uint16(uint position, const uint16_t& data); + void set_uint32(uint position, const uint32_t& data); + void set_uint64(uint position, const uint64_t& data); + + void set_float(uint position, const float& data); + void set_double(uint position, const double& data); + + const uint8_t + getByte(uint position); + + const std::vector + getBytes(uint position, uint length); + + const bool getBit(uint byteOffset, uint bitOffset); + const bool getBit(uint64_t position); + const std::vector + getBits(uint byteOffset, uint8_t bitOffset, uint64_t length); + + const std::vector + getBits(uint64_t position, uint64_t length); + + const uint16_t get_uint16(uint position); + const uint32_t get_uint32(uint position); + const uint64_t get_uint64(uint position); + + const float get_float(uint position); + const double get_double(uint position); + + std::string get_string(uint position, uint length); + + std::string get_hex_string(uint position, uint length); + std::string get_hex_string(); +private: + std::unique_ptr> ptr_data; +}; + +#endif // RANDOMACCESSBINARY_H diff --git a/src/core/model/AStructure.h b/src/core/model/AStructure.h index 598f74d..7b7179a 100644 --- a/src/core/model/AStructure.h +++ b/src/core/model/AStructure.h @@ -1,11 +1,17 @@ #ifndef ASTRUCTURE_H #define ASTRUCTURE_H +#include +#include +#include "AField.h" class AStructure { public: AStructure(); + +private: + std::list> fields; }; -#endif // ASTRUCTURE_H \ No newline at end of file +#endif // ASTRUCTURE_H