Basic project structure, basic encoder implementation

This commit is contained in:
TennesseeTrash 2025-09-14 13:58:26 +02:00
commit 4159fc4643
12 changed files with 897 additions and 0 deletions

21
Tests/CMakeLists.txt Normal file
View file

@ -0,0 +1,21 @@
add_executable(Tests)
target_compile_features(Tests
PRIVATE
cxx_std_23
)
target_include_directories(Tests
PRIVATE
"Include"
)
target_link_libraries(Tests
PRIVATE
LibCBOR
)
target_sources(Tests
PRIVATE
"Main.cpp"
)

39
Tests/Main.cpp Normal file
View file

@ -0,0 +1,39 @@
#include "CBOR/Core.hpp"
#include "CBOR/Encoder.hpp"
#include <array>
#include <cstdint>
#include <print>
#include <vector>
int main()
{
using namespace std::string_view_literals;
std::array<std::uint8_t, 256> buffer = {0};
std::vector<std::uint8_t> binData(5, 'g');
CBOR::BasicEncoder enc(buffer);
enc.BeginMap(7);
enc.Encode("Hello ");
enc.Encode("World! ");
enc.Encode("Behold by new power! ");
enc.Encode("It truly is a sight to see ..."sv);
enc.Encode(std::int64_t(1212121212121212));
enc.Encode(binData);
enc.Encode("random double");
enc.Encode(420.69);
enc.Encode("random float");
enc.Encode(420.69f);
enc.Encode("undefined?");
enc.Encode(CBOR::Special::Undefined);
enc.Encode("null?");
enc.Encode(CBOR::Special::Null);
enc.End();
for (const auto &byte: buffer) {
std::print("{:02x} ", byte);
}
std::println("");
}