https://github.com/djoezeke/yamlfy
A Lightweight Yaml file parser and emmiter written in pure c.
https://github.com/djoezeke/yamlfy
c config configuration cpp deserialize emmiter parser serializer yaml yaml-parser
Last synced: 11 months ago
JSON representation
A Lightweight Yaml file parser and emmiter written in pure c.
- Host: GitHub
- URL: https://github.com/djoezeke/yamlfy
- Owner: djoezeke
- License: mit
- Created: 2025-03-08T00:24:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-08T01:35:38.000Z (over 1 year ago)
- Last Synced: 2025-03-08T02:24:33.951Z (over 1 year ago)
- Topics: c, config, configuration, cpp, deserialize, emmiter, parser, serializer, yaml, yaml-parser
- Language: C
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MyYAML 📄
MyYAML is a simple C library for creating, manipulating, and printing YAML data structures. It supports scalar values, sequences, and mappings.
## Features ✨
- Create YAML scalar values
- Create YAML sequences
- Create YAML mappings
- Add items to sequences
- Add key-value pairs to mappings
- Print YAML values
- Pretty print YAML values to a string
- Read YAML files into `YamlValue` structures
- Write `YamlValue` structures to YAML files
- Free YAML values
## Files 📂
- `yaml.c`: Implementation of the YAML library
## Usage 🚀
### Creating and Printing YAML Values
To create and print YAML values, you can use the functions provided in `yaml.c`. Here is an example:
````c
#include "yaml.c"
int main()
{
// Create a YAML mapping
Yaml *root = yaml_create_mapping();
yaml_mapping_add(root, "name", yaml_create_scalar("John Doe"));
yaml_mapping_add(root, "age", yaml_create_scalar("30"));
// Create a YAML sequence and add it to the mapping
Yaml *hobbies = yaml_create_sequence();
yaml_sequence_add(hobbies, yaml_create_scalar("reading"));
yaml_sequence_add(hobbies, yaml_create_scalar("swimming"));
yaml_sequence_add(hobbies, yaml_create_scalar("coding"));
yaml_mapping_add(root, "hobbies", hobbies);
// Print the YAML value
yaml_print(root, 0);
// Pretty print the YAML value
yaml_pretty_print(root, 0);
// Free the YAML value
yaml_free(root);
return 0;
}# MyYAML 📄
MyYAML is a simple C library for creating, manipulating, and printing YAML data structures. It supports scalar values, sequences, and mappings.
## Features ✨
- Create YAML scalar values
- Create YAML sequences
- Create YAML mappings
- Add items to sequences
- Add key-value pairs to mappings
- Print YAML values
- Free YAML values
## Files 📂
- `yaml.c`: Implementation of the YAML library
- `csv.cpp`: Implementation of a CSV parser
- `mycsv.hpp`: Header file for CSV and YAML related classes and functions
- `csvconfig.hpp`: Configuration header for CSV parser (currently empty)
- `yaml.cpp`: C++ implementation of the YAML library
## Usage 🚀
### Creating and Printing YAML Values
To create and print YAML values, you can use the functions provided in `yaml.c`. Here is an example:
```c
#include "yaml.c"
int main()
{
// Create a YAML mapping
YamlValue *root = yaml_create_mapping();
yaml_mapping_add(root, "name", yaml_create_scalar("John Doe"));
yaml_mapping_add(root, "age", yaml_create_scalar("30"));
// Create a YAML sequence and add it to the mapping
YamlValue *hobbies = yaml_create_sequence();
yaml_sequence_add(hobbies, yaml_create_scalar("reading"));
yaml_sequence_add(hobbies, yaml_create_scalar("swimming"));
yaml_sequence_add(hobbies, yaml_create_scalar("coding"));
yaml_mapping_add(root, "hobbies", hobbies);
// Print the YAML value
yaml_print(root, 0);
// Free the YAML value
yaml_free(root);
return 0;
}
````
## License 📜
This project is licensed under the MIT License.