generated from Husenap/cmake-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for c-style array (#7)
* Added support for c-style array * updated header files to .hpp * updated clang-format
- Loading branch information
Showing
20 changed files
with
556 additions
and
509 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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,19 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
namespace dubu::serialize { | ||
|
||
class ReadBuffer { | ||
public: | ||
virtual ~ReadBuffer() = default; | ||
virtual void Read(char* data, uint32_t numBytes) = 0; | ||
}; | ||
|
||
class WriteBuffer { | ||
public: | ||
virtual ~WriteBuffer() = default; | ||
virtual void Write(const char* data, uint32_t numBytes) = 0; | ||
}; | ||
|
||
} // namespace dubu::serialize |
This file was deleted.
Oops, something went wrong.
This file contains 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,60 @@ | ||
#pragma once | ||
|
||
#include <filesystem> | ||
#include <fstream> | ||
|
||
#include "Buffer.hpp" | ||
|
||
namespace dubu::serialize { | ||
|
||
class FileBuffer : public ReadBuffer, public WriteBuffer { | ||
public: | ||
enum class Mode { Read, Write }; | ||
|
||
public: | ||
FileBuffer(std::filesystem::path filePath, Mode mode) | ||
: mMode(mode) { | ||
if (mMode == Mode::Read) { | ||
mStream.open(filePath, std::ios::in | std::ios::binary); | ||
} else { | ||
mStream.open(filePath, std::ios::out | std::ios::binary); | ||
} | ||
} | ||
~FileBuffer() { mStream.close(); } | ||
|
||
template <typename T> | ||
T Tell() { | ||
if (mMode == Mode::Read) { | ||
return static_cast<T>(mStream.tellg()); | ||
} else { | ||
return static_cast<T>(mStream.tellp()); | ||
} | ||
} | ||
|
||
template <typename T> | ||
void Seek(T position) { | ||
if (mMode == Mode::Read) { | ||
mStream.seekg(static_cast<std::streampos>(position)); | ||
} else { | ||
mStream.seekp(static_cast<std::streampos>(position)); | ||
} | ||
} | ||
|
||
void Read(char* data, uint32_t size) override { | ||
mStream.read(data, static_cast<std::streamsize>(size)); | ||
} | ||
void Write(const char* data, uint32_t size) override { | ||
mStream.write(data, static_cast<std::streamsize>(size)); | ||
} | ||
|
||
template <typename T> | ||
void Write(const std::basic_istream<T>& stream) { | ||
mStream << stream.rdbuf(); | ||
} | ||
|
||
private: | ||
std::fstream mStream; | ||
Mode mMode = Mode::Read; | ||
}; | ||
|
||
} // namespace dubu::serialize |
This file was deleted.
Oops, something went wrong.
This file contains 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,58 @@ | ||
#pragma once | ||
|
||
#include <sstream> | ||
|
||
#include "Buffer.hpp" | ||
|
||
namespace dubu::serialize { | ||
|
||
class MemoryBuffer : public ReadBuffer, public WriteBuffer { | ||
public: | ||
MemoryBuffer() {} | ||
|
||
/** | ||
* Get the position of the write pointer in the stream. | ||
* @return The position of the write pointer. | ||
*/ | ||
template <typename T> | ||
T TellP() { | ||
return static_cast<T>(mStream.tellp()); | ||
} | ||
/** | ||
* Get the position of the read pointer in the stream. | ||
* @return The position of the read pointer. | ||
*/ | ||
template <typename T> | ||
T TellG() { | ||
return static_cast<T>(mStream.tellg()); | ||
} | ||
|
||
/** | ||
* Set the position of the write pointer in the stream. | ||
* @param position The desired position for the write pointer. | ||
*/ | ||
template <typename T> | ||
void SeekP(T position) { | ||
mStream.seekp(static_cast<std::streampos>(position)); | ||
} | ||
/** | ||
* Set the position of the read pointer in the stream. | ||
* @param position The desired position for the read pointer. | ||
*/ | ||
template <typename T> | ||
void SeekG(T position) { | ||
mStream.seekg(static_cast<std::streampos>(position)); | ||
} | ||
|
||
void Read(char* data, uint32_t size) override { | ||
mStream.read(data, static_cast<std::streamsize>(size)); | ||
} | ||
void Write(const char* data, uint32_t size) override { | ||
mStream.write(data, static_cast<std::streamsize>(size)); | ||
} | ||
|
||
private: | ||
std::stringstream mStream; | ||
}; | ||
|
||
} // namespace dubu::serialize |
This file was deleted.
Oops, something went wrong.
This file contains 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,5 @@ | ||
#pragma once | ||
|
||
#include "dubu_serialize/buffer/FileBuffer.hpp" | ||
#include "dubu_serialize/buffer/MemoryBuffer.hpp" | ||
#include "dubu_serialize/serializer/Serializer.hpp" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.