add bitsery (#3834)

* add bitsery

* cstdint patch

* welp, sha should be there

* lets try every platform
pull/3835/head
SFGrenade 11 months ago committed by GitHub
parent 4cfe90ba17
commit 01fb375526
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      packages/b/bitsery/patches/5.2.3/cstdint-include.patch
  2. 50
      packages/b/bitsery/xmake.lua

@ -0,0 +1,12 @@
diff --git a/include/bitsery/details/adapter_common.h b/include/bitsery/details/adapter_common.h
index 7f665d4..166d188 100644
--- a/include/bitsery/details/adapter_common.h
+++ b/include/bitsery/details/adapter_common.h
@@ -28,6 +28,7 @@
#include <algorithm>
#include <cassert>
#include <climits>
+#include <cstdint>
namespace bitsery {

@ -0,0 +1,50 @@
package("bitsery")
set_kind("library", {headeronly = true})
set_homepage("https://github.com/fraillt/bitsery")
set_description("Header only C++ binary serialization library. It is designed around the networking requirements for real-time data delivery, especially for games.")
set_license("MIT")
add_urls("https://github.com/fraillt/bitsery/archive/refs/tags/$(version).tar.gz",
"https://github.com/fraillt/bitsery.git")
add_versions("v5.2.3", "896d82ab4ccea9899ff2098aa69ad6d25e524ee1d4c747ce3232d0afe3cd05a5")
add_patches("5.2.3", path.join(os.scriptdir(), "patches", "5.2.3", "cstdint-include.patch"), "bb9ea1f68b219249395f3f3f9404d6e5c150144d793b6707f51facd1ff751f2c")
on_install(function (package)
os.cp(path.join("include", "*"), package:installdir("include"))
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
enum class MyEnum:uint16_t { V1,V2,V3 };
struct MyStruct {
uint32_t i;
MyEnum e;
std::vector<float> fs;
};
template <typename S>
void serialize(S& s, MyStruct& o) {
s.value4b(o.i);
s.value2b(o.e);
s.container4b(o.fs, 10);
}
using Buffer = std::vector<uint8_t>;
using OutputAdapter = bitsery::OutputBufferAdapter<Buffer>;
using InputAdapter = bitsery::InputBufferAdapter<Buffer>;
void test() {
MyStruct data{8941, MyEnum::V2, {15.0f, -8.5f, 0.045f}};
MyStruct res{};
Buffer buffer;
auto writtenSize = bitsery::quickSerialization<OutputAdapter>(buffer, data);
auto state = bitsery::quickDeserialization<InputAdapter>({buffer.begin(), writtenSize}, res);
assert(state.first == bitsery::ReaderError::NoError && state.second);
assert(data.fs == res.fs && data.i == res.i && data.e == res.e);
}
]]}, {configs = {languages = "c++11"}, includes = {"bitsery/bitsery.h", "bitsery/adapter/buffer.h", "bitsery/traits/vector.h"}}))
end)
Loading…
Cancel
Save