https://github.com/RippeR37/SLACC
Simple Lightweight Adaptable Command Console
https://github.com/RippeR37/SLACC
Last synced: 17 days ago
JSON representation
Simple Lightweight Adaptable Command Console
- Host: GitHub
- URL: https://github.com/RippeR37/SLACC
- Owner: RippeR37
- License: mit
- Created: 2015-12-17T23:16:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-01-21T23:02:38.000Z (over 5 years ago)
- Last Synced: 2024-11-14T21:38:07.287Z (6 months ago)
- Language: C++
- Size: 14.6 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - SLACC
README
## 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:
```c++
void func1_ptr(const std::string& name) {
std::cout << "Hello " << name << "!" << std::endl;
}std::function 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);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](LICENSE) file.### Examples of usage
You can find example usage in `src/main.cpp` file.