2023-03-07 14:56:13 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "util/FFstrbuf.h"
|
2023-08-17 10:56:54 +08:00
|
|
|
#include "3rdparty/yyjson/yyjson.h"
|
|
|
|
|
|
|
|
|
|
// Must be the first field of FFModuleOptions
|
|
|
|
|
typedef struct FFModuleBaseInfo
|
|
|
|
|
{
|
|
|
|
|
const char* name;
|
2023-08-17 16:00:24 +08:00
|
|
|
bool (*parseCommandOptions)(void* options, const char* key, const char* value);
|
2023-08-17 10:56:54 +08:00
|
|
|
void (*parseJsonObject)(void* options, yyjson_val *module);
|
|
|
|
|
void (*printModule)(void* options);
|
|
|
|
|
} FFModuleBaseInfo;
|
|
|
|
|
|
|
|
|
|
static inline void ffOptionInitModuleBaseInfo(
|
|
|
|
|
FFModuleBaseInfo* baseInfo,
|
|
|
|
|
const char* name,
|
2023-08-17 16:00:24 +08:00
|
|
|
void* parseCommandOptions, // bool (*const parseCommandOptions)(void* options, const char* key, const char* value)
|
2023-08-17 10:56:54 +08:00
|
|
|
void* parseJsonObject, // void (*const parseJsonObject)(void* options, yyjson_val *module)
|
|
|
|
|
void* printModule // void (*const printModule)(void* options)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
baseInfo->name = name;
|
|
|
|
|
baseInfo->parseCommandOptions = parseCommandOptions;
|
|
|
|
|
baseInfo->parseJsonObject = parseJsonObject;
|
|
|
|
|
baseInfo->printModule = printModule;
|
|
|
|
|
}
|
2023-03-07 14:56:13 +08:00
|
|
|
|
|
|
|
|
typedef struct FFModuleArgs
|
|
|
|
|
{
|
|
|
|
|
FFstrbuf key;
|
2023-06-18 12:32:47 +08:00
|
|
|
FFstrbuf keyColor;
|
2023-03-07 14:56:13 +08:00
|
|
|
FFstrbuf outputFormat;
|
2023-08-15 21:40:22 +08:00
|
|
|
uint32_t keyWidth;
|
2023-03-07 14:56:13 +08:00
|
|
|
} FFModuleArgs;
|
|
|
|
|
|
2023-03-10 10:56:36 +08:00
|
|
|
typedef struct FFKeyValuePair
|
|
|
|
|
{
|
|
|
|
|
const char* key;
|
|
|
|
|
int value;
|
|
|
|
|
} FFKeyValuePair;
|
|
|
|
|
|
2023-03-07 14:56:13 +08:00
|
|
|
const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName);
|
|
|
|
|
bool ffOptionParseModuleArgs(const char* argumentKey, const char* pkey, const char* value, FFModuleArgs* result);
|
|
|
|
|
void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer);
|
2023-03-10 10:56:36 +08:00
|
|
|
FF_C_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value);
|
2023-06-25 14:33:13 +08:00
|
|
|
FF_C_NODISCARD int32_t ffOptionParseInt32(const char* argumentKey, const char* value);
|
2023-03-10 10:56:36 +08:00
|
|
|
FF_C_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]);
|
|
|
|
|
FF_C_NODISCARD bool ffOptionParseBoolean(const char* str);
|
2023-06-10 21:34:41 +08:00
|
|
|
void ffOptionParseColor(const char* value, FFstrbuf* buffer);
|
2023-03-07 14:56:13 +08:00
|
|
|
void ffOptionInitModuleArg(FFModuleArgs* args);
|
|
|
|
|
void ffOptionDestroyModuleArg(FFModuleArgs* args);
|