Giter Club home page Giter Club logo

derelict-resources's Introduction

Derelict Resources banner

Derelict Resources (DR) is a configuration language and parser library featuring array based values and short s-like expressions based functions. The language's syntax aims to be both human-readable and easy to parse. Yet provides enough tools to the end user to create branching and dynamic configurations that can be modified and reloaded on the fly.

The library is free and open-source software licensed under the LGPL-2.1. It's made to run on modern POSIX-compliant systems, and except for the compiler and build system, is not dependent on third-party software.

Language Features

  • comments
  • user-defined sections
  • user-defined variables
  • program-defined parameters
  • arithmetic operations
  • string operations
  • color operations
  • iteration loops
  • conditionals
  • child file inclusion

For more information about the language usage, features and syntax check out the full language spec.

Dependencies

Tools :

  • C99 compiler with a stdlib + POSIX 200809L
  • Make
  • Xxd

First-party libraries :

Installation

First, edit the makefile if you want to change the installation destinations. These are represented by the variables DEST_HEADERS and DEST_LIBS for the public API headers and library files respectively. By default, they are set to /usr/include/derelict/ and /usr/lib. Then, build and install DR with the following commands :

make
make install

After these steps, both a shared binary and static archive will be generated and installed on your system. Examples will also be built and placed under ./build/bin. The examples are statically compiled and can be run from anywhere on your system.

Usage

Add this include to get access to the library functions :

#include <derelict/dr.h>

As well as this compilation flag :

-ldr

Minimal Example

The following code snippet shows a minimal example of the library usage. When compiled and run, it will look for the file /tmp/dr-example and load its data. It then attempts to fetch a resource named property under the namespace namespace, and if found, prints its values.

#include <stdio.h>
#include <derelict/dr.h>

int
main(void)
{
	dr_config_t *cfg = dr_config_create(0);

	dr_config_push_source(cfg, "/tmp/dr-example");
	dr_config_load(cfg);

	dr_resource_fetch(cfg, "example_namespace", "example_property");
	while (dr_resource_pick_next_value(cfg))
	{
		printf("%s\n", dr_resource_convert_to_string(cfg));
	}

	return 0;
}

A matching minimal DR configuration in /tmp/dr-example will then look like this :

example_namespace example_property value_A value_B

Output :

value_A
value_B

Check out the examples directory for more in depth demonstrations.

derelict-resources's People

Contributors

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