Liking cljdoc? Tell your friends :D

parse_struct

Parse C struct dumps in clojure.

Clojars Project

Installation:

Leiningen/Boot

[fctorial/parse_struct "0.8.0"]

Clojure CLI/deps.edn

fctorial/parse_struct {:mvn/version "0.8.0"}

Gradle

compile 'fctorial:parse_struct:0.8.0'

Maven

<dependency>
  <groupId>fctorial</groupId>
  <artifactId>parse_struct</artifactId>
  <version>0.8.0</version>
</dependency>

Examples

(ns examples
  (:require [parse_struct.core :refer [serialize deserialize type-size]]
            [parse_struct.common_types :as ct]))

(declare byte-seq)

(deserialize ct/i16 byte-seq)
; short integer

(deserialize {:type    :array
              :len     20
              :element ct/u32be}
             byte-seq)
; seq of big endian unsigned integers (long if they're too big, since java doesn't have unsigned. Large longs are stored in bigint)

(deserialize {:type        :struct
              :definition [[:a ct/u32]
                           (ct/padding 2)
                           [:b ct/i32]
                           [:c {:type       :string
                                :bytes      8}]]}
             byte-seq)
; a struct

See wiki for full documentation.

TODO:

  • support cljs
  • Lazy serializer and tests
  • Abstracted tests
  • :bytes

Tests:

You'll need to have gcc installed to run tests.

clojure -A:test-setup
clojure -A:dump-server
# in other window
clojure -A:test

Can you improve this documentation? These fine people already did:
Sagar Tiwari & Ertuğrul Çetin
Edit on GitHub

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

× close