CLLIO (c++ low level io) wants to be a lightweight, ZERO warnings stream io and serialization abstraction layer.
What cllio does not have:
- no complex serialization code.
- direct memory allocations
- complex buffering logic
What it should have:
- 0 Warnings (W4) on "all" compilers
- minimal effort to integrate into project
- usable functions without the need to write boilerplate
- EXTREME error checking without performance sacrifice
- no template overkill, functions should be easy to read with a debugger.
Status:
std::FILE
read/write layer: Workingvoid*
memory read/write layer: Working
0 warnings (using premake5 warnings("Extra")):
Visual studio 2019
0 warningsdocker/ubuntu
0 warnings
memory_rstream
reads fromconst void*
memory_rstream_unchecked
reads fromconst void*
no end() checksmemory_wstream
writes tovoid*
memory_wstream_unchecked
writes tovoid*
no end() checksmemory_rfunc<F>
reads from a return value of a functorconst cllio::byte_t* F::operator(std::size_t)
memory_wfunc<F>
writes to functor result ofcllio::byte_t* F::operator(std::size_t)
stdfile_rstream_view
read fromstd::FILE*
, does not own the filestdfile_wstream_view
write tostd::FILE*
, does not own the filestdfile_rstream
read fromstd::FILE*
, owns file handlestdfile_wstream
write fromstd::FILE*
, owns file handle
size_info
calculates write sizecall_trace_info
debug utility, prints all calls to serialization primitivesfile_read_mapview
maps file toconst void*
, usedata()
andsize()
tcpsocket
for simple socket io
memory_vector_serializer<V>
typedef for writer to a std::vector like container (size()/resize()
)
Note: calling any read/write functions on a closed std_file_*
is UB;
Read/Write functions can handle following types:
uint8_t
uint16_t
uint32_t
uint64_t
int8_t
int16_t
int32_t
int64_t
float
double
Readers have functions that follow the following format:
T pop_T();
Try to read, runtime assert and UB on failure.bool pop_T(T & out);
Try to read, returns false on failure andout
is unchangedT pop_T(bool& error);
Try to read, returns T(0) on error and error = true.T popdefault_T(const T & default);
Try to read, returndefault
on failure.bool popdefault_T(T & out, const T & default);
Try to read,out = default
on failure and returns false.void pop_T(T & out, bool& error);
Try to read if 'error == false', on filiure 'error = true'void read_raw_buffer(void * dest, const std::size_t byte_count);
Try to read, UB on failiurebool tryread_raw_buffer(void * dest, const std::size_t byte_count);
If read is not possible function returns false, otherwise it populates 'dest' buffer
Where T
is one of 'Supported Types'.
Note: one some Undefined behaviors there is an assert
void push_T(const T & value)
will write; UB on failure.bool trypush_T(const T & value)
will return false if push failedvoid push_ptr(const void *)
will write; UB on failure.bool trypush_ptr(const void*)
will return false if push failedvoid write_raw_buffer(const void * data, const std::size_t byte_count);
Try to write, UB on failiurebool trywrite_raw_buffer(const void * data, const std::size_t byte_count);
Try to write, Returns false on failiure
Where T
is one of 'Supported Types'.