Giter VIP home page Giter VIP logo

construct's Introduction

Python Construct

Construct is a powerful declarative parser for binary data.

It is based on the concept of defining data structures in a declarative
manner, rather than procedural code: Simple constructs can be combined
hierarchically to form increasingly complex data structures. It’s the first
library that makes parsing fun, instead of the usual headache it is today.

Construct features bit and byte granularity, symmetrical operation (parsing
and building), component-oriented declarative design, easy debugging and
testing, an easy-to-extend subclass system, and lots of primitive
constructs to make your work easier:

  • Fields
  • Structs
  • Unions
  • Repeaters
  • Meta constructs
  • Switches
  • On-demand parsing
  • Pointers
  • And more!

Java Construct

This Java version employs some syntactic sugar (i.e. static methods) to make the syntax as close as possible to the original Construct library in Python.

See for example


    Construct struct = BitStruct("foo",
                         BitField("a", 3),
                         Flag("b"),
                         Padding(3),
                         Nibble("c"),
                         Struct("bar",
                           Nibble("d"),
                           Bit("e")));

A Java Construct can parse byte arrays and produces Objects like Containers. Viceversa, it can take Objects to produce byte arrays.

public Object parse(byte[] data);
public byte[] build( Object obj);

Parsing example:


    Container c1 = Container( "a", 7, "b", false, "bar", Container( "d", 15 , "e", 1), "c",8);
    Container c2 = struct.parse( ByteArray( 0xe1, 0x1f ));
    assertEquals( c1, c2 );

Features

Currently Java Construct supports enough Macros, Adapters and repeaters to parse and build these protocols:

construct's People

Contributors

zigliouk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.