Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
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
257
258// clang-format off
259
271
272// clang-format on
273
338
339// clang-format off
340
351
352// clang-format on
353
608
612typedef enum
613{
616
620
639
644typedef union
645{
650 FILE* file;
651
655 struct
656 {
658 uint8_t* data;
660 size_t length;
661 };
662
667 struct
668 {
670 char** lines;
672 size_t lineCount;
673 };
674
679 struct
680 {
682 char* text;
684 size_t textSize;
685 };
686
687 const char * fileName;
689
693typedef struct
694{
699 char* section;
700
704 char* name;
705
709 char* value;
710} optPair_t;
711
719typedef struct
720{
725
731
752
758typedef bool (*processFn_t)(processorInput_t* arg);
759
763typedef struct
764{
766 const char* name;
767
770
773
776
777 union
778 {
781
783 const char* exec;
784 };
786
790typedef struct
791{
793 const char* inExt;
794
796 const char* outExt;
797
800
804
806extern const char* inDirName;
807
809extern const char* outDirName;
810
811#endif
const char * outDirName
The path that is provided for output assets on the command line.
Definition assets_preprocessor.c:61
const char * inDirName
The path that is provided for input assets on the command line.
Definition assets_preprocessor.c:60
const char * fileName
Definition assets_preprocessor.h:687
char * text
Buffer holding text data.
processorType_t type
The type of this asset processor.
Definition assets_preprocessor.h:775
bool(* processFn_t)(processorInput_t *arg)
A function that performs asset processing on a file.
Definition assets_preprocessor.h:758
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:744
char * section
The section name only.
Definition assets_preprocessor.h:699
char * value
The value string.
Definition assets_preprocessor.h:709
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:772
char * name
The key name.
Definition assets_preprocessor.h:704
FILE * file
Holds file handle for FMT_FILE or FMT_FILE_BIN formats.
Definition assets_preprocessor.h:650
const char * inFilename
Holds the input filename for convenience and error reporting.
Definition assets_preprocessor.h:747
processorFormat_t inFmt
The format this processor accepts its input data in. Ignored for exec.
Definition assets_preprocessor.h:769
optPair_t * pairs
The array of options.
Definition assets_preprocessor.h:729
const assetProcessor_t * processor
A pointer to the processor used to transform the files.
Definition assets_preprocessor.h:799
uint8_t * data
Buffer holding binary data.
const char * name
A name for this asset processor, if referenced.
Definition assets_preprocessor.h:766
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:750
const char * inExt
The input file extension to match.
Definition assets_preprocessor.h:793
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:796
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:625
@ FMT_FILE_BIN
An opened file handle (in binary mode) is passed for the file.
Definition assets_preprocessor.h:629
@ FMT_DATA
A buffer containing a file's raw binary data is passed.
Definition assets_preprocessor.h:631
@ FMT_FILENAME
Only provide/use filenames, instead of opening/use them as a file.
Definition assets_preprocessor.h:637
@ FMT_LINES
A text file's data is passed as an array of one string per line.
Definition assets_preprocessor.h:635
@ FMT_FILE
An opened file handle is passed for the file.
Definition assets_preprocessor.h:627
@ FMT_TEXT
A text file's data is passed as an ordinary string.
Definition assets_preprocessor.h:633
const processorFileData_t in
Holds the input data in whichever format was configured for the processor.
Definition assets_preprocessor.h:741
size_t optionCount
The number of options contained in this list.
Definition assets_preprocessor.h:724
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:613
@ EXEC
Processor that executes a shell command to process assets.
Definition assets_preprocessor.h:618
@ FUNCTION
Processor that calls a function pointer to process assets.
Definition assets_preprocessor.h:615
Defines an asset processor.
Definition assets_preprocessor.h:764
Associates an input and output extension to a processor.
Definition assets_preprocessor.h:791
Holds a single key-value pair.
Definition assets_preprocessor.h:694
Holds the input and output data for a single file processing operation.
Definition assets_preprocessor.h:739
Holds a list of key-value option pairs.
Definition assets_preprocessor.h:720
Holds processor input or output data.
Definition assets_preprocessor.h:645