Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 69 additions & 23 deletions code/logic/fossil/io/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,86 @@ extern "C" {

// Types of command argument
typedef enum {
FOSSIL_IO_PARSER_BOOL, // Boolean (enable/disable)
FOSSIL_IO_PARSER_STRING, // String argument
FOSSIL_IO_PARSER_INT, // Integer argument
FOSSIL_IO_PARSER_FLOAT, // Floating-point argument
FOSSIL_IO_PARSER_DATE, // Date argument
FOSSIL_IO_PARSER_ARRAY, // Array of values
FOSSIL_IO_PARSER_FEATURE, // Feature flag
FOSSIL_IO_PARSER_INVALID // Invalid argument type
// Boolean / Flag Types
FOSSIL_IO_PARSER_BOOL, // Boolean (enable/disable)
FOSSIL_IO_PARSER_FLAG, // Simple flag (on/off, no value)
FOSSIL_IO_PARSER_TOGGLE, // Explicit enable/disable toggle

// String Types
FOSSIL_IO_PARSER_STRING, // Generic string
FOSSIL_IO_PARSER_FILE, // File path
FOSSIL_IO_PARSER_DIR, // Directory path
FOSSIL_IO_PARSER_REGEX, // Regular expression
FOSSIL_IO_PARSER_ENUM, // Strict set of options
FOSSIL_IO_PARSER_JSON, // JSON string
FOSSIL_IO_PARSER_BASE64, // Base64-encoded string
FOSSIL_IO_PARSER_URL, // URL string
FOSSIL_IO_PARSER_IP, // IPv4/IPv6

// Numeric Types
FOSSIL_IO_PARSER_INT, // Signed integer
FOSSIL_IO_PARSER_UINT, // Unsigned integer
FOSSIL_IO_PARSER_HEX, // Hexadecimal integer (0x prefix)
FOSSIL_IO_PARSER_OCT, // Octal integer (0 prefix)
FOSSIL_IO_PARSER_BIN, // Binary integer (0b prefix)
FOSSIL_IO_PARSER_FLOAT, // Floating-point number
FOSSIL_IO_PARSER_DOUBLE, // Double precision floating-point
FOSSIL_IO_PARSER_SIZE, // Size values (e.g., 10K, 2M)
FOSSIL_IO_PARSER_PERCENT, // Percentage (0-100%)

// Time / Date Types
FOSSIL_IO_PARSER_DATE, // Date (YYYY-MM-DD)
FOSSIL_IO_PARSER_TIMESTAMP, // Timestamp (YYYY-MM-DD HH:MM:SS)
FOSSIL_IO_PARSER_DURATION, // Duration (e.g., 1h30m, 45s)

// Collection Types
FOSSIL_IO_PARSER_ARRAY, // Array of values
FOSSIL_IO_PARSER_LIST, // List of values
FOSSIL_IO_PARSER_MAP, // Key-value pairs

// Feature / Option Types
FOSSIL_IO_PARSER_FEATURE, // Feature flag
FOSSIL_IO_PARSER_COMBO, // Select from predefined options

// Invalid / Sentinel
FOSSIL_IO_PARSER_INVALID // Invalid argument type
} fossil_io_parser_arg_type_t;

// Structure to represent each argument in the command
typedef union fossil_io_parser_value_u {
int i;
unsigned int u;
long l;
float f;
double d;
char *s;
char **arr;
void *ptr; // For MAP or JSON structures
} fossil_io_parser_value_t;

typedef struct fossil_io_parser_argument_s {
char *name; // Argument name
fossil_io_parser_arg_type_t type; // Argument type
char *value; // Parsed value
char **combo_options; // Valid options for COMBO type
int combo_count; // Number of valid options
struct fossil_io_parser_argument_s *next; // Next argument in the list
char *name;
char short_name;
fossil_io_parser_arg_type_t type;
fossil_io_parser_value_t value;
char **combo_options;
int combo_count;
struct fossil_io_parser_argument_s *next;
} fossil_io_parser_argument_t;

// Structure for a command
typedef struct fossil_io_parser_command_s {
char *name; // Command name
char *description; // Command description
fossil_io_parser_argument_t *arguments; // List of arguments
struct fossil_io_parser_command_s *prev; // Previous command in the list
struct fossil_io_parser_command_s *next; // Next command in the list
char *name; // Command name
char *description; // Command description
fossil_io_parser_argument_t *arguments; // List of arguments
struct fossil_io_parser_command_s *prev; // Previous command in the list
struct fossil_io_parser_command_s *next; // Next command in the list
} fossil_io_parser_command_t;

// Structure for the command palette
typedef struct fossil_io_parser_palette_s {
char *name; // Palette name
char *description; // Palette description
fossil_io_parser_command_t *commands; // List of commands
char *name; // Palette name
char *description; // Palette description
fossil_io_parser_command_t *commands; // List of commands
} fossil_io_parser_palette_t;

// ==================================================================
Expand Down
Loading
Loading