Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zackmason/nyml
A simple file format similar to Yaml
https://github.com/zackmason/nyml
Last synced: about 2 months ago
JSON representation
A simple file format similar to Yaml
- Host: GitHub
- URL: https://github.com/zackmason/nyml
- Owner: ZackMason
- Created: 2022-03-21T17:06:15.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-28T00:07:41.000Z (over 2 years ago)
- Last Synced: 2023-08-13T00:10:53.732Z (over 1 year ago)
- Language: C++
- Size: 184 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nyml - nyml not yaml
A simple file format similar to Yaml---
A basic nyml config file looks something like this
```
---
# Comments must start with a '#'
version: 0.1.1
window: ~
width: 640
height: 480
title: nyml is great
font: ~
file: Fonts/NotoMono-Regular.ttf
size: 12credits: ~
-: ~
name: Bill Gates
role: Programmer
-: ~
name: Pablo Picasso
role: Artist
# Any of these work as bools
settings: ~
fullscreen: false
mute: True
vsync: off
uncappedFPS: On
tests: true
-: on
title: test1
file: test1.nyml
-: off
title: bench_test
file: bench_test.nyml
```## Code Example
```c++
#define NYML_IMPLEMENTATION
#define NYML_EXCEPTIONS
#include "Nyml.h"int main()
{
using namespace std::string_literals;
// load from a file
nyml::Node config = nyml::LoadFile(ASSETS_PATH + std::string("config.nyml"));std::cout << nyml::Dump(config).str() << std::endl;
// load from string
std::string test_data =
"test: ~\n"
" hello: world!\n";nyml::Node test_node = nyml::Parse(test_data);
test_node["test"]["bool"] = true;
test_node["test"]["bool"] = false;try {
test_node["test"]["bool"].as(); // throws exception with NYML_EXCEPTIONS
}
catch(nyml::NymlInvalidAccessException & e)
{
std::cerr << e.pretty_print() << std::endl;
}
// text such as "on" and "Off" is only valid as a bool when using Parse
test_node["test"]["bool"].as(); // valid
test_node["test"]["bool"] = "false"s;
test_node["test"]["bool"].as(); // valid
test_node["test"]["bool"].as(); // invalid
return 0;
}
```