Skip to content

Commit 9963d06

Browse files
committed
First commit, everything fine except allocator stuff that needs to be sorted out.
Variant and tuple to be tested. eastl::string and std::wstring from gtest don't bode well.
1 parent 1d37c63 commit 9963d06

File tree

107 files changed

+2663
-1783
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+2663
-1783
lines changed

CHANGELOG.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# [5.2.4](https://github.com/fraillt/bitsery/compare/v5.2.3...v5.2.4) (2024-07-30)
22

33
### Improvements
4-
* implement brief syntax for std::optional and std::bitset. #116 (thanks to [Destroyerrrocket](https://github.com/Destroyerrrocket))
4+
* implement brief syntax for eastl::optional and eastl::bitset. #116 (thanks to [Destroyerrrocket](https://github.com/Destroyerrrocket))
55
* improve performance for buffer adapters. #118 (thanks to [Destroyerrrocket](https://github.com/Destroyerrrocket))
66
* check if should swap by taking into account actual type (in addition to configuration). #105 (thanks to [SoftdriveFelix](https://github.com/SoftdriveFelix))
77
* fix compile errors for latest compilers. #106 (thanks to [NBurley93](https://github.com/NBurley93))
@@ -27,8 +27,8 @@
2727

2828
### Improvements
2929
* add 16 byte value support #75 (thanks to [Victor Stewart](https://github.com/victorstewart))
30-
* avoid reinitializing nontrivial std::variant #77 (thanks to [Robbert van der Helm](https://github.com/robbert-vdh))
31-
* avoid reinitializing nontrivial std::optional.
30+
* avoid reinitializing nontrivial eastl::variant #77 (thanks to [Robbert van der Helm](https://github.com/robbert-vdh))
31+
* avoid reinitializing nontrivial eastl::optional.
3232

3333
### Bug fixes
3434
* fix missing headers for GCC11, also added test to check includes #82 (thanks to [michael-mueller-git](https://github.com/michael-mueller-git))
@@ -116,7 +116,7 @@ If you can trust your data this will improve deserialization performance. Error
116116

117117
* improved design for serializer/deserializer *context*. It was hard to understand and easy to misuse, so several changes were made.
118118
* removed *internal* context from config, because it doesn't actually solve any problems, only allows doing the same thing in multiple ways.
119-
* removed `T* context()`. This allowed to get a context that is `std::tuple<...>`, but you can do the same with other methods, by wrapping in an outer tuple, e.g. `std::tuple<std::tuple<...>>`.
119+
* removed `T* context()`. This allowed to get a context that is `eastl::tuple<...>`, but you can do the same with other methods, by wrapping in an outer tuple, e.g. `eastl::tuple<eastl::tuple<...>>`.
120120
* if a context is defined, in serializer/deserializer, it is passed (and stored) by reference as a first argument (instead of pointer). Other parameters are forwarded to a input/output adapter.
121121
* changed signature `T* context<T>` to `T& context<T>`, this will either return context or doesn't compile, previously it could also return nullptr.
122122
* `context<T>` and `contextOrNull<T>` now also check if a type is convertible, so it can work with base classes
@@ -129,7 +129,7 @@ This allows much easier serialization customization, because no additional state
129129
* removed various functions/classes that became redundant:
130130
* *AdapterWriter/Reader* classes - their functionality is moved to *adapters*.
131131
* *AdapterAccess* class - now serializer/deserializer expose adapter directly via `adapter()` method.
132-
Additionally adapter can be moved out if serializer/deserializer is rvalue .e.g `auto adapter = std::move(ser).adapter();`.
132+
Additionally adapter can be moved out if serializer/deserializer is rvalue .e.g `auto adapter = eastl::move(ser).adapter();`.
133133
* removed *Writer/Reader* parameters from extensions *serialize/deserialize* methods - because serializer/deserializer now expose *adapter* directly.
134134
* *archive* from serializer/deserializer - because `operator()` do the same thing, but it is more terse, and is compatible with `cereal` library.
135135
* *align* function from serializer/deserializer - it can now be called directly on input/output adapter.
@@ -167,12 +167,12 @@ e.g. instead of writing `s.container(obj, [](S& s, MyData& data) {s.ext(data, My
167167
# [4.6.0](https://github.com/fraillt/bitsery/compare/v4.5.1...v4.6.0) (2019-03-12)
168168

169169
### Features
170-
* new extensions **StdTuple** and **StdVariant** for `std::tuple` and `std::variant`. These are the first extensions that requires C++17, or higher, standard enabled.
171-
Although `std::tuple` is C++11 type, but from usage perspective it has exactly the same requirements as `std::variant` and relies heavily on having class template argument deduction guides to make it convenient to use.
172-
You can easily use `std::tuple` without any extension at all, so the main motivation was to create convenient interface for **StdVariant** and use the same interface for **StdTuple** as well.
170+
* new extensions **StdTuple** and **StdVariant** for `eastl::tuple` and `eastl::variant`. These are the first extensions that requires C++17, or higher, standard enabled.
171+
Although `eastl::tuple` is C++11 type, but from usage perspective it has exactly the same requirements as `eastl::variant` and relies heavily on having class template argument deduction guides to make it convenient to use.
172+
You can easily use `eastl::tuple` without any extension at all, so the main motivation was to create convenient interface for **StdVariant** and use the same interface for **StdTuple** as well.
173173
* instead of providing custom lambda to overload each type in tuple or variant, there was added several helper callable objects.
174174
**OverloadValue** wrapper around `s.value<N>(o)`, **OverloadExtValue** wrapper around `s.ext<N>(o, Ext{})` and **OverloadExtObject** wrapper around `s.ext(o, Ext{})`.
175-
* new extensions **StdDuration** and **StdTimePoint** for `std::chrono::duration` and `std::chrono::time_point`.
175+
* new extensions **StdDuration** and **StdTimePoint** for `eastl::chrono::duration` and `eastl::chrono::time_point`.
176176

177177
### Improvements
178178
tests now uses `gtest_discover_tests` function, to automatically discover tests, which requires CMake 3.10.
@@ -192,7 +192,7 @@ tests now uses `gtest_discover_tests` function, to automatically discover tests,
192192
It is not necessary to enforce class invariant immediately, because internal object representation will be overriden anyway.
193193

194194
### Improvements
195-
* `StdSmartPtr` supports `std::unique_ptr` with custom deleter.
195+
* `StdSmartPtr` supports `eastl::unique_ptr` with custom deleter.
196196
* `*InputBufferAdapter`(all) can also accept const buffer;
197197

198198
### Bug fixes
@@ -246,21 +246,21 @@ struct MyHierarchy<Shape>: bitsery::ext::bitsery::ext::PolymorphicClassesList<My
246246
* added runtime polymorphism support for pointer like types (raw and smart pointers).
247247
In order to enable polymorphism new **PolymorphicContext** was created. It provides capability to register classes with serializer/deserializer.
248248
* runtime polymorphism can be customized, by replacing **StandardRTTI** from <bitsery/ext/utils/rtti_utils.h> header.
249-
* added smart pointers support for std::unique_ptr, std::shared_ptr and std::weak_ptr via **StdSmartPtr** extension.
249+
* added smart pointers support for eastl::unique_ptr, eastl::shared_ptr and eastl::weak_ptr via **StdSmartPtr** extension.
250250
* new **UnsafeInputBufferAdapter** doesn't check for buffer size on deserialization, on some compilers can improve deserialization performance up to ~40%.
251251
252252
### Improvements
253253
* creatly improved interface for extending/implementing support for pointer like types. Now all pointer like types extends from **PointerObjectExtensionBase** and implements/configures required details.
254254
* reimplemented **PointerOwner**, **PointerObserver**, **ReferencedByPointer**.
255-
* reimplemented **PointerLinkingContext** to properly support shared objects and runtime polymorphism, pointer ownership for shared objects now has two states: SharedOwner e.g. std::shared_ptr and SharedObserver std::weak_ptr.
255+
* reimplemented **PointerLinkingContext** to properly support shared objects and runtime polymorphism, pointer ownership for shared objects now has two states: SharedOwner e.g. eastl::shared_ptr and SharedObserver eastl::weak_ptr.
256256
257257
### Other notes
258258
There is one *minor?* issue/limitation for pointer like types that uses virtual inheritance. When several pointers points to same object through different static type. it will not work correctly e.g.:
259259
```cpp
260260
struct Derived: virtual Base {...};
261261
struct MyData {
262-
std::shared_ptr<Derived> sptr;
263-
std::weak_ptr<Base> wptddr;
262+
eastl::shared_ptr<Derived> sptr;
263+
eastl::weak_ptr<Base> wptddr;
264264
}
265265
```
266266
In this example wptr and sptr have different static type, and *Derived* is virtually inherited from *Base*, so I get different pointer address for different types.
@@ -310,19 +310,19 @@ In order to correctly manage pointer ownership, three extensions was created in
310310
To validate and update pointers **PointerLinkingContext** have to be passed to serialization/deserialization.
311311
It ensures that all pointers are valid, that same pointer doesn't have multiple owners, and non-owning pointers doesn't point outside of scope (i.e. non owning pointers points to data that is serialized/deserialized), see [raw_pointers example](examples/raw_pointers.cpp) for usage example.
312312

313-
*Currently polimorphism and std::shared_ptr, std::unique_ptr is not supported.*
313+
*Currently polimorphism and eastl::shared_ptr, eastl::unique_ptr is not supported.*
314314

315315
* added **context\<T\>()** overload to *BasicSerializer/BasicDeserializer* and now they became typesafe.
316-
For better extensions support, added posibility to have multiple types in context with *std::tuple*.
317-
E.g. when using multiple extensions, that requires specific contexts, together with your custom context, you can define your context as *std::tuple\<PointerLinkingContext, MyContext\>* and in serialization function you can correctly get your data via *context\<MyContext\>()*.
316+
For better extensions support, added posibility to have multiple types in context with *eastl::tuple*.
317+
E.g. when using multiple extensions, that requires specific contexts, together with your custom context, you can define your context as *eastl::tuple\<PointerLinkingContext, MyContext\>* and in serialization function you can correctly get your data via *context\<MyContext\>()*.
318318

319319

320320
### Improvements
321321

322322
* new **OutputBufferedStreamAdapter** use internal buffer instead of directly writing to stream, can get more than 2x performance increase.
323323
* can use any contiguous container as internal buffer.
324-
* when using fixed-size, stack allocated container (*std::array*), buffer size via constructor is ignored.
325-
* default internal buffer is *std::array<char,256>*.
324+
* when using fixed-size, stack allocated container (*eastl::array*), buffer size via constructor is ignored.
325+
* default internal buffer is *eastl::array<char,256>*.
326326
* added *static_assert* when trying to use *BufferAdapter* with non contiguous container.
327327

328328

@@ -400,7 +400,7 @@ Be careful when using deserializing untrusted data and make sure to enforce fund
400400
* **ext** to **extend** and changed its interface, to make it more easy to extend.
401401
* alias functions that write bytes directly no has *b* (meaning bytes) at the end of the name eg. *value4* now is *value4b*.
402402
* changed BufferWriter/Reader behaviour:
403-
* added support for fixed size buffers for better serializer performance (more than 50% improvement). Default config is resizable buffer (*std::vector<uint8_t>*).
403+
* added support for fixed size buffers for better serializer performance (more than 50% improvement). Default config is resizable buffer (*eastl::vector<uint8_t>*).
404404
* after serialization, call *getWrittenRange* to get valid range written to buffer, because BufferWritter for resizable buffer now always resize to *capacity* to avoid using *back_insert_iterator* for better performance.
405405
* BufferReader has constructor with iterators (range), and raw value type pointers (begin, end).
406406
* renamed BufferReader **isCompleted** to **isCompletedSuccessfully**, that returns true only when there is no errors and buffer is fully read.
@@ -423,7 +423,7 @@ Be careful when using deserializing untrusted data and make sure to enforce fund
423423

424424
* endianness support, default network configuration is *little endian*
425425
* added user extensible function **ext**, to work with objects that require different serialization/deserialization path (e.g. pointers)
426-
* **optional** extension (for *ext* function), to work with *std::optional* types
426+
* **optional** extension (for *ext* function), to work with *eastl::optional* types
427427

428428
### Breaking changes
429429

@@ -449,7 +449,7 @@ Serialization functions:
449449
* **value** - [fundamental types](doc/design/fundamental_types.md)
450450
* **container** - dynamic size containers
451451
* **array** - fixed size containers
452-
* **text** - for c-array and std::string
452+
* **text** - for c-array and eastl::string
453453
* **range** - compresion for fundamental types (e.g. int between [255..512] will take up 8bits
454454
* **substitution** - default value from list (e.g. 4d vector, that is most of the time equals to [0,0,0,1] can store only 1bit)
455455
* **boolBit**/**boolByte** - serialize bool, as 1bit or 1byte.

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
cmake_minimum_required(VERSION 3.25)
1+
cmake_minimum_required(VERSION 3.22)
2+
3+
set(VCPKG_LIBRARY_LINKAGE static)
4+
set(VCPKG_MAX_CONCURRENCY 12)
5+
6+
if (WIN32)
7+
set(VCPKG_TARGET_TRIPLET x64-windows)
8+
include("$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
9+
elseif (UNIX)
10+
set(VCPKG_TARGET_TRIPLET x64-linux)
11+
include("/home/$ENV{USER}/GameDev/Libraries/vcpkg/scripts/buildsystems/vcpkg.cmake")
12+
endif()
13+
214
project(bitsery
315
LANGUAGES CXX
416
VERSION 5.2.4)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ enum class MyEnum:uint16_t { V1,V2,V3 };
5656
struct MyStruct {
5757
uint32_t i;
5858
MyEnum e;
59-
std::vector<float> fs;
59+
eastl::vector<float> fs;
6060
};
6161

6262
template <typename S>
@@ -66,7 +66,7 @@ void serialize(S& s, MyStruct& o) {
6666
s.container4b(o.fs, 10);
6767
}
6868

69-
using Buffer = std::vector<uint8_t>;
69+
using Buffer = eastl::vector<uint8_t>;
7070
using OutputAdapter = bitsery::OutputBufferAdapter<Buffer>;
7171
using InputAdapter = bitsery::InputBufferAdapter<Buffer>;
7272

@@ -96,7 +96,7 @@ This documentation comprises these parts:
9696
9797
Works with C++11 compiler, no additional dependencies, include `<bitsery/bitsery.h>` and you're done.
9898
99-
> some **bitsery** extensions might require higher C++ standard (e.g. `StdVariant`)
99+
> some **bitsery** extensions might require higher C++ standard (e.g. `EastlVariant`)
100100
101101
## Platforms
102102

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
#SOFTWARE.
2222

23-
cmake_minimum_required(VERSION 3.25)
23+
cmake_minimum_required(VERSION 3.22)
2424
project(bitsery_examples CXX)
2525

2626
if (NOT TARGET Bitsery::bitsery)

examples/basic_usage.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@
88
// a buffer.
99
#include <bitsery/traits/vector.h>
1010

11+
void* __cdecl operator new[](size_t size, const char* name, int flags, unsigned debugFlags, const char* file, int line)
12+
{
13+
(void)name;
14+
(void)flags;
15+
(void)debugFlags;
16+
(void)file;
17+
(void)line;
18+
return new uint8_t[size];
19+
}
20+
21+
void* __cdecl operator new[](size_t size, size_t alignement, size_t offset, const char* name, int flags, unsigned debugFlags, const char* file, int line)
22+
{
23+
(void)name;
24+
(void)alignement;
25+
(void)offset;
26+
(void)flags;
27+
(void)debugFlags;
28+
(void)file;
29+
(void)line;
30+
return new uint8_t[size];
31+
}
32+
1133
enum class MyEnum : uint16_t
1234
{
1335
V1,
@@ -18,7 +40,7 @@ struct MyStruct
1840
{
1941
uint32_t i;
2042
MyEnum e;
21-
std::vector<float> fs;
43+
eastl::vector<float> fs;
2244
};
2345

2446
// define how object should be serialized/deserialized
@@ -33,7 +55,7 @@ serialize(S& s, MyStruct& o)
3355
}
3456

3557
// some helper types
36-
using Buffer = std::vector<uint8_t>;
58+
using Buffer = eastl::vector<uint8_t>;
3759
using OutputAdapter = bitsery::OutputBufferAdapter<Buffer>;
3860
using InputAdapter = bitsery::InputBufferAdapter<Buffer>;
3961

examples/bit_packing.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
#include <bitsery/adapter/buffer.h>
22
#include <bitsery/bitsery.h>
3-
// we'll be using std::array as a buffer type, so include traits for this
3+
// we'll be using eastl::array as a buffer type, so include traits for this
44
#include <bitsery/traits/array.h>
55
#include <bitsery/traits/string.h>
66
#include <bitsery/traits/vector.h>
77
// include extension that will allow to compress our data
88
#include <bitsery/ext/value_range.h>
99

10+
void* __cdecl operator new[](size_t size, const char* name, int flags, unsigned debugFlags, const char* file, int line)
11+
{
12+
(void)name;
13+
(void)flags;
14+
(void)debugFlags;
15+
(void)file;
16+
(void)line;
17+
return new uint8_t[size];
18+
}
19+
20+
void* __cdecl operator new[](size_t size, size_t alignement, size_t offset, const char* name, int flags, unsigned debugFlags, const char* file, int line)
21+
{
22+
(void)name;
23+
(void)alignement;
24+
(void)offset;
25+
(void)flags;
26+
(void)debugFlags;
27+
(void)file;
28+
(void)line;
29+
return new uint8_t[size];
30+
}
31+
1032
namespace MyTypes {
1133

1234
struct Vec3
@@ -17,8 +39,8 @@ struct Vec3
1739
struct Monster
1840
{
1941
Vec3 pos;
20-
std::vector<Vec3> path;
21-
std::string name;
42+
eastl::vector<Vec3> path;
43+
eastl::string name;
2244
};
2345

2446
template<typename S>
@@ -51,7 +73,7 @@ serialize(S& s, Monster& o)
5173
}
5274

5375
// use fixed-size buffer
54-
using Buffer = std::array<uint8_t, 10000>;
76+
using Buffer = eastl::array<uint8_t, 10000>;
5577
using OutputAdapter = bitsery::OutputBufferAdapter<Buffer>;
5678
using InputAdapter = bitsery::InputBufferAdapter<Buffer>;
5779

examples/brief_syntax.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@
99
// get static assert error, saying to define serialize function.
1010
#include <bitsery/brief_syntax/vector.h>
1111

12+
void* __cdecl operator new[](size_t size, const char* name, int flags, unsigned debugFlags, const char* file, int line)
13+
{
14+
(void)name;
15+
(void)flags;
16+
(void)debugFlags;
17+
(void)file;
18+
(void)line;
19+
return new uint8_t[size];
20+
}
21+
22+
void* __cdecl operator new[](size_t size, size_t alignement, size_t offset, const char* name, int flags, unsigned debugFlags, const char* file, int line)
23+
{
24+
(void)name;
25+
(void)alignement;
26+
(void)offset;
27+
(void)flags;
28+
(void)debugFlags;
29+
(void)file;
30+
(void)line;
31+
return new uint8_t[size];
32+
}
33+
1234
enum class MyEnum : uint16_t
1335
{
1436
V1,
@@ -19,7 +41,7 @@ struct MyStruct
1941
{
2042
uint32_t i;
2143
MyEnum e;
22-
std::vector<float> fs;
44+
eastl::vector<float> fs;
2345

2446
// define serialize function as usual
2547
template<typename S>
@@ -31,7 +53,7 @@ struct MyStruct
3153
};
3254

3355
// some helper types
34-
using Buffer = std::vector<uint8_t>;
56+
using Buffer = eastl::vector<uint8_t>;
3557
using OutputAdapter = bitsery::OutputBufferAdapter<Buffer>;
3658
using InputAdapter = bitsery::InputBufferAdapter<Buffer>;
3759

@@ -46,8 +68,7 @@ main()
4668
Buffer buffer;
4769
auto writtenSize = bitsery::quickSerialization<OutputAdapter>(buffer, data);
4870

49-
auto state = bitsery::quickDeserialization<InputAdapter>(
50-
{ buffer.begin(), writtenSize }, res);
71+
auto state = bitsery::quickDeserialization<InputAdapter>({ buffer.begin(), writtenSize }, res);
5172

5273
assert(state.first == bitsery::ReaderError::NoError && state.second);
5374
assert(data.fs == res.fs && data.i == res.i && data.e == res.e);

examples/composite_types.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
struct MyStruct
1414
{
15-
std::vector<int32_t> v{};
15+
eastl::vector<int32_t> v{};
1616
float f{};
1717

1818
bool operator==(const MyStruct& rhs) const
@@ -30,8 +30,8 @@ serialize(S& s, MyStruct& o)
3030
}
3131

3232
// this will be the type that we want to serialize/deserialize
33-
using MyTuple = std::tuple<float, MyStruct>;
34-
using MyVariant = std::variant<int64_t, MyTuple, MyStruct>;
33+
using MyTuple = eastl::tuple<float, MyStruct>;
34+
using MyVariant = eastl::variant<int64_t, MyTuple, MyStruct>;
3535

3636
// define default serialize function for MyVariant, so that we could use
3737
// quickSerialization/Deserialization functions
@@ -91,7 +91,7 @@ serialize(S& s, MyVariant& o)
9191
}
9292

9393
// some helper types
94-
using Buffer = std::vector<uint8_t>;
94+
using Buffer = eastl::vector<uint8_t>;
9595
using OutputAdapter = bitsery::OutputBufferAdapter<Buffer>;
9696
using InputAdapter = bitsery::InputBufferAdapter<Buffer>;
9797

@@ -130,6 +130,6 @@ main()
130130
int
131131
main()
132132
{
133-
return 0;
133+
return -1;
134134
}
135135
#endif

0 commit comments

Comments
 (0)