Giter VIP home page Giter VIP logo

treepack's Introduction

treepack โ€” file-tree marshaling

Programs

  • treeload directory file
    • Loads a file into a tree rooted at directory according to rules described later.
  • treedump directory file
    • Dumps a tree rooted at directory into a file in one of the supported formats.

Currently libucl is used to read and write files so that UCL or JSON files can be loaded with treeload; and JSON (pretty, compact), YAML (compact), and msgpack, can be dumped with treedump.

Tree-making rules

  • Tree leaves, that is non-object, non-array object members or array elements become regular files with their key as the file name and value as file content. Key of array elements is their implicit zero-based index.
  • Objects and arrays become directories named after their key. They contain files and directories corresponding to child leaves or other objects and arrays.

Let's consider a simple example with a structure in UCL format:

people = [
	{name = "Alice", genius = yes, items = [phaser]}
	{name = "Bob", genius = no, items = [cap, stick]},
]

The resulting file tree produced by treeload is as follows:

people/
	0/
		name    -> Joe
		genius 	-> no
		items/
			0     -> cap
			1     -> stick
	1/
		name    -> Alice
		genius  -> yes
		items/
			0     -> phaser

TODO

  • Write treedump.
  • Write actual tree-making code instead of emitting a shell script.
  • Rewrite as a Lua host (script?) driven by Lua tables.
    • This way any structured format can be generically plugged in by writing a binding and using it to fill a Lua table.

NOTES

Cleaned up ucl.h

treepack's People

Contributors

okvik 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.