Git Product home page Git Product logo

nfig's Introduction

nfig

A header-only C++ config library with a focus on ease of spontaneous use over performance. There is no direct access to variables, but instead each variable is accessed like:

int width = nfig.get<int>("I_WIDTH")

Trying to code spontaneously when I need to create new config values in different locations in code (globals extern, globals local, parsing config, config file itself) is awful. I rarely make a local copy of a config variable, unless I'm going over a high-performance section of code.

Config values are created in a JSON-formatted file, for example:

{
	"B_MUTE_MUSIC": false,
	"I_WIDTH": 100,
	"I_HEIGHT": 100,
	"F_WEIGHT": 10.3,
	"S_TITLE": "This is a sweet title"
}

where the prefix before the underline must correspond to each type. This allows for creating custom config value types in extensions to nfig, such as colour. You'll need to include a parsing function to create a Value of this type.

{
	"CLR_BACKGROUND": [255, 128, 0]
}

Test code is included.

Dependencies

For handling parameters of unknown type:

riffer

For parsing JSON-format config files:

picojson

nfig's People

Contributors

dustinfreeman avatar

Watchers

 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.