reading nested yaml sequences for vertices
This commit is contained in:
parent
03da03d679
commit
e694c32496
3 changed files with 25 additions and 9 deletions
12
data.yaml
12
data.yaml
|
|
@ -1,8 +1,8 @@
|
||||||
name: Fibonacci
|
name: Fibonacci
|
||||||
data:
|
data:
|
||||||
- 1
|
- [1.0, 0.5]
|
||||||
- 1
|
- [1.0, 0.5]
|
||||||
- 2
|
- [2.0, 0.5]
|
||||||
- 3
|
- [3.0, 0.5]
|
||||||
- 5
|
- [5.0, 0.5]
|
||||||
- 8
|
- [8.0, 0.5]
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ void kubo_file_parse(char *file_name) {
|
||||||
|
|
||||||
printf("%s:\n", n->name);
|
printf("%s:\n", n->name);
|
||||||
for (unsigned i = 0; i < n->data_count; i++) {
|
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);
|
err = cyaml_free(&config, &top_schema, n, 0);
|
||||||
|
|
|
||||||
20
kubo_file.h
20
kubo_file.h
|
|
@ -23,14 +23,30 @@
|
||||||
#include <cyaml/cyaml.h>
|
#include <cyaml/cyaml.h>
|
||||||
#include <stdio.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 {
|
struct numbers {
|
||||||
char *name;
|
char *name;
|
||||||
int *data;
|
kubo_file_vertex *data;
|
||||||
unsigned data_count;
|
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 = {
|
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[] = {
|
static const cyaml_schema_field_t top_mapping_schema[] = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue