Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <unordered_map>
- #include <functional>
- struct PrefixObject;
- struct Asset {
- enum Type : int {
- TEXTURE, DERP, BURP, FURP, NONE
- };
- };
- std::unordered_map<Asset::Type, std::vector<std::string>, std::hash<int>> global_pref;
- std::unordered_map<Asset::Type, std::vector<std::string>, std::hash<int>> global_post;
- struct PrefixObject {
- std::vector<std::string> pref;
- PrefixObject operator | (const PrefixObject& other) {
- PrefixObject o;
- for (std::string& s : pref)
- o.pref.push_back(s);
- for (const std::string& s : other.pref)
- o.pref.push_back(s);
- return o;
- }
- Asset::Type operator >> (const Asset::Type& other) {
- for (std::string& s : pref)
- global_pref[other].push_back(s);
- return other;
- }
- };
- Asset::Type operator << (const Asset::Type& t, const PrefixObject& other) {
- for (const std::string& s : other.pref)
- global_post[t].push_back(s);
- return t;
- }
- PrefixObject operator "" _p(const char* s, unsigned int size) {
- return {{std::string(s)}};
- }
- int main() {
- ("images/"_p | "textures/"_p) >> Asset::TEXTURE << (".png"_p | ".jpg"_p | ".dds"_p | ".bmp"_p);
- for (std::string& d : global_pref[Asset::TEXTURE])
- std::cout << d << std::endl;
- std::cout << "--------------------" << std::endl;
- for (std::string& d : global_post[Asset::TEXTURE])
- std::cout << d << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement