mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-24 08:27:50 +00:00
moved operating system -> string to base
This commit is contained in:
+36
-11
@@ -1435,6 +1435,35 @@ str32_from_8(Arena *arena, String8 in){
|
||||
return(str32(str, size));
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ String -> Enum Conversions
|
||||
|
||||
read_only global struct
|
||||
{
|
||||
String8 string;
|
||||
OperatingSystem os;
|
||||
} g_os_enum_map[] =
|
||||
{
|
||||
{ str8_lit_comp(""), OperatingSystem_Null },
|
||||
{ str8_lit_comp("Windows"), OperatingSystem_Windows, },
|
||||
{ str8_lit_comp("Linux"), OperatingSystem_Linux, },
|
||||
{ str8_lit_comp("Mac"), OperatingSystem_Mac, },
|
||||
};
|
||||
StaticAssert(ArrayCount(g_os_enum_map) == OperatingSystem_COUNT, g_os_enum_map_count_check);
|
||||
|
||||
internal OperatingSystem
|
||||
operating_system_from_string(String8 string)
|
||||
{
|
||||
for(U64 i = 0; i < ArrayCount(g_os_enum_map); ++i)
|
||||
{
|
||||
if(str8_match(g_os_enum_map[i].string, string, StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
return g_os_enum_map[i].os;
|
||||
}
|
||||
}
|
||||
return OperatingSystem_Null;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Types & Space Enum -> String Conversions
|
||||
|
||||
@@ -1467,18 +1496,14 @@ string_from_side(Side side){
|
||||
}
|
||||
|
||||
internal String8
|
||||
string_from_operating_system(OperatingSystem os){
|
||||
local_persist String8 strings[] = {
|
||||
str8_lit_comp("Null"),
|
||||
str8_lit_comp("Windows"),
|
||||
str8_lit_comp("Linux"),
|
||||
str8_lit_comp("Mac"),
|
||||
};
|
||||
String8 result = str8_lit("error");
|
||||
if (os < OperatingSystem_COUNT){
|
||||
result = strings[os];
|
||||
string_from_operating_system(OperatingSystem os)
|
||||
{
|
||||
String8 result = g_os_enum_map[OperatingSystem_Null].string;
|
||||
if(os < ArrayCount(g_os_enum_map))
|
||||
{
|
||||
result = g_os_enum_map[os].string;
|
||||
}
|
||||
return(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal String8
|
||||
|
||||
@@ -311,6 +311,11 @@ internal String16 str16_from_8(Arena *arena, String8 in);
|
||||
internal String8 str8_from_32(Arena *arena, String32 in);
|
||||
internal String32 str32_from_8(Arena *arena, String8 in);
|
||||
|
||||
////////////////////////////////
|
||||
//~ String -> Enum Conversions
|
||||
|
||||
internal OperatingSystem operating_system_from_string(String8 string);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Types & Space Enum -> String Conversions
|
||||
|
||||
|
||||
@@ -118,24 +118,4 @@ os_file_search(Arena *arena, String8List dir_list, String8 file_path)
|
||||
return match_list;
|
||||
}
|
||||
|
||||
static struct
|
||||
{
|
||||
String8 string;
|
||||
OperatingSystem os;
|
||||
} g_os_map[] = {
|
||||
{ str8_lit_comp("windows"), OperatingSystem_Windows, },
|
||||
{ str8_lit_comp("linux"), OperatingSystem_Linux, },
|
||||
{ str8_lit_comp("mac"), OperatingSystem_Mac, },
|
||||
};
|
||||
|
||||
internal OperatingSystem
|
||||
operating_system_from_string(String8 string)
|
||||
{
|
||||
for (U64 i = 0; i < ArrayCount(g_os_map); ++i) {
|
||||
if (str8_match(g_os_map[i].string, string, StringMatchFlag_CaseInsensitive)) {
|
||||
return g_os_map[i].os;
|
||||
}
|
||||
}
|
||||
return OperatingSystem_Null;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,5 @@ internal String8Array os_data_from_file_path_parallel(TP_Context *tp, Arena *are
|
||||
internal String8List os_file_search(Arena *arena, String8List dir_list, String8 file_path);
|
||||
internal B32 os_folder_path_exists(String8 path);
|
||||
|
||||
internal OperatingSystem operating_system_from_string(String8 string);
|
||||
|
||||
internal B32 os_set_large_pages(B32 toggle);
|
||||
|
||||
internal U32 os_get_process_start_time_unix(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user