https://github.com/akira4o4/c-luaconfig
C\Cpp Lua Config
https://github.com/akira4o4/c-luaconfig
config cpp lua
Last synced: 3 months ago
JSON representation
C\Cpp Lua Config
- Host: GitHub
- URL: https://github.com/akira4o4/c-luaconfig
- Owner: akira4O4
- License: agpl-3.0
- Created: 2025-03-22T16:47:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-23T18:27:03.000Z (over 1 year ago)
- Last Synced: 2025-03-23T19:21:43.338Z (over 1 year ago)
- Topics: config, cpp, lua
- Language: C++
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# C-LuaConfig
**Easy** C\C++ LuaConfig lib
---
## Feat
- Only one file
- Support: C\C++
- Support: int,float,double,std::string,bool
- Support: array index calls e.g."a.b.c[0]"
---
## Usage
### 1.Install Lua
```bash
sudo apt install lua5.3
```
### 2.Edit your ```config.lua```
```lua
name="Akira"
config = {
window = {
width = 1920,
height = 1080,
},
title = "C-LuaConfig",
enable = false,
colors = {
rgb = {1, 2, 3},
rgba= {1.1, 2.2, 3.3,4.4},
},
}
```
### 3.Edit your ```main.cc```
```cpp
#include "src/luaconfig.h"
#include
int main(int argc, char const *argv[])
{
std::string file = "../config.lua";
auto config = new LuaConfig(file);
auto name = config->get("name");
auto width = config->get("config.window.width");
auto height = config->get("config.window.height");
auto title = config->get("config.title");
auto enable = config->get("config.enable");
auto rgb0 = config->get("config.colors.rgb[0]");
auto rgba1 = config->get("config.colors.rgba[1]");
std::cout << name << std::endl;
std::cout << width << std::endl;
std::cout << height << std::endl;
std::cout << title << std::endl;
std::cout << enable << std::endl;
std::cout << rgb0 << std::endl;
std::cout << rgba1 << std::endl;
return 0;
}
```