8#ifndef SEN_LIBS_DB_SRC_UTIL_H
9#define SEN_LIBS_DB_SRC_UTIL_H
19#include <spdlog/logger.h>
32template <
typename T,
typename B>
36inline void write(T&& data, FILE* file);
43void uncompressBuffer(
const std::vector<uint8_t>& lz4Buf, std::vector<uint8_t>& memBuf, std::size_t decompressedSize);
45[[nodiscard]] FILE*
openFile(
const std::filesystem::path& path);
48[[nodiscard]] const ::sen::ClassType*
searchOwner(const ::sen::ClassType* classType,
49 const ::sen::Property* property)
noexcept;
52[[nodiscard]] const ::sen::ClassType*
searchOwner(const ::sen::ClassType* classType,
53 const ::sen::Event* event)
noexcept;
57 const ::sen::Property* property);
74inline void write(T&& data, FILE* file)
76 auto block = std::make_shared<ResizableHeapBlock>();
80 doWrite(block->getConstSpan(), file);
83template <
typename T,
typename B>
96 auto buffer = std::make_shared<ResizableHeapBlock>();
void writeUInt32(uint32_t val)
Definition output_stream.h:44
A writer that owns a buffer that gets resized on demand.
Definition buffer_writer.h:59
Contiguous view of elements of type T. Inspired by http://www.open-std.org/jtc1/sc22/wg21/docs/papers...
Definition span.h:34
Definition type_traits.h:47
Definition type_specs.h:19
void doWrite(const Span< const uint8_t > &span, FILE *file)
const ::sen::ClassType * searchOwner(const ::sen::ClassType *classType, const ::sen::Property *property) noexcept
Returns the class in the hierarchy of classes that owns the property. Returns nullptr if not found.
void uncompressBuffer(const std::vector< uint8_t > &lz4Buf, std::vector< uint8_t > &memBuf, std::size_t decompressedSize)
uint32_t getFileHeaderSize()
Definition db/src/util.h:68
FILE * openFile(const std::filesystem::path &path)
MemberHash computePlatformDependentEventId(const ::sen::ClassType *classType, const ::sen::Event *event)
Computes the old version (platform-dependent) of the event id. Used for retro-compatibility.
void writeToBuffer(const T &data, B &buffer)
Definition db/src/util.h:84
void write(T &&data, FILE *file)
Definition db/src/util.h:74
std::shared_ptr< ResizableHeapBlock > writeSizeAndDataToBuffer(const T &data)
Definition db/src/util.h:93
std::shared_ptr< spdlog::logger > getLogger()
void writeToCompressedBuffer(const std::vector< uint8_t > &memBuf, kernel::Buffer &lz4Buf)
MemberHash computePlatformDependentPropertyId(const ::sen::ClassType *classType, const ::sen::Property *property)
Computes the old version (platform-dependent) of the property id. Used for retro-compatibility.
OutputStreamTemplate< LittleEndian > OutputStream
Definition output_stream.h:64
The hash of a member.
Definition type.h:39