1## Sol 2.15 2 3[![Join the chat at https://gitter.im/chat-sol2/Lobby](https://badges.gitter.im/chat-sol2/Lobby.svg)](https://gitter.im/chat-sol2/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 4 5[![Build Status](https://travis-ci.org/ThePhD/sol2.svg?branch=develop)](https://travis-ci.org/ThePhD/sol2) 6[![Documentation Status](https://readthedocs.org/projects/sol2/badge/?version=latest)](http://sol2.readthedocs.io/en/latest/?badge=latest) 7 8Sol is a C++ library binding to Lua. It currently supports all Lua versions 5.1+ (LuaJIT 2.x included). Sol aims to be easy to use and easy to add to a project. 9The library is header-only for easy integration with projects. 10 11## Documentation 12 13Find it [here](http://sol2.rtfd.io/). A run-through kind of tutorial is [here](http://sol2.readthedocs.io/en/latest/tutorial/all-the-things.html)! The API documentation goes over most cases (particularly, the "api/usertype" and "api/proxy" and "api/function" sections) that should still get you off your feet and going, and there's an examples directory [here](https://github.com/ThePhD/sol2/tree/develop/examples) as well. 14 15## Sneak Peek 16 17```cpp 18#include <sol.hpp> 19#include <cassert> 20 21int main() { 22 sol::state lua; 23 int x = 0; 24 lua.set_function("beep", [&x]{ ++x; }); 25 lua.script("beep()"); 26 assert(x == 1); 27} 28``` 29 30```cpp 31#include <sol.hpp> 32#include <cassert> 33 34struct vars { 35 int boop = 0; 36}; 37 38int main() { 39 sol::state lua; 40 lua.new_usertype<vars>("vars", "boop", &vars::boop); 41 lua.script("beep = vars.new()\n" 42 "beep.boop = 1"); 43 assert(lua.get<vars>("beep").boop == 1); 44} 45``` 46 47More examples are given in the examples directory. 48 49## Presentations 50 51"A Sun For the Moon - A Zero-Overhead Lua Abstraction using C++" 52ThePhD 53Lua Workshop 2016 - Mashape, San Francisco, CA 54[Deck](https://github.com/ThePhD/sol2/blob/develop/docs/presentations/ThePhD%20-%20No%20Overhead%20C%20Abstraction%20-%202016.10.14.pdf) 55 56## Creating a single header 57 58You can grab a single header out of the library [here](https://github.com/ThePhD/sol2/tree/develop/single/sol). For stable version, check the releases tab on github for a provided single header file for maximum ease of use. A script called `single.py` is provided in the repository if there's some bleeding edge change that hasn't been published on the releases page. You can run this script to create a single file version of the library so you can only include that part of it. Check `single.py --help` for more info. 59 60## Features 61 62- [Fastest in the land](http://sol2.readthedocs.io/en/latest/benchmarks.html) (see: sol bar in graph). 63- Supports retrieval and setting of multiple types including `std::string` and `std::map/unordered_map`. 64- Lambda, function, and member function bindings are supported. 65- Intermediate type for checking if a variable exists. 66- Simple API that completely abstracts away the C stack API, including `protected_function` with the ability to use an error-handling function. 67- `operator[]`-style manipulation of tables 68- C++ type representations in lua userdata as `usertype`s with guaranteed cleanup. 69- Customization points to allow your C++ objects to be pushed and retrieved from Lua as multiple consecutive objects, or anything else you desire! 70- Overloaded function calls: `my_function(1); my_function("Hello")` in the same lua script route to different function calls based on parameters 71- Support for tables, nested tables, table iteration with `table.for_each` / `begin()` and `end()` iterators. 72 73## Supported Compilers 74 75Sol makes use of C++11/14 features. GCC 4.9 and Clang 3.4 (with std=c++1z and appropriate standard library) or higher should be able to compile without problems. However, the 76officially supported and CI-tested compilers are: 77 78- GCC 4.9.0+ 79- Clang 3.5+ 80- Visual Studio 2015 Community (Visual C++ 14.0)+ 81 82## License 83 84Sol is distributed with an MIT License. You can see LICENSE.txt for more info. 85