mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-04 14:48:44 +00:00
adding prefixes to source
They'll be removed on demand in libgen repo
This commit is contained in:
+61
-61
@@ -9,98 +9,98 @@
|
||||
////////////////////////////////
|
||||
//~ rjf: Parsed Command Line Types
|
||||
|
||||
typedef struct CmdLineOpt CmdLineOpt;
|
||||
struct CmdLineOpt
|
||||
typedef struct MD_CmdLineOpt MD_CmdLineOpt;
|
||||
struct MD_CmdLineOpt
|
||||
{
|
||||
CmdLineOpt* next;
|
||||
CmdLineOpt* hash_next;
|
||||
U64 hash;
|
||||
String8 string;
|
||||
String8List value_strings;
|
||||
String8 value_string;
|
||||
MD_CmdLineOpt* next;
|
||||
MD_CmdLineOpt* hash_next;
|
||||
MD_U64 hash;
|
||||
MD_String8 string;
|
||||
MD_String8List value_strings;
|
||||
MD_String8 value_string;
|
||||
};
|
||||
|
||||
typedef struct CmdLineOptList CmdLineOptList;
|
||||
struct CmdLineOptList
|
||||
typedef struct MD_CmdLineOptList MD_CmdLineOptList;
|
||||
struct MD_CmdLineOptList
|
||||
{
|
||||
U64 count;
|
||||
CmdLineOpt* first;
|
||||
CmdLineOpt* last;
|
||||
MD_U64 count;
|
||||
MD_CmdLineOpt* first;
|
||||
MD_CmdLineOpt* last;
|
||||
};
|
||||
|
||||
typedef struct CmdLine CmdLine;
|
||||
struct CmdLine
|
||||
typedef struct MD_CmdLine MD_CmdLine;
|
||||
struct MD_CmdLine
|
||||
{
|
||||
String8 exe_name;
|
||||
CmdLineOptList options;
|
||||
String8List inputs;
|
||||
U64 option_table_size;
|
||||
CmdLineOpt** option_table;
|
||||
MD_String8 exe_name;
|
||||
MD_CmdLineOptList options;
|
||||
MD_String8List inputs;
|
||||
MD_U64 option_table_size;
|
||||
MD_CmdLineOpt** option_table;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ NOTE(rjf): Command Line Option Parsing
|
||||
|
||||
U64 cmd_line_hash_from_string(String8 string);
|
||||
MD_API CmdLineOpt** cmd_line_slot_from_string(CmdLine* cmd_line, String8 string);
|
||||
MD_API CmdLineOpt* cmd_line_opt_from_slot (CmdLineOpt** slot, String8 string);
|
||||
void cmd_line_push_opt (CmdLineOptList* list, CmdLineOpt* var);
|
||||
MD_U64 md_cmd_line_hash_from_string(MD_String8 string);
|
||||
MD_API MD_CmdLineOpt** md_cmd_line_slot_from_string(MD_CmdLine* cmd_line, MD_String8 string);
|
||||
MD_API MD_CmdLineOpt* md_cmd_line_opt_from_slot (MD_CmdLineOpt** slot, MD_String8 string);
|
||||
void md_cmd_line_push_opt (MD_CmdLineOptList* list, MD_CmdLineOpt* var);
|
||||
|
||||
CmdLineOpt* cmd_line_opt_from_string (CmdLine* cmd_line, String8 name);
|
||||
String8List cmd_line_strings (CmdLine* cmd_line, String8 name);
|
||||
String8 cmd_line_string (CmdLine* cmd_line, String8 name);
|
||||
B32 cmd_line_has_flag (CmdLine* cmd_line, String8 name);
|
||||
B32 cmd_line_has_argument (CmdLine* cmd_line, String8 name);
|
||||
MD_CmdLineOpt* md_cmd_line_opt_from_string (MD_CmdLine* cmd_line, MD_String8 name);
|
||||
MD_String8List md_cmd_line_strings (MD_CmdLine* cmd_line, MD_String8 name);
|
||||
MD_String8 md_cmd_line_string (MD_CmdLine* cmd_line, MD_String8 name);
|
||||
MD_B32 md_cmd_line_has_flag (MD_CmdLine* cmd_line, MD_String8 name);
|
||||
MD_B32 md_cmd_line_has_argument (MD_CmdLine* cmd_line, MD_String8 name);
|
||||
|
||||
inline CmdLineOpt* cmd_line_insert_opt__arena (Arena* arena, CmdLine* cmd_line, String8 string, String8List values);
|
||||
MD_API CmdLineOpt* cmd_line_insert_opt__ainfo (AllocatorInfo ainfo, CmdLine* cmd_line, String8 string, String8List values);
|
||||
inline CmdLine cmd_line_from_string_list__arena(Arena* arena, String8List arguments);
|
||||
MD_API CmdLine cmd_line_from_string_list__ainfo(AllocatorInfo ainfo, String8List arguments);
|
||||
inline MD_CmdLineOpt* md_cmd_line_insert_opt__arena (MD_Arena* arena, MD_CmdLine* cmd_line, MD_String8 string, MD_String8List values);
|
||||
MD_API MD_CmdLineOpt* md_cmd_line_insert_opt__ainfo (MD_AllocatorInfo ainfo, MD_CmdLine* cmd_line, MD_String8 string, MD_String8List values);
|
||||
inline MD_CmdLine md_cmd_line_from_string_list__arena(MD_Arena* arena, MD_String8List arguments);
|
||||
MD_API MD_CmdLine md_cmd_line_from_string_list__ainfo(MD_AllocatorInfo ainfo, MD_String8List arguments);
|
||||
|
||||
#define cmd_line_insert_opt(allocator, cmd_line, string, values) \
|
||||
#define md_cmd_line_insert_opt(allocator, cmd_line, string, values) \
|
||||
_Generic(allocator, \
|
||||
Arena*: cmd_line_insert_opt__arena, \
|
||||
AllocatorInfo: cmd_line_insert_opt__ainfo, \
|
||||
default: assert_generic_sel_fail \
|
||||
) generic_call(allocator, cmd_line, string, values)
|
||||
MD_Arena*: md_cmd_line_insert_opt__arena, \
|
||||
MD_AllocatorInfo: md_cmd_line_insert_opt__ainfo, \
|
||||
default: md_assert_generic_sel_fail \
|
||||
) md_generic_call(allocator, cmd_line, string, values)
|
||||
|
||||
#define cmd_line_from_string_list(allocator, arguments) \
|
||||
#define md_cmd_line_from_string_list(allocator, arguments) \
|
||||
_Generic(allocator, \
|
||||
Arena*: cmd_line_from_string_list__arena, \
|
||||
AllocatorInfo: cmd_line_from_string_list__ainfo, \
|
||||
default: assert_generic_sel_fail \
|
||||
) generic_call(allocator, arguments)
|
||||
MD_Arena*: md_cmd_line_from_string_list__arena, \
|
||||
MD_AllocatorInfo: md_cmd_line_from_string_list__ainfo, \
|
||||
default: md_assert_generic_sel_fail \
|
||||
) md_generic_call(allocator, arguments)
|
||||
|
||||
inline U64
|
||||
cmd_line_hash_from_string(String8 string) {
|
||||
U64 result = 5381;
|
||||
for(U64 i = 0; i < string.size; i += 1) {
|
||||
inline MD_U64
|
||||
md_cmd_line_hash_from_string(MD_String8 string) {
|
||||
MD_U64 result = 5381;
|
||||
for(MD_U64 i = 0; i < string.size; i += 1) {
|
||||
result = ((result << 5) + result) + string.str[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
force_inline CmdLineOpt* cmd_line_insert_opt__arena (Arena* arena, CmdLine* cmd_line, String8 string, String8List values) { return cmd_line_insert_opt__ainfo (arena_allocator(arena), cmd_line, string, values); }
|
||||
force_inline CmdLine cmd_line_from_string_list__arena(Arena* arena, String8List command_line) { return cmd_line_from_string_list__ainfo(arena_allocator(arena), command_line); }
|
||||
md_force_inline MD_CmdLineOpt* md_cmd_line_insert_opt__arena (MD_Arena* arena, MD_CmdLine* cmd_line, MD_String8 string, MD_String8List values) { return md_cmd_line_insert_opt__ainfo (md_arena_allocator(arena), cmd_line, string, values); }
|
||||
md_force_inline MD_CmdLine md_cmd_line_from_string_list__arena(MD_Arena* arena, MD_String8List command_line) { return md_cmd_line_from_string_list__ainfo(md_arena_allocator(arena), command_line); }
|
||||
|
||||
inline CmdLineOpt* cmd_line_opt_from_string(CmdLine *cmd_line, String8 name) { return cmd_line_opt_from_slot(cmd_line_slot_from_string(cmd_line, name), name); }
|
||||
inline B32 cmd_line_has_flag (CmdLine *cmd_line, String8 name) { CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name); return(var != 0); }
|
||||
inline B32 cmd_line_has_argument (CmdLine *cmd_line, String8 name) { CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name); return(var != 0 && var->value_strings.node_count > 0); }
|
||||
inline MD_CmdLineOpt* md_cmd_line_opt_from_string(MD_CmdLine *cmd_line, MD_String8 name) { return md_cmd_line_opt_from_slot(md_cmd_line_slot_from_string(cmd_line, name), name); }
|
||||
inline MD_B32 md_cmd_line_has_flag (MD_CmdLine *cmd_line, MD_String8 name) { MD_CmdLineOpt *var = md_cmd_line_opt_from_string(cmd_line, name); return(var != 0); }
|
||||
inline MD_B32 md_cmd_line_has_argument (MD_CmdLine *cmd_line, MD_String8 name) { MD_CmdLineOpt *var = md_cmd_line_opt_from_string(cmd_line, name); return(var != 0 && var->value_strings.md_node_count > 0); }
|
||||
|
||||
inline String8List
|
||||
cmd_line_strings(CmdLine *cmd_line, String8 name) {
|
||||
String8List result = {0};
|
||||
CmdLineOpt* var = cmd_line_opt_from_string(cmd_line, name);
|
||||
inline MD_String8List
|
||||
md_cmd_line_strings(MD_CmdLine *cmd_line, MD_String8 name) {
|
||||
MD_String8List result = {0};
|
||||
MD_CmdLineOpt* var = md_cmd_line_opt_from_string(cmd_line, name);
|
||||
if (var != 0) { result = var->value_strings; }
|
||||
return result;
|
||||
}
|
||||
|
||||
inline String8
|
||||
cmd_line_string(CmdLine *cmd_line, String8 name) {
|
||||
String8 result = {0};
|
||||
CmdLineOpt* var = cmd_line_opt_from_string(cmd_line, name);
|
||||
inline MD_String8
|
||||
md_cmd_line_string(MD_CmdLine *cmd_line, MD_String8 name) {
|
||||
MD_String8 result = {0};
|
||||
MD_CmdLineOpt* var = md_cmd_line_opt_from_string(cmd_line, name);
|
||||
if (var != 0) { result = var->value_string; }
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void cmd_line_push_opt(CmdLineOptList* list, CmdLineOpt* var) { sll_queue_push(list->first, list->last, var); list->count += 1; }
|
||||
inline void md_cmd_line_push_opt(MD_CmdLineOptList* list, MD_CmdLineOpt* var) { md_sll_queue_push(list->first, list->last, var); list->count += 1; }
|
||||
|
||||
Reference in New Issue
Block a user