Code Monkey home page Code Monkey logo

holgen's Introduction

HolGen : Generate your Json/Lua C++ Bindings!

HolGen (pronounced whole-gen) is an MIT licensed code generation tool developed alongside a game that I'm working on, that generates json loaders (using rapidjson) and Lua exporters for your data structures in C++. It has a C-like DSL allowing you to express your data structure along with your usage intent, and it generates C++ classes and CMake files.

PS: The project is not yet ready for its prime time; please don't use it in production unless you're OK with frequent changes. Once the project reaches 1.0, I'll make sure not to make backwards incompatible changes between minor versions.

Embedding in your project

Compile holgen cli application and put it in your PATH. Holgen is smart enough that it won't overwrite your files if the contents are identical, so you can integrate it with your build system and regenerate without triggering unnecessary rebuilds. Or if you're lazy, just create a bash script like this that you execute manually:

#!/usr/bin/env bash

holgen holgen/schemas libs/schemas project_r::schemas project_r_schemas ../ProjectRSchemas.h

CLI will change over time (getopts will be supported eventually), currently the usage is:

holgen [schema dir] [output dir] [namespace] [cmake project name] [common header file to include where you can configure error handling]

Usage

In the examples directory, you can see the schemas under < id >/schemas and the generated output in [example id] /output. There's a main project that includes all the projects in order to showcase its usage. The project is under examples/usage, and each example has an examples/usage/example< id >.cpp file making use of the generated code.

Example 1: Classes and enums

Check out this schema and its usage to see the basic syntax, structs, enums and fields. This example uses a single schema file for simplicity, but holgen cli will read all schema files under the provided directory.

Example 2: Extended class/enum usage

This schema and its usage shows some field annotations to customize your getters/setters along with defining functions that can be called from C++ or Lua.

Example 3: Variants (type unions)

If you need to determine the type of a variable in runtime and store different types of objects in the same c++ container, variants will be useful! They're more or less like std::variant. See how to use it here.

Example 4: Data Manager for data oriented projects

If you're building an RPG, you'll have many weapons, armors, characters, and you'll want to be systematic in your usage. In that case DataManager is for you! It recursively loads all your data from a directory, assigns IDs, creates field based indices so that you can reference your resources using their name in json. Check out how it's used.

Interested in a feature not yet supported? Let me know!

holgen's People

Contributors

holgac avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.