jin-tree 3.0.0

Tree - simple fast compact user-readable binary-safe extensible structural format


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Tree

Simple fast compact user-readable binary-safe extensible structural format.

Build Status

more - betterJSONXMLYAMLINITree
Readability31455
Edit-friendly31455
Deep hierarchy33315
Simple to implement32155
Performance31155
Size31455
Streaming00555
Binary-safe20005
Universality43315
Prevalence55330
Text editors support55351
Languages support45351

Short description

Structural-nodes represents as names that can not contain [\s\n=]. Example of structural nodes:

first-level second-level third-level
first-level
	first-of-second-level third-level
	second-of-second-level

Indents must use tabs, lines must use unix line ends.

Data-nodes represents as raw data between [\\] and [\n] characters. Example

\hello
\world
\
	\hello
	\world

In one line may be any count of structural-nodes, but only one data-node at the end.

article
	title \Hello world
	description
		\This is demo of tree-format
		\Cool! Is not it? :-)

Grammar using grammar.tree language

More examples.

More info about format and tree-based languages (russian article).

IDE support

Implementations

D API

Parsing

    string data = cast(string) read( "path/to/file.tree" ); // read from file
    Tree tree = Tree.parse( data , "http://example.org/source/uri" ); // parse to tree

Simple queries

    Tree userNames = tree.select( "user name" ); // returns name-nodes
    Tree userNamesValues = tree.select( "user name " ); // returns value-nodes

Node info

    string name = userNames[0].name; // get node name
    string stringValue = userNames[0].value; // get value as string with "\n" as delimiter
    uint intValue =  userNames[0].value!uint; // get value converted from string to another type

    Tree[] childs = tree.childs; // get child nodes array
    string baseUri = tree.baseUri; // get base uri like "http://example.org/source/uri"
    size_t row = tree.row; // get row in source stream
    size_t col = tree.col; // get column in source stream
    string uri = tree.uri; // get uri like "http://example.org/source/uri#3:2"

Nodes creation

	Tree values = Tree.Values( "foo\nbar" , [] );
	Tree name = Tree.Name( "name" , values );
	Tree list = Tree.List( [ name , name ] );
	Tree firstLineName = name.clone( [ name[0] );

Serialization

    string data = tree.toString(); // returns string representation of tree
    tree.pipe( stdout ); // prints tree to output buffer
Authors:
jin
Dependencies:
none
Versions:
3.0.0 2016-Sep-11
2.0.0 2015-Nov-22
1.2.0 2015-Nov-09
1.1.1 2015-Oct-10
1.1.0 2015-Oct-10
Show all 13 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 13 downloads this month

  • 319 downloads total