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
- Host: GitHub
- URL: https://github.com/moritzrinow/cstream
- Owner: moritzrinow
- Created: 2018-09-13T10:08:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-22T20:45:08.000Z (over 7 years ago)
- Last Synced: 2025-05-07T13:34:58.494Z (9 months ago)
- Topics: byte-array, bytes, c, cpp, memory, serializable-objects, serialization, serialize, stream
- Language: C
- Size: 49.8 KB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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