73 lines
2.1 KiB
C
73 lines
2.1 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>
|
|
|
|
#include "kubo_context.h"
|
|
#include "kubo_wall.h"
|
|
|
|
typedef int 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;
|
|
};
|
|
|
|
static const cyaml_schema_value_t int_entry = {
|
|
CYAML_VALUE_INT(CYAML_FLAG_DEFAULT, int),
|
|
};
|
|
|
|
static const cyaml_schema_value_t vertex_entry = {
|
|
CYAML_VALUE_SEQUENCE_FIXED(CYAML_FLAG_DEFAULT, int, &int_entry, 2),
|
|
};
|
|
|
|
static const cyaml_schema_field_t wall_fields[] = {
|
|
CYAML_FIELD_SEQUENCE("vertices", CYAML_FLAG_POINTER, struct kubo_file_wall,
|
|
vertices, &vertex_entry, 0, CYAML_UNLIMITED),
|
|
CYAML_FIELD_END
|
|
};
|
|
|
|
static const cyaml_schema_value_t wall_schema = {
|
|
CYAML_VALUE_MAPPING(CYAML_FLAG_DEFAULT, struct kubo_file_wall, wall_fields),
|
|
};
|
|
|
|
static const cyaml_schema_field_t scene_fields[] = {
|
|
CYAML_FIELD_SEQUENCE("walls", CYAML_FLAG_POINTER, struct kubo_file_scene,
|
|
walls, &wall_schema, 0, CYAML_UNLIMITED),
|
|
CYAML_FIELD_END
|
|
};
|
|
|
|
static const cyaml_schema_value_t top_schema = {
|
|
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, struct kubo_file_scene,
|
|
scene_fields),
|
|
};
|
|
|
|
struct kubo_context kubo_file_parse(char *file_name);
|
|
void kubo_file_write(struct kubo_context *context);
|
|
|
|
#endif
|