reading nested yaml sequences for vertices

This commit is contained in:
Luka Jankovic 2025-07-25 01:48:23 +02:00
parent 03da03d679
commit e694c32496
3 changed files with 25 additions and 9 deletions

View file

@ -1,8 +1,8 @@
name: Fibonacci
data:
- 1
- 1
- 2
- 3
- 5
- 8
- [1.0, 0.5]
- [1.0, 0.5]
- [2.0, 0.5]
- [3.0, 0.5]
- [5.0, 0.5]
- [8.0, 0.5]

View file

@ -16,7 +16,7 @@ void kubo_file_parse(char *file_name) {
printf("%s:\n", n->name);
for (unsigned i = 0; i < n->data_count; i++) {
printf(" - %i\n", n->data[i]);
printf(" - %f:%f\n", n->data[i][0], n->data[i][1]);
}
err = cyaml_free(&config, &top_schema, n, 0);

View file

@ -23,14 +23,30 @@
#include <cyaml/cyaml.h>
#include <stdio.h>
typedef float kubo_file_vertex[2];
//
// struct kubo_file_wall {
// kubo_file_vertex *vertices;
// unsigned vertices_count;
// };
//
// struct kubo_file_scene {
// struct kubo_file_wall *walls;
// unsigned walls_count;
// };
struct numbers {
char *name;
int *data;
kubo_file_vertex *data;
unsigned data_count;
};
static const cyaml_schema_value_t float_entry = {
CYAML_VALUE_FLOAT(CYAML_FLAG_DEFAULT, float),
};
static const cyaml_schema_value_t data_entry = {
CYAML_VALUE_INT(CYAML_FLAG_DEFAULT, int),
CYAML_VALUE_SEQUENCE_FIXED(CYAML_FLAG_DEFAULT, float, &float_entry, 2),
};
static const cyaml_schema_field_t top_mapping_schema[] = {