Generators
Understand how SchemaLang generators transform your schema into working code.
Overview
SchemaLang generators convert schema definitions into target-specific code. Generators can work independently or integrate through the drop-in system.
C++ Generator
Generates complete C++ classes with getters, setters, and constructors.
./SchemaLangTranspiler -schema=./schemas -outputDirectory=./output -cpp
Generated Output
- Header files (.hpp) with class declarations
- Source files (.cpp) with method implementations
- Private member variables with public accessors
- Drop-in method injection support
JSON Generator
Creates JSON schemas and adds serialization methods via drop-in.
./SchemaLangTranspiler -schema=./schemas -outputDirectory=./output -json -cpp
Generated Methods (Drop-In)
json toJSON()- Serialize object to JSONvoid fromJSON(json j)- Deserialize from JSONjson getSchema()- Get JSON Schema definition
SQLite Generator
Generates SQLite database operations with automatic migration support.
./SchemaLangTranspiler -schema=./schemas -outputDirectory=./output -sqlite -cpp
Generated Methods (Drop-In)
bool SQLiteInsert(sqlite3* db)- Insert recordvoid SQLiteSelectBy[Field](sqlite3* db, type value)- Select by each fieldstatic bool SQLiteCreateTable(sqlite3* db)- Create table- Automatic migration functions
MySQL Generator
Generates MySQL X DevAPI operations with migration support.
./SchemaLangTranspiler -schema=./schemas -outputDirectory=./output -mysql -cpp
Generated Methods (Drop-In)
bool MySQLInsert(mysqlx::Session& session)- Insert recordstatic vector<T*> MySQLSelectBy[Field](...)- Select operationsstatic bool MySQLCreateTable(mysqlx::Session& session)- Create table- Embedded migration SQL
Drop-In System
The drop-in system allows specialized generators to inject methods into OOP language classes seamlessly.
How It Works
- Enable multiple generators (e.g.,
-cpp -json -sqlite) - Specialized generators register methods to inject
- C++ generator includes injected methods in generated classes
- Result: Unified classes with database ops, serialization, etc.
Custom Generators
Create custom generators as .dll/.so plugins:
./SchemaLangTranspiler -additionalGenerators=./plugins -schema=./schemas -outputDirectory=./output
See the documentation for creating dynamic generators.