Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
assets_preprocessor.h
Go to the documentation of this file.
1#ifndef _ASSETS_PREPROCESSOR_H_
2#define _ASSETS_PREPROCESSOR_H_
3
4#include <stdbool.h>
5#include <stddef.h>
6#include <stdio.h>
7#include <stdint.h>
8
254
255// clang-format off
256
268
269// clang-format on
270
331
332// clang-format off
333
343
344// clang-format on
345
600
604typedef enum
605{
608
612
629
634typedef union
635{
640 FILE* file;
641
645 struct
646 {
648 uint8_t* data;
650 size_t length;
651 };
652
657 struct
658 {
660 char** lines;
662 size_t lineCount;
663 };
664
669 struct
670 {
672 char* text;
674 size_t textSize;
675 };
677
681typedef struct
682{
687 char* section;
688
692 char* name;
693
697 char* value;
698} optPair_t;
699
707typedef struct
708{
713
719
740
746typedef bool (*processFn_t)(processorInput_t* arg);
747
751typedef struct
752{
754 const char* name;
755
758
761
764
765 union
766 {
769
771 const char* exec;
772 };
774
778typedef struct
779{
781 const char* inExt;
782
784 const char* outExt;
785
788
792
793#endif
char * text
Buffer holding text data.
processorType_t type
The type of this asset processor.
Definition assets_preprocessor.h:763
bool(* processFn_t)(processorInput_t *arg)
A function that performs asset processing on a file.
Definition assets_preprocessor.h:746
size_t length
Length of binary data.
processorFileData_t out
Holds the output data in whichever format was configured for the processor.
Definition assets_preprocessor.h:732
char * section
The section name only.
Definition assets_preprocessor.h:687
char * value
The value string.
Definition assets_preprocessor.h:697
const char * exec
An executable command to call for processing matching files.
processorFormat_t outFmt
The format this processor returns its output data in. Ignored for exec.
Definition assets_preprocessor.h:760
char * name
The key name.
Definition assets_preprocessor.h:692
FILE * file
Holds file handle for FMT_FILE or FMT_FILE_BIN formats.
Definition assets_preprocessor.h:640
const char * inFilename
Holds the input filename for convenience and error reporting.
Definition assets_preprocessor.h:735
processorFormat_t inFmt
The format this processor accepts its input data in. Ignored for exec.
Definition assets_preprocessor.h:757
optPair_t * pairs
The array of options.
Definition assets_preprocessor.h:717
const assetProcessor_t * processor
A pointer to the processor used to transform the files.
Definition assets_preprocessor.h:787
uint8_t * data
Buffer holding binary data.
const char * name
A name for this asset processor, if referenced.
Definition assets_preprocessor.h:754
char ** lines
Array of string pointers for each line.
const processorOptions_t * options
Holds a pointer to any configuration options in use for this file.
Definition assets_preprocessor.h:738
const char * inExt
The input file extension to match.
Definition assets_preprocessor.h:781
size_t textSize
The size of the text data, including NUL terminator.
const char * outExt
The output file extension to write.
Definition assets_preprocessor.h:784
processFn_t function
A function to call for processing matching files.
processorFormat_t
The format that this asset processor accepts or returns its data in.
Definition assets_preprocessor.h:617
@ FMT_FILE_BIN
An opened file handle (in binary mode) is passed for the file.
Definition assets_preprocessor.h:621
@ FMT_DATA
A buffer containing a file's raw binary data is passed.
Definition assets_preprocessor.h:623
@ FMT_LINES
A text file's data is passed as an array of one string per line.
Definition assets_preprocessor.h:627
@ FMT_FILE
An opened file handle is passed for the file.
Definition assets_preprocessor.h:619
@ FMT_TEXT
A text file's data is passed as an ordinary string.
Definition assets_preprocessor.h:625
const processorFileData_t in
Holds the input data in whichever format was configured for the processor.
Definition assets_preprocessor.h:729
size_t optionCount
The number of options contained in this list.
Definition assets_preprocessor.h:712
size_t lineCount
The number of string pointers in the array.
processorType_t
Specifies which type of asset processor is being defined.
Definition assets_preprocessor.h:605
@ EXEC
Processor that executes a shell command to process assets.
Definition assets_preprocessor.h:610
@ FUNCTION
Processor that calls a function pointer to process assets.
Definition assets_preprocessor.h:607
Defines an asset processor.
Definition assets_preprocessor.h:752
Associates an input and output extension to a processor.
Definition assets_preprocessor.h:779
Holds a single key-value pair.
Definition assets_preprocessor.h:682
Holds the input and output data for a single file processing operation.
Definition assets_preprocessor.h:727
Holds a list of key-value option pairs.
Definition assets_preprocessor.h:708
Holds processor input or output data.
Definition assets_preprocessor.h:635