Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/claudiuhbann/streamable_old
Fast and easy-to-use single-header parser with a simple format for C++20 and NO dependencies.
https://github.com/claudiuhbann/streamable_old
cpp20 easy-to-use fast format no-dependencies parser simple single-header
Last synced: about 1 month ago
JSON representation
Fast and easy-to-use single-header parser with a simple format for C++20 and NO dependencies.
- Host: GitHub
- URL: https://github.com/claudiuhbann/streamable_old
- Owner: ClaudiuHBann
- License: mit
- Created: 2023-08-20T16:44:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-30T21:05:56.000Z (over 1 year ago)
- Last Synced: 2024-09-07T21:22:40.895Z (4 months ago)
- Topics: cpp20, easy-to-use, fast, format, no-dependencies, parser, simple, single-header
- Language: C++
- Homepage:
- Size: 109 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Streamable
This library is all about speedy data parsing, churning out super small byte streams.
## Table of Contents
- [Installation](#installation)
- [Features](#features)
- [Usage](#usage)
- [Examples](#examples)
- [Documentation](#documentation)
- [TODO](#todo)## Installation
To use this library, simply get and include the header file `Streamable.hpp` into your project.
## Features
- **fast** - the parsing represents just a simple iteration, knows where every object is and how big it is, for example it reserves the memory for ranges that allow it before adding elements etc...
- **easy-to-use** - inherit a class and implement it's methods with just a macro
- **single-header** - just copy paste the file in your project
- **simple format** - contains just the data itself and for the types that have a dynamic size a metadata representing just a uint32_t
- **has no dependencies** - uses just the standard library
- **accepts multiple data types** - beside **itself** ofc, **primitive types** (ex.: bool, unsigned int, double etc...), **strings** (ex.: std::string. std::wstring etc...), **any type with standard layout** (ex.: POD structs and classes, enums, etc...), **nested ranges** (ex.: vector, list, vector<list> etc...), and bonus types like *std::filesystem::path* etc... ( doesn't support pointers... yet :) )## Usage
1. Inherit from the `IStreamable` class or any class that implements it.
2. Use one of the macros **ISTREAMABLE_DEFINE_X**OR
1. Inherit from the `IStreamable` class or any class that implements it.
2. Implement the `Constructor(stream)` used for deserializing, simply by using the macro ISTREAMABLE_DESERIALIZE_X(object1, object2, ...)
3. Implement the `ToStream()` method used for serializing, simply by using the macro ISTREAMABLE_SERIALIZE_X(object1, object2, ...)
4. Implement the `GetObjectsSize` used for calculating the exact size required to store the objects, simply by using the macro ISTREAMABLE_GET_OBJECTS_SIZE_X(object1, object2, ...)## Examples
- [Simple Class](https://github.com/ClaudiuHBann/Streamable/blob/main/Example%20Simple%20Class.cpp) - how to use **Streamable** for a simple class
- [Derived Class](https://github.com/ClaudiuHBann/Streamable/blob/main/Example%20Derived%20Class.cpp) - how to use **Streamable** for a base class and a derived class
- [Derived Classes](https://github.com/ClaudiuHBann/Streamable/blob/main/Example%20Derived%20Class%2B.cpp) - how to use **Streamable** for a base class, multiple intermediate classes and the final class## Documentation
There are 3 types of macros:
- **ISTREAMABLE_GET_OBJECTS_SIZE_X** - finds the exact size required to store the objects
- **ISTREAMABLE_SERIALIZE_X** - serializes the objects
- **ISTREAMABLE_DESERIALIZE_X** - deserializes the objectsThose 3 macros have 4 types each that will be used depending on the situation:
- **ISTREAMABLE_X**(...) - used by simple classes
- **ISTREAMABLE_X_DERIVED_START**(...) - used by the base classes
- **ISTREAMABLE_X_DERIVED**(...) - used by the intermediate classes
- **ISTREAMABLE_X_DERIVED_END**(...) - used by the final classesBut we are going to use the following macros to define everything in just one line:
- **ISTREAMABLE_DEFINE**(className, ...) - used by simple classes
- **ISTREAMABLE_DEFINE_DERIVED_START**(className, ...) - used by the base classes
- **ISTREAMABLE_DEFINE_DERIVED**(className, baseClass, ...) - used by the intermediate classes
- **ISTREAMABLE_DEFINE_DERIVED_END**(className, baseClass, ...) - used by the final classes## TODO
Features:
- make it work with tuplesEnchantments:
- remove the single copy from the project from ReadStreamable
- split the class IStreamable into IStreamWriter, IStreamReader, IStreamBase...Bugs:
- give me some... :)