-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
feat: added serializers #2756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
feat: added serializers #2756
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0b19d86
feat: added serializers
SharonIV0x86 6e1f86d
fix: added assertions in test function.
SharonIV0x86 79539ae
fix: added test assertions.
SharonIV0x86 4df4977
fix: made requested changes.
SharonIV0x86 8b8f915
fix: replaced ssize_t with std::uint32_t
SharonIV0x86 afb2b7a
fix: made required changes.
SharonIV0x86 a436849
fix: added missing @brief
SharonIV0x86 447d463
docs: add documentation to main
realstealthninja 33573a9
fix: made required changes
SharonIV0x86 155df97
fix: added Serialization namespace
SharonIV0x86 4e4089c
fix: fixed namespace issues
SharonIV0x86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,248 @@ | ||||||||||||||||
/** | ||||||||||||||||
* @file serialization.cpp | ||||||||||||||||
* @brief Utility for binary serialization and deserialization of fundamental | ||||||||||||||||
* data types and strings. | ||||||||||||||||
* @details | ||||||||||||||||
* Binary serialization converts data into its binary format for | ||||||||||||||||
* efficient storage and transmission, which is more compact and faster than | ||||||||||||||||
* text-based formats. This utility handles fundamental types like integers, | ||||||||||||||||
* doubles, and characters by writing their binary representation directly to a | ||||||||||||||||
* file using `reinterpret_cast`. | ||||||||||||||||
* | ||||||||||||||||
* ### Serializing: | ||||||||||||||||
* - **Fundamental Types**: Written directly in their binary form. | ||||||||||||||||
* - **Strings**: The string's length is written first, followed by the string | ||||||||||||||||
* data, and a `|` delimiter to mark the end. String size should not exceed 1MB. | ||||||||||||||||
* | ||||||||||||||||
* ### Deserializing: | ||||||||||||||||
* - **Fundamental Types**: Reads the binary data back into the appropriate | ||||||||||||||||
* type. | ||||||||||||||||
* - **Strings**: Reads the string's length, followed by the string data, and | ||||||||||||||||
* checks for the `|` delimiter. An error is raised if the delimiter is missing. | ||||||||||||||||
* | ||||||||||||||||
* @author [SharonIV0X86](https://github.com/SharonIV0X86) | ||||||||||||||||
*/ | ||||||||||||||||
|
||||||||||||||||
#include <cassert> // for assert | ||||||||||||||||
#include <cstdint> // for std::uint32_t | ||||||||||||||||
#include <cstdio> // for std::remove() | ||||||||||||||||
#include <fstream> // for std::ifstream std::ofstream | ||||||||||||||||
#include <iostream> // for std::ios std::cout std::cerr | ||||||||||||||||
#include <string> // for std::string | ||||||||||||||||
#include <type_traits> // for std::is_fundamental | ||||||||||||||||
|
||||||||||||||||
/** \namespace ciphers | ||||||||||||||||
* \brief Classes for binary Serialization and Deserialization | ||||||||||||||||
*/ | ||||||||||||||||
|
/** \namespace ciphers | |
* \brief Classes for binary Serialization and Deserialization | |
*/ | |
/** | |
* @namespace serialization | |
* @brief Classes for binary Serialization and Deserialization | |
*/ |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
namespace Serialization { | |
namespace serialization { |
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
SharonIV0x86 marked this conversation as resolved.
Show resolved
Hide resolved
SharonIV0x86 marked this conversation as resolved.
Show resolved
Hide resolved
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
realstealthninja marked this conversation as resolved.
Show resolved
Hide resolved
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.