Liking cljdoc? Tell your friends :D

helins.binf

Uninhibited library for handling any kind binary format or protocol.

See README for an overview.

Uninhibited library for handling any kind binary format or protocol.

See README for an overview.
raw docstring

-charset-utf-8clj

source

-growclj

(-grow this)
source

base64-decodeclj/s

(base64-decode string)

Decodes a string into a buffer according to the Base64 basic scheme (RFC 4648 section 4)

Decodes a string into a [[buffer]] according to the Base64 basic scheme (RFC 4648 section 4)
sourceraw docstring

base64-encodeclj/s

(base64-encode buffer)
(base64-encode buffer offset)
(base64-encode buffer offset n-bytes)

Encodes a buffer into a string according to the Base64 basic scheme (RFC 4648 section 4)

Encodes a [[buffer]] into a string according to the Base64 basic scheme (RFC 4648 section 4)
sourceraw docstring

bits-f32clj/s

(bits-f32 f32)

Converts a 32-bit float to an integer preserving the bit pattern.

Opposite of f32.

Converts a 32-bit float to an integer preserving the bit pattern.

Opposite of [[f32]].
sourceraw docstring

bits-f64clj/s

(bits-f64 f64)

Converts a 64-bit float to an integer preserving the bit pattern.

Opposite of f32.

Converts a 64-bit float to an integer preserving the bit pattern.

Opposite of [[f32]].
sourceraw docstring

bufferclj/s

(buffer n-bytes)

Allocates a new buffer having n-bytes bytes.

In Clojurescript, corresponds to a JS ArrayBuffer.

In Clojure on the JVM, corresponds to a plain byte array.

In order to do anything interesting with this library, it needs to be wrapped in a [[view]].

Allocates a new buffer having `n-bytes` bytes.

In Clojurescript, corresponds to a JS `ArrayBuffer`.

In Clojure on the JVM, corresponds to a plain byte array.

In order to do anything interesting with this library, it needs to be wrapped in a [[view]].
sourceraw docstring

buffer*clj/smacro

(buffer* & b8s)

Macro for instanting a new buffer populated by the given bytes.

For allocating a zeroed one, see buffer.

Macro for instanting a new buffer populated by the given bytes.

For allocating a zeroed one, see [[buffer]].
sourceraw docstring

copy-bufferclj/s

(copy-buffer src-buffer)
(copy-buffer dest-buffer src-buffer)
(copy-buffer dest-buffer dest-offset src-buffer)
(copy-buffer dest-buffer dest-offset src-buffer src-offset)
(copy-buffer dest-buffer dest-offset src-buffer src-offset n-bytes)

Copies a buffer to another buffer.

Copies a buffer to another buffer.
sourceraw docstring

f32clj/s

(f32 bits)
(f32 b8-1 b8-2 b8-3 b8-4)

Interprets bits from an integer (at least 32 bits) as a 32-bit float.

Opposite of bits-f32.

Interprets bits from an integer (at least 32 bits) as a 32-bit float.

Opposite of [[bits-f32]].
sourceraw docstring

f64clj/s

(f64 bits)
(f64 b8-1 b8-2 b8-3 b8-4 b8-5 b8-6 b8-7 b8-8)

Interprets bits from a 64-bits integer as a 64-bit float.

Opposite of [[bits-64]].

Interprets bits from a 64-bits integer as a 64-bit float.

Opposite of [[bits-64]].
sourceraw docstring

growing-viewclj/s

(growing-view buffer)
(growing-view buffer next-size)

Creates a growing view, starting with the given buffer.

A growing view will reallocate a bigger buffer everytime it reaches the end of the current one, but ONLY WHEN WRITING.

This is a simple strategy for when the size is unknown in advance, but it has proven to be rather optimal and ultimately efficient for the most common use cases. Even more so if the size can be roughly estimated.

The size of the bigger buffer is decided by calling next-size which is a function old-size -> new-size. Thus the user can be in full control of the process. When not provided, size is always multiplied by 1.5.

Creates a growing view, starting with the given buffer.

A growing view will reallocate a bigger buffer everytime it reaches the end of the current one, but ONLY WHEN WRITING.

This is a simple strategy for when the size is unknown in advance, but it has proven to be rather optimal
and ultimately efficient for the most common use cases. Even more so if the size can be roughly estimated.

The size of the bigger buffer is decided by calling `next-size` which is a function `old-size` -> `new-size`.
Thus the user can be in full control of the process. When not provided, size is always multiplied by 1.5.
sourceraw docstring

growing?clj/s

(growing? x)

Returns true if x is a growing view instead of a fixed one.

See growing-view.

Returns true if `x` is a growing view instead of a fixed one.

See [[growing-view]].
sourceraw docstring

GrowingViewcljs

source

i16clj/s

(i16 bits)
(i16 b8-1 b8-2)

Casts the given bits (any integer) into a 16-bit signed integer.

Or recombines the given bytes in big endian order.

Casts the given `bits` (any integer) into a 16-bit signed integer.

Or recombines the given bytes in big endian order.
sourceraw docstring

i32clj/s

(i32 bits)
(i32 b8-1 b8-2 b8-3 b8-4)

Casts the given bits (any integer) into a 32-bit signed integer.

Or recombines the given bytes in big endian order.

Casts the given `bits` (any integer) into a 32-bit signed integer.

Or recombines the given bytes in big endian order.
sourceraw docstring

i64clj/s

(i64 b8-1 b8-2 b8-3 b8-4 b8-5 b8-6 b8-7 b8-8)

Recombines the given byets in big endian order to form a 64-bit signed integer.

Recombines the given byets in big endian order to form a 64-bit signed integer.
sourceraw docstring

i8clj/s

(i8 u8)

Casts the given bits (any integer) into a 8-bit signed integer.

Casts the given `bits` (any integer) into a 8-bit signed integer.
sourceraw docstring

IAbsoluteReaderclj/sprotocol

Reading primitive values at an absolute position, without disturbing the current one.

Reading primitive values at an absolute position, without disturbing the current one.

ra-u8clj/s

(ra-u8 view position)

Reads an unsigned 8-bit interger from an absolute position.

Reads an unsigned 8-bit interger from an absolute `position`.

ra-i32clj/s

(ra-i32 view position)

Reads a signed 32-bit integer from an absolute position.

Reads a signed 32-bit integer from an absolute `position`.

ra-f64clj/s

(ra-f64 view position)

Reads a 64-bit float at from absolute position.

Reads a 64-bit float at from absolute `position`.

ra-stringclj/s

(ra-string view position n-bytes)
(ra-string view decoder position n-bytes)

Reads a string consisting of n-bytes bytes from an absolute position.

A decoder may be provided (default is UTF-8).

Cf. text-decoder

Reads a string consisting of `n-bytes` bytes from an absolute `position`.

A decoder may be provided (default is UTF-8).

Cf. [[text-decoder]]

ra-f32clj/s

(ra-f32 view position)

Reads a 32-bit float at from absolute position.

Reads a 32-bit float at from absolute `position`.

ra-u16clj/s

(ra-u16 view position)

Reads an unsigned 16-bit integer from an absolute position.

Reads an unsigned 16-bit integer from an absolute `position`.

ra-i8clj/s

(ra-i8 view position)

Reads a signed 8-bit integer from an absolute position.

Reads a signed 8-bit integer from an absolute `position`.

ra-i64clj/s

(ra-i64 view position)

Reads a signed 64-bit integer from an absolute position.

Reads a signed 64-bit integer from an absolute `position`.

ra-bufferclj/s

(ra-buffer view position n-bytes)
(ra-buffer view position n-bytes buffer)
(ra-buffer view position n-bytes buffer offset)

Reads n-bytes from an absolute position and returns them in a new buffer or in the given one at the specified offset (or 0).

Reads n-bytes from an absolute `position` and returns them in a new buffer or in the
given one at the specified `offset` (or 0).

ra-u32clj/s

(ra-u32 view position)

Reads an unsigned 32-bit integer from an absolute position.

Reads an unsigned 32-bit integer from an absolute `position`.

ra-i16clj/s

(ra-i16 view position)

Reads a signed 16-bit integer from an absolute position.

Reads a signed 16-bit integer from an absolute `position`.
sourceraw docstring

IAbsoluteWriterclj/sprotocol

Writing primitive values at an absolute position, without disturbing the current one.

When writing integers, sign is irrelevant and truncation is automatic.

Writing primitive values at an absolute position, without disturbing the current one.

When writing integers, sign is irrelevant and truncation is automatic.

wa-b16clj/s

(wa-b16 view position integer)

Writes a 16-bit integer to an absolute position.

Writes a 16-bit integer to an absolute `position`.

wa-b32clj/s

(wa-b32 view position integer)

Writes a 32-bit integer to an absolute position.

Writes a 32-bit integer to an absolute `position`.

wa-b64clj/s

(wa-b64 view position integer)

Writes a 64-bit integer to an absolute position.

Writes a 64-bit integer to an absolute `position`.

wa-b8clj/s

(wa-b8 view position integer)

Writes an 8-bit integer to an absolute position.

Writes an 8-bit integer to an absolute position.

wa-bufferclj/s

(wa-buffer view position buffer)
(wa-buffer view position buffer offset)
(wa-buffer view position buffer offset n-bytes)

Copies the given buffer to an absolute position.

An offset in the buffer as well as a number of bytes to copy (n-bytes) may be provided.

Copies the given `buffer` to an absolute `position`.

An `offset` in the buffer as well as a number of bytes to copy (`n-bytes`) may be provided.

wa-f32clj/s

(wa-f32 view position floating)

Writes a 32-bit float to an absolute position.

Writes a 32-bit float to an absolute `position`.

wa-f64clj/s

(wa-f64 view position floating)

Writes a 64-bit float to an absolute position.

Writes a 64-bit float to an absolute `position`.

wa-stringclj/s

(wa-string view position string)

Writes a string (encoded as UTF-8) to an absolute position.

Unlike other functions which are implemented as a fluent interface, this function returns a tuple indicating how many bytes and chars have been written, and if the process is finished: [finished? n-bytes n-chars].

With that information, the user can continue writing if needed. On the JVM, the tuple contains a 4th item which is a CharBuffer containing the rest of the unwritten string which can be passed in place of the string argument.

Growing views will automatically grow and only one call will be sufficient.

Writes a string (encoded as UTF-8) to an absolute `position`.

Unlike other functions which are implemented as a fluent interface, this function returns
a tuple indicating how many bytes and chars have been written, and if the process is finished:
`[finished? n-bytes n-chars]`.

With that information, the user can continue writing if needed. On the JVM, the tuple contains a 4th
item which is a `CharBuffer` containing the rest of the unwritten string which can be passed in place
of the `string` argument.

Growing views will automatically grow and only one call will be sufficient.
sourceraw docstring

IEndianessclj/sprotocol

Retrieving or modifying the endianess.

Retrieving or modifying the endianess.

endianessclj/s

(endianess view)
(endianess view new-endianess)

Arity 1 returns the current endianess, arity 2 sets it.

Accepted values are :little-endian and :big-endian.

Arity 1 returns the current endianess, arity 2 sets it.

Accepted values are `:little-endian` and `:big-endian`.
sourceraw docstring

IGrowingclj/sprotocol

Only applicable to growing views which are capable of growing size dynamically.

See growing-view.

Only applicable to `growing views` which are capable of growing size dynamically.

See [[growing-view]].

garanteeclj/s

(garantee growing-view n-bytes)

Garantees that at least n-bytes bytes can be written.

The growing view will automatically grow its size if needed.

This function is rather a lower-level one, the common user will probably never use it directly.

Garantees that at least `n-bytes` bytes can be written.

The growing view will automatically grow its size if needed.

This function is rather a lower-level one, the common user will probably never use it directly.
sourceraw docstring

integerclj/s

(integer floating)

Truncates a float value to 64-bit unsigned integer (eg. 42.0 to 42).

Truncates a float value to 64-bit unsigned integer (eg. `42.0` to `42`).
sourceraw docstring

IRelativeReaderclj/sprotocol

Reading primitive values from the current position, advancing it as needed. For instance, reading a 32-bit integer will advance the current position by 4 bytes.

Reading primitive values from the current position, advancing it as needed. For instance,
reading a 32-bit integer will advance the current position by 4 bytes.

rr-i8clj/s

(rr-i8 view)

Reads a signed 8-bit integer from the current position.

Reads a signed 8-bit integer from the current position.

rr-i32clj/s

(rr-i32 view)

Reads a signed 32-bit integer from the current position.

Reads a signed 32-bit integer from the current position.

rr-i64clj/s

(rr-i64 view)

Reads a signed 64-bit integer from the current position.

Reads a signed 64-bit integer from the current position.

rr-bufferclj/s

(rr-buffer view n-bytes)
(rr-buffer view n-bytes buffer)
(rr-buffer view n-bytes buffer offset)

Reads n-bytes and returns them in a new buffer or in the given one at the specified offset (or 0).

Reads n-bytes and returns them in a new buffer or in the given one at the specified `offset` (or 0).

rr-u8clj/s

(rr-u8 view)

Reads an unsigned 8-bit integer from the current position.

Reads an unsigned 8-bit integer from the current position.

rr-u16clj/s

(rr-u16 view)

Reads an unsigned 16-bit integer from the current position.

Reads an unsigned 16-bit integer from the current position.

rr-f32clj/s

(rr-f32 view)

Reads a 32-bit float from the current position.

Reads a 32-bit float from the current position.

rr-f64clj/s

(rr-f64 view)

Reads a 64-bit float from the current position.

Reads a 64-bit float from the current position.

rr-stringclj/s

(rr-string view n-bytes)
(rr-string view decoder n-bytes)

Reads a string consisting of n-bytes from the current position.

A decoder may be provided (default is UTF-8).

See text-decoder

Reads a string consisting of `n-bytes` from the current position.

A decoder may be provided (default is UTF-8).

See [[text-decoder]]

rr-i16clj/s

(rr-i16 view)

Reads a signed 16-bit integer from the current position.

Reads a signed 16-bit integer from the current position.

rr-u32clj/s

(rr-u32 view)

Reads an unsigned 32-bit integer from the current position.

Reads an unsigned 32-bit integer from the current position.
sourceraw docstring

IRelativeWriterclj/sprotocol

Writing primitive values to the current position, advancing it as needed. For instance, reading a 64-bit float will advance the current position by 8 bytes.

When writing integers, sign is irrelevant and truncation is automatic.

Writing primitive values to the current position, advancing it as needed. For instance,
reading a 64-bit float will advance the current position by 8 bytes.

When writing integers, sign is irrelevant and truncation is automatic.

wr-b16clj/s

(wr-b16 view integer)

Writes a 16-bit integer to the current position.

Writes a 16-bit integer to the current position.

wr-b32clj/s

(wr-b32 view integer)

Writes a 32-bit integer to the current position.

Writes a 32-bit integer to the current position.

wr-b64clj/s

(wr-b64 view integer)

Writes a 64-bit integer to the current position.

Writes a 64-bit integer to the current position.

wr-b8clj/s

(wr-b8 view integer)

Writes an 8-bit integer to the current position.

Writes an 8-bit integer to the current position.

wr-bufferclj/s

(wr-buffer view buffer)
(wr-buffer view buffer offset)
(wr-buffer view buffer offset n-bytes)

Copies the given buffer to the current position.

An offset in the buffer as well as a number of bytes to copy (n-bytes) may be provided.

Copies the given `buffer` to the current position.

An `offset` in the buffer as well as a number of bytes to copy (`n-bytes`) may be provided.

wr-f32clj/s

(wr-f32 view floating)

Writes a 32-bit float to the current position.

Writes a 32-bit float to the current position.

wr-f64clj/s

(wr-f64 view floating)

Writes a 64-bit float to the current position.

Writes a 64-bit float to the current position.

wr-stringclj/s

(wr-string view string)

Writes a string to the current position, encoded at UTF-8.

Cf. [[wa-string]] about the returned value

Writes a string to the current position, encoded at UTF-8.

Cf. [[wa-string]] about the returned value
sourceraw docstring

IViewclj/sprotocol

Additional functions related to views (growing ones as well).

Additional functions related to views (growing ones as well).

garanteed?clj/s

(garanteed? view n-bytes)

Is it possible to write at least n-bytes bytes?

Growing views always return true since they can grow automatically.

Is it possible to write at least `n-bytes` bytes?

Growing views always return true since they can grow automatically.

offsetclj/s

(offset view)

Returns the offset in the original buffer this view starts from.

Views can be counted using Clojure's count which expresses the number of bytes wrapped by the view starting from the offset.

Returns the offset in the original buffer this view starts from.

Views can be counted using Clojure's `count` which expresses the number of bytes wrapped by the view
starting from the offset.

positionclj/s

(position view)

Returns the current position.

Returns the current position.

seekclj/s

(seek view position)

Modifies the current position.

Modifies the current position.

skipclj/s

(skip view n-bytes)

Advances the current position by n-bytes bytes.

Advances the current position by `n-bytes` bytes.

to-bufferclj/s

(to-buffer view)

Returns the buffer wrapped by the view.

Also see [[offset]].

Returns the buffer wrapped by the view.

Also see [[offset]].
sourceraw docstring

IViewBuilderclj/sprotocol

Building a new view.

Building a new view.

viewclj/s

(view view)
(view view offset)
(view view offset n-bytes)

A view can be created from a buffer (see buffer) or from another view.

An offset as well as a size (n-bytes) may be provided.

(def my-buffer
     (binf/buffer 100))

;; View with an offset of 50 bytes, 40 bytes long
(def my-view
     (binf/view my-buffer
                50
                40))

;; View from a view, offset of 60 bytes in the original buffer (50 + 10), 20 bytes long
(def inner-view
     (binf/view my-view
                10
                20))
A view can be created from a buffer (see [[buffer]]) or from another view.

An `offset` as well as a size (`n-bytes`) may be provided.

```clojure
(def my-buffer
     (binf/buffer 100))

;; View with an offset of 50 bytes, 40 bytes long
(def my-view
     (binf/view my-buffer
                50
                40))

;; View from a view, offset of 60 bytes in the original buffer (50 + 10), 20 bytes long
(def inner-view
     (binf/view my-view
                10
                20))
```
sourceraw docstring

remainingclj/s

(remaining view)

Returns the number of bytes remaining until the end of the view.

In the context of a growing view, this value means the number of bytes before hitting the end of the currently allocated buffer, which matters for reading. When writing, this value indicates the number of bytes remaining before reallocating a bigger buffer. See growing-view.

Returns the number of bytes remaining until the end of the view.

In the context of a growing view, this value means the number of bytes before hitting the end of the currently
allocated buffer, which matters for reading. When writing, this value indicates the number of bytes remaining
before reallocating a bigger buffer. See [[growing-view]].
sourceraw docstring

text-decodeclj/s

(text-decode buffer)
(text-decode text-decoder buffer)

Interprets the given buffer as a string.

A decoder may be provided (see text-decoder).

Interprets the given `buffer` as a string.

A decoder may be provided (see [[text-decoder]]).
sourceraw docstring

text-decoderclj/s

(text-decoder)
(text-decoder encoding)

Some functions accepts a text decoder.

Available encodings are: :iso-8859-1, :utf-8, :utf-16-be, :utf-16-le

Default is UTF-8 but argument is non-nilable.

Some functions accepts a text decoder.

Available encodings are: `:iso-8859-1`, `:utf-8`, `:utf-16-be`, `:utf-16-le`

Default is UTF-8 but argument is non-nilable.
sourceraw docstring

text-encodeclj/s

(text-encode string)

Returns a buffer containing the given string encoded in UTF-8.

Returns a buffer containing the given `string` encoded in UTF-8.
sourceraw docstring

u16clj/s

(u16 bits)
(u16 b8-1 b8-2)

Casts the given bits (any integer) into a 16-bit unsigned integer.

Or recombines the given bytes in big endian order.

Casts the given `bits` (any integer) into a 16-bit unsigned integer.

Or recombines the given bytes in big endian order.
sourceraw docstring

u32clj/s

(u32 bits)
(u32 b8-1 b8-2 b8-3 b8-4)

Casts the given bits (any integer) into a 32-bit unsigned integer.

Or recombines the given bytes in big endian order.

Casts the given `bits` (any integer) into a 32-bit unsigned integer.

Or recombines the given bytes in big endian order.
sourceraw docstring

u8clj/s

(u8 integer)

Casts the given bits (any integer) into a 8-bit unsigned integer.

Casts the given `bits` (any integer) into a 8-bit unsigned integer.
sourceraw docstring

Viewcljs

source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close