GithubHelp home page GithubHelp logo

slacc's Introduction

SLACC - Simple Lightweight Adaptable Command Console

Command console module written in C++11 for use as in-game console module or simple scripting engine.

This module have zero dependencies so it's super easy to use in existing projects. It heavily uses variadic templates to provide automatisation of binding commands with functions and nice API. Small usage example below:

void func1_ptr(const std::string& name) {
    std::cout << "Hello " << name << "!" << std::endl;
}

std::function<void(float)> func2_wrapper = [](float x) {
    std::cout << x << "^2 = " << x*x << std::endl;
};

auto func3_lambda = [](int x, float y, const std::string& z) {
    std::cout << x << y << z << std::endl;
};

/* ... */

CommandConsole cmd;

cmd.bind("func1", func_ptr);      // default parser, types are infered from function pointer
cmd.bind("func2", func2_wrapper); // default parser, types are infered from std::function wrapper
// to use lambda, either wrap it in std::function or provide valid parser
cmd.bind("func3", func3_lambda, Parser::BasicParser::parse<int, float, std::string>);

cmd.execute("func1 John"); // func1_ptr("John")
cmd.execute("func2 11.0"); // func2_wrapper(11.0f)
cmd.execute("func3 0 3.14 \"hello world\""); // func3_lambda(0, 3.14f, "hello world")

Requirements

  • C++11 supporting compiler (project for Visual Studio 2013 provided)

Platforms tested

  • Windows (tested on Windows 7 x64)

Compilers tested

  • MSVC (tested on Visual Studio 2013)
  • GCC (tested on 5.1.0)

Dependencies

None!

License

See LICENSE file.

Examples of usage

You can find example usage in src/main.cpp file.

slacc's People

Contributors

ripper37 avatar shrimpey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

shrimpey

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.