Coder Social home page Coder Social logo

kv's Introduction

kv
==

kv is a simple, header-only key-value config reader for C.  It is implemented using X
Macros.  The advantage of this approach is that it generates code for parsing, printing,
and serialising the configuration files all at once.


format
------

Configuration file is read from standard input, one line per field of the key-value
struct.  Each line is expected to follow `%s = %s\n` format.  Conversions are provided
for integers, double precision floats, booleans (formatted as: `T`, `True` or `true`),
characters and strings.  Empty keys and lines are silently discarded.  Maximum length of
keys and values is BUFSIZ.

	# comments can be removed with sed
	key1 = 1       # int
	key2 = 1.0     # double
	key3 = T       # bool
	key4 = O       # char
	key5 = /       # char *
	key6 = 1,2,3   # int *


usage
-----

See included `example.c` and `example.conf` files, with Planck+15 cosmology data.

	make
	< example.conf sed 's/#.*//' | ./example

Notice that `kv.h` header file must be included **after** defining a `KV` macro.

kv's People

Contributors

oleskiewicz avatar

Watchers

James Cloos avatar  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.