Basic project structure, basic encoder implementation
This commit is contained in:
commit
4159fc4643
12 changed files with 897 additions and 0 deletions
39
Tests/Main.cpp
Normal file
39
Tests/Main.cpp
Normal 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("");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue