An open API service indexing awesome lists of open source software.

https://github.com/moritzrinow/cstream

C byte-stream and serialization utils
https://github.com/moritzrinow/cstream

byte-array bytes c cpp memory serializable-objects serialization serialize stream

Last synced: 6 months ago
JSON representation

C byte-stream and serialization utils

Awesome Lists containing this project

README

          

# cStream

C byte-stream and serialization utils

## Content

* Build
* Usage

## Build

Clone the repository with git...

### Linux
Open the terminal in the repo directory and type:

"make" to install cStream

"make clean" to uninstall cStream

### Windows
I have not added a way to build binaries for Windows yet...
Just add the source files to your VS Solution/Project.

## Using streams

#### The structure
STREAM stream;

#### Initialize
stream_init(&stream , 0) // (stream, capacity)

_init(&stream, 0) // Macro

#### Reserve memory
stream_reserve(&stream, 1024) // (stream, size)

_reserve(&stream, 1024) // Macro

#### Write (overwrite)
stream_write(&stream, some_byte_buffer, length, 0) // (stream, buffer, length, offset)

_write(&stream, some_byte_buffer, length, 0) // Macro

#### Write (insert)
stream_insert(&stream, some_byte_buffer, length, 0) // (stream, buffer, length, offset)

_insert(&stream, some_byte_buffer, length, 0) // Macro

#### Read
stream_read(&stream, some_byte_buffer, length, 0) // (stream, buffer, length, offset)

_read(&stream, some_byte_buffer, length, 0) // Macro

#### Seek (change position)
stream_seek(&stream, 0) // (stream, position)

_seek(&stream, 0) // Macro

#### Clear (reset)
stream_clear(&stream) // (stream)

_clear(&stream) // Macro

#### Copy
stream_copy(&stream, &some_other_stream) // (source_stream, dest_stream)

_copy(&stream, &some_other_stream) // Macro

#### Close (cleanup resources)
stream_close(&stream) // (stream)

_close // Macro

##### The macros are available if you define _STREAM_MACROS before including cStream.h