Godot YAML
by FimbulWorks
27
Godot YAML GDExtension
This is the C++ GDExtension implementation of the Godot YAML plugin. It provides high-performance YAML parsing and serialization using RapidYAML as the core engine, offering sub-millisecond processing for most YAML documents. This extension is built for Godot 4.3 or later.
๐ Version History
- 1.1.0 (Current) - Nested YAML files can now be loaded with the
!Resource
tag, and some fixes - 1.0.0 - First major release with custom YAML editor, streamlined API, and several fixes. See the plugin changelog for details
- 0.12.1 - Build support for Linux (x86 64-bit)
- 0.12.0 - Performance optimizations, bug fixes, and comprehensive tests for all variant types
- 0.11.0 - Added support for parsing multiple documents, and error handling for custom class deserialization
- 0.10.1 - Fixed issue with custom Resources not being serializable
- 0.10.0 - Added custom class serialization support, upgraded to Godot 4.3
- 0.9.0 - Initial public release
๐ Quick Start
# Parse YAML
var result = YAML.parse("key: value\nlist:\n - item1\n - item2")
if result.has_error():
push_error(result.get_error())
return
var data = result.get_data()
print(data.key) # Outputs: value
print(data.list) # Outputs: [item1, item2]
# Generate YAML
var yaml_text = YAML.stringify(data).get_data()
print(yaml_text)
๐ For full usage details and API documentation, see the plugin README:
๐ project/addons/yaml/README.md
๐ฅ Key Features
- โก High Performance: Built on the lightweight and efficient RapidYAML library
- ๐งฉ Comprehensive Variant Support: Handles all Godot built-in Variant types (except Callable and RID)
- ๐งช Custom Class Serialization: Register your GDScript classes for seamless serialization and deserialization
- ๐ Multi-Document Support: Parse YAML files with multiple
---
separated documents - ๐จ Style Customization: Control how YAML is formatted with customizable style options
- ๐ Comprehensive Error Handling: Detailed error reporting with line and column information
- ๐ Thread-Safe: Fully supports multi-threaded parsing and emission
- โ Validation: Separate validation step for checking YAML syntax without full parsing
- ๐๏ธ Resource References: Use
!Resource
tags to reference and load external resources - ๐ก๏ธ Security Controls: Manage resource loading security during YAML parsing
๐ ๏ธ Installation & Setup
Building From Source
Prerequisites
- Git (for cloning and submodules)
- Python 3.x (for SCons build system)
- C++ compiler with C++17 support:
- Windows: Visual Studio 2022 with C++ workload
- Linux/macOS: GCC 9+ or Clang 10+
- SCons build system (
pip install scons
)
Step 1: Clone the Repository
# Clone with submodules
git clone --recursive https://github.com/fimbul-works/godot-yaml
# Or if already cloned, initialize submodules
git submodule update --init --recursive
Step 2: Build the Extension
# Debug build
scons target=template_debug
# Release build
scons target=template_release
# Specify platform (default is platform-dependent)
scons platform=windows target=template_release
scons platform=linux target=template_release
Build Options
platform
: Target (windows
,linux
,macos
, etc.)target
: Build type (template_debug
,template_release
)arch
: CPU architecture (x86_32
,x86_64
,arm64
, etc.)dev_build
: Enable extra debugging (yes
/no
)use_llvm
: Use Clang/LLVM compiler (yes
/no
)verbose
: Verbose build output (yes
/no
)
โ Supported Platforms
- Windows: โ Prebuilt binaries available.
- Linux: โ Prebuilt binaries available for x86 64-bit architecture.
- macOS: ๐ง Not yet prebuilt, but should compile without issues.
๐ Contributions welcome! If you can help with Linux/macOS, open a PR.
๐งโ๐ป Contributing
Development Guidelines
- Follow Godot's API design patterns.
- Minimize allocations (use
ryml::cstring
instead ofstd::string
). - Error handling: Use
YAMLResult
and throwYAMLException
for C++ errors. - Thread safety: No global state; ensure safe multithreading.
- Write tests: Every new feature should have test coverage.
- Document your changes: All public APIs must be documented.
Code Formatting
# Format code (requires clang-format)
clang-format -i src/*.cpp src/*.h src/variants/*.cpp src/variants/*.h
๐ License
MIT License (see LICENSE file for details).
๐ Built with โก by FimbulWorks
Download
Version1.1.0
Download Now
Support
If you need help or have questions about this plugin, please contact the author.
Contact Author