50 typename T::AssetType;
52 { T::Load(path) } -> std::same_as<std::shared_ptr<typename T::AssetType>>;
55 { T::Save(asset, path) } -> std::same_as<void>;
58 { T::Import(path) } -> std::same_as<std::shared_ptr<typename T::AssetType>>;
61 { T::GetHandledType() } -> std::same_as<std::string>;
66 typedef std::unordered_map<std::string, ExtensionHandler*> ExtensionHandlerMap;
67 static inline ExtensionHandlerMap HandlerMap = ExtensionHandlerMap(25);
70 static std::vector<std::string> ParseExtensions(
const std::string& extPostfix) {
71 std::stringstream ss(extPostfix);
72 std::string extension;
73 std::vector<std::string> extensions;
75 while (std::getline(ss, extension,
'|')) {
76 extension.erase(0, extension.find_first_not_of(
" \t\n\r\f\v"));
77 extension.erase(extension.find_last_not_of(
" \t\n\r\f\v") + 1);
78 extensions.push_back(extension);
86 std::string extension;
88 while (std::getline(ss, extension,
'|')) {
90 extension.erase(0, extension.find_first_not_of(
" \t\n\r\f\v"));
91 extension.erase(extension.find_last_not_of(
" \t\n\r\f\v") + 1);
94 HandlerMap[extension] = ext.
Handler;
99 size_t dotPos = path.find_last_of(
'.');
100 if (dotPos == std::string::npos) {
102 static IOBuffer NULLBUF(
nullptr, 0);
105 auto& handler = HandlerMap[path.substr(dotPos + 1)];
107 return handler->Read(path);