-
Notifications
You must be signed in to change notification settings - Fork 1
/
out.c++
29 lines (23 loc) · 916 Bytes
/
out.c++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#import "out.h"
#import "str.h"
#import "rmr.h"
using _ = out_t&;
out_t::out_t() : used(false), null(false), last(true), fatal(false) { }
out_t::out_t(out_t& _) : out_t() { _.last = false; used = _.used; fatal = _.fatal; null = _.null; }
out_t::out_t(out_t&& _) : out_t() { _.last = false; used = _.used; fatal = _.fatal; null = _.null; }
_ out_t::operator<<(str_t _) {
if (!null && rmr.loglevel() >= 0) cerr << _.str() << " ";
used = true;
return *this;
}
_ out_t::operator,(str_t _) { return *this << _; }
_ out_t::arm() { fatal = true; return *this; }
_ out_t::disarm() { fatal = false; return *this; }
_ out_t::off() { null = true; return *this; }
_ out_t::on() { null = false; return *this; }
out_t::operator bool() { return true; }
out_t::~out_t() {
if (last && used && !null) cerr << rmr_t::ansi_clear() << endl;
cerr.flush();
if (last && fatal) rmr_t::die("out_t: fatal");
}