-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added utils/resources to split mime-like logic
- Loading branch information
karurochari
committed
Dec 15, 2024
1 parent
7d2f392
commit 1647173
Showing
9 changed files
with
109 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#pragma once | ||
|
||
|
||
#include <utility> | ||
|
||
namespace vs{ | ||
namespace res{ | ||
|
||
//TODO: Move script_t/component_t and possibly more somewhere else | ||
|
||
enum struct script_t{ | ||
NONE, | ||
C, | ||
JS | ||
}; | ||
|
||
enum struct component_t{ | ||
NONE, | ||
VS, | ||
XML, | ||
LIB, | ||
WASM, | ||
RISCV, | ||
CNATIVE, | ||
MARKDOWN, | ||
}; | ||
component_t component_t_i(const char* t); | ||
constexpr const char* component_t_s(component_t t){ | ||
if(t==component_t::NONE)return ""; | ||
else if(t==component_t::VS)return ".vs"; | ||
else if(t==component_t::XML)return ".xml"; | ||
else if(t==component_t::LIB){ | ||
//TODO:Add arch fragment? | ||
# if defined(__linux__) | ||
return ".so"; | ||
# elif defined(_WIN32) || defined(_WIN64) | ||
return ".dll"; | ||
# elif defined(__APPLE__) | ||
return ".dylib"; | ||
# endif | ||
} | ||
else if(t==component_t::WASM)return ".wasm"; | ||
else if(t==component_t::RISCV)return ".riscv"; | ||
else if(t==component_t::CNATIVE)return ".c"; | ||
else if(t==component_t::MARKDOWN)return ".md"; | ||
else return nullptr; | ||
} | ||
|
||
|
||
/** | ||
* @brief In case of a file inclusion without extension, like `this://component`, this function tells which one to look for next. | ||
* | ||
* @return std::pair<bool,component_t> boolean true if a file, false if a file inside the folder. | ||
*/ | ||
std::pair<bool,component_t> next_component_attempt(std::pair<bool,component_t>); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <cstring> | ||
#include <utils/resources.hpp> | ||
|
||
namespace vs{ | ||
namespace res{ | ||
|
||
component_t component_t_i(const char* t){ | ||
if(false); | ||
else if(strcmp(t,".vs")==1)return component_t::VS; | ||
else if(strcmp(t,".xml")==1)return component_t::XML; | ||
else if(strcmp(t,".wasm")==1)return component_t::WASM; | ||
else if(strcmp(t,".riscv")==1)return component_t::RISCV; | ||
# if defined(__linux__) | ||
else if(strcmp(t,".so")==1)return component_t::LIB; | ||
# elif defined(_WIN32) || defined(_WIN64) | ||
else if(strcmp(t,".dll")==1)return component_t::LIB; | ||
# elif defined(__APPLE__) | ||
else if(strcmp(t,".dylib")==1)return component_t::LIB; | ||
# endif | ||
else if(strcmp(t,".c")==1)return component_t::CNATIVE; | ||
else if(strcmp(t,".md")==1)return component_t::MARKDOWN; | ||
else return component_t::NONE; | ||
} | ||
|
||
} | ||
} |