18 #include <emscripten.h> 24 void Alert(
const std::string & msg) { EM_ASM_ARGS({ msg = Pointer_stringify($0); alert(msg); }, msg.c_str()); }
26 void Alert(
const std::string & msg) { std::cerr << msg <<
std::endl; }
31 template <
typename... TYPE_SET>
37 template <
typename... TYPE_SET>
39 static size_t cur_count = 0;
50 AlertObj(
const std::string & _msg,
bool _on_c=
true,
bool _on_d=
false)
51 : msg(_msg), on_construct(_on_c), on_destruct(_on_d) {
if (on_construct)
emp::Alert(msg); }
55 void SetMessage(
const std::string & _msg) { msg = _msg; }
void Trigger()
Definition: alert.h:54
std::string to_string(ALL_TYPES &&...all_values)
Definition: string_utils.h:511
bool on_destruct
Should the message print automatically during destruction?
Definition: alert.h:48
static void CappedAlert(size_t cap, TYPE_SET...inputs)
A version of Alert that will cap how many times it can go off.
Definition: alert.h:38
Simple functions to manipulate strings.
void SetMessage(const std::string &_msg)
Definition: alert.h:55
static const PrintStr endl("<br>")
Pre-define emp::endl to insert a "<br>" and thus acting like a newline.
std::string msg
Message for the alert to print.
Definition: alert.h:46
void Alert(const std::string &msg)
Definition: alert.h:29
If we are in emscripten, make sure to include the header.
Definition: array.h:37
~AlertObj()
Definition: alert.h:52
AlertObj(const std::string &_msg, bool _on_c=true, bool _on_d=false)
Definition: alert.h:50
bool on_construct
Should the message print automatically during construction?
Definition: alert.h:47