kubo/kubo_file.h

65 lines
1.8 KiB
C

/*
* Copyright Luka Jankovic 2025
*
* This file is part of Kubo.
*
* Kubo is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* Kubo is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Kubo. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef KUBO_FILE_H
#define KUBO_FILE_H
#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;
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_SEQUENCE_FIXED(CYAML_FLAG_DEFAULT, float, &float_entry, 2),
};
static const cyaml_schema_field_t top_mapping_schema[] = {
CYAML_FIELD_STRING_PTR("name", CYAML_FLAG_POINTER, struct numbers, name, 0,
CYAML_UNLIMITED),
CYAML_FIELD_SEQUENCE("data", CYAML_FLAG_POINTER, struct numbers, data,
&data_entry, 0, CYAML_UNLIMITED),
CYAML_FIELD_END};
static const cyaml_schema_value_t top_schema = {
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, struct numbers, top_mapping_schema),
};
void kubo_file_parse(char *file_name);
#endif