Skip to content

xZepyx/toon.hpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toon.hpp

toon.hpp is a lightweight cpp header for reading, writing, and editing TOON (Token-Oriented Object Notation) files.

TOON is a structured configuration format designed to be compact, readable, and efficient. toon.hpp allows C++ programs to parse .toon files into dynamic objects, modify them, and write them back to disk.


Features

  • Header-only library
  • Parse TOON text and files
  • Write and overwrite .toon files
  • Dynamic value system (objects, arrays, strings, numbers, booleans)
  • Nested object editing
  • Minimal dependencies (C++ standard library only)

Installation

Clone the repository:

git clone https://github.com/xZepyx/toon.hpp

Add the header to your project:

#include "toon/toon.hpp"

No linking or build configuration is required.


Example

#include "toon/toon.hpp"
#include <iostream>

int main() {

    toon::value config;

    config["window"]["width"] = 1280;
    config["window"]["height"] = 720;

    config["user"]["name"] = "zepyx";
    config["user"]["admin"] = true;

    std::cout << toon::dump(config);

    toon::write_file("config.toon", config);
}

Output:

window:
  width: 1280
  height: 720
user:
  name: zepyx
  admin: true

Reading Files

auto config = toon::parse_file("config.toon");

int width = config["window"]["width"];

Example config.toon:

window:
  width: 1280
  height: 720

Writing Files

toon::write_file("config.toon", config);

This serializes the structure and overwrites the file.


Editing Data

auto cfg = toon::parse_file("config.toon");

cfg["window"]["width"] = 1920;
cfg["window"]["height"] = 1080;

toon::write_file("config.toon", cfg);

Arrays

toon::value fruits;

fruits.push_back("apple");
fruits.push_back("banana");
fruits.push_back("orange");

Serialized output:

- apple
- banana
- orange

Parsing Text

auto data = toon::parse(R"(

user:
  name: Alice
  admin: true

)");

Documentation

Documentation: docs/root.md

Todo: docs/todo.md


License

© 2025 xZepyx — Licensed under the MIT License.


Status

Early development version.

APIs may change as the parser and format support expand.

Contributing

Feel free to contribute. It's a open-source project duh?


About

A simple cpp header for reading, writing and editing: Token-Oriented Object Notation (TOON)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors