#ifndef FLUTTER_INAPPWEBVIEW_PLUGIN_UTIL_H_ #define FLUTTER_INAPPWEBVIEW_PLUGIN_UTIL_H_ #include #include #include #include #include "strconv.h" namespace flutter_inappwebview_plugin { static inline void debugLog(const std::string& msg) { #ifndef NDEBUG std::cout << msg << std::endl; OutputDebugString(ansi_to_wide(msg + "\n").c_str()); #endif } template static inline std::optional make_pointer_optional(const T* value) { return value == nullptr ? std::nullopt : std::make_optional(*value); } static inline std::string variant_to_string(const std::variant& var) { return std::visit([](auto&& arg) { using T = std::decay_t; if constexpr (std::is_same_v) return arg; else if constexpr (std::is_arithmetic_v) return std::to_string(arg); else static_assert(always_false_v, "non-exhaustive visitor!"); }, var); } template static inline bool map_contains(const std::map& map, const K& key) { return map.find(key) != map.end(); } template static inline T map_at_or_null(const std::map& map, const K& key) { auto itr = map.find(key); return itr != map.end() ? itr->second : nullptr; } } #endif //FLUTTER_INAPPWEBVIEW_PLUGIN_UTIL_H_