#pragma once #include #include #include #include using std::map; using std::string; using std::variant; typedef variant ArgumentVariant; typedef map ArgumentMap; #include "blur.h" #include "bounce.h" #include "caption.h" #include "caption2.h" #include "circle.h" #include "colors.h" #include "crop.h" #include "deepfry.h" #include "explode.h" #include "flag.h" #include "flip.h" #include "freeze.h" #include "gamexplain.h" #include "globe.h" #include "homebrew.h" #include "invert.h" #include "jpeg.h" #include "magik.h" #include "meme.h" #include "mirror.h" #include "motivate.h" #include "reddit.h" #include "resize.h" #include "reverse.h" #include "scott.h" #include "snapchat.h" #include "sonic.h" #include "speed.h" #include "spin.h" #include "squish.h" #include "swirl.h" #include "tile.h" #include "togif.h" #include "uncanny.h" #include "uncaption.h" #include "wall.h" #include "watermark.h" #include "whisper.h" #include "zamn.h" template T GetArgument(ArgumentMap map, string key) { try { return std::get(map.at(key)); } catch (std::bad_variant_access&) { throw "Invalid requested type from variant."; } } template T GetArgumentWithFallback(ArgumentMap map, string key, T fallback) { try { return std::get(map.at(key)); } catch (...) { // this is, not great... return fallback; } } #define MAP_HAS(ARRAY, KEY) (ARRAY.count(KEY) > 0) #define MAP_GET(ARRAY, KEY, TYPE) \ (MAP_HAS(ARRAY, KEY) ? get(ARRAY.at(KEY)) \ : NULL) // C++ has forced my hand #define MAP_GET_FALLBACK(ARRAY, KEY, TYPE, FALLBACK) \ (MAP_HAS(ARRAY, KEY) ? get(ARRAY.at(KEY)) : FALLBACK) #define ARG_TYPES std::variant const std::unordered_map fontPaths{ {"futura", "assets/fonts/caption.otf"}, {"helvetica", "assets/fonts/caption2.ttf"}, {"roboto", "assets/fonts/reddit.ttf"}}; const std::map FunctionMap = {{"blur", &Blur}, {"bounce", &Bounce}, {"caption", &Caption}, {"captionTwo", &CaptionTwo}, {"circle", &Circle}, {"colors", &Colors}, {"crop", &Crop}, {"deepfry", &Deepfry}, {"explode", &Explode}, {"flag", &Flag}, {"flip", &Flip}, {"freeze", &Freeze}, {"gamexplain", Gamexplain}, {"globe", Globe}, {"invert", Invert}, {"jpeg", Jpeg}, {"magik", Magik}, {"meme", Meme}, {"mirror", Mirror}, {"motivate", Motivate}, {"reddit", Reddit}, {"resize", Resize}, {"reverse", Reverse}, {"scott", Scott}, {"snapchat", Snapchat}, {"speed", &Speed}, {"spin", Spin}, {"squish", Squish}, {"swirl", Swirl}, {"tile", Tile}, {"togif", ToGif}, {"uncanny", Uncanny}, {"uncaption", &Uncaption}, {"wall", Wall}, {"watermark", &Watermark}, {"whisper", Whisper}, {"zamn", Zamn}}; const std::map NoInputFunctionMap = {{"homebrew", Homebrew}, {"sonic", Sonic}};