blob: 39438faac2573c1702b85eeba496fc321b031ff7 (
plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#include <midillo/event.h>
#include <midillo/util.h>
namespace midillo {
void event_t::load(int& rs,istream& s) {
deltat = readVL(s);
message.load(rs,s);
}
void event_t::save(int& rs,ostream& s) const {
writeVL(s,deltat);
message.save(rs,s);
}
unsigned long event_t::calculate_save_size(int& rs) const {
return calcVLsize(deltat) + message.calculate_save_size(rs);
}
void event_t::dump(ostream& s) const {
std::ios::fmtflags ff = s.flags();
s.unsetf(std::ios::hex); s.setf(std::ios::dec);
s << "deltat=" << deltat << " [" << message << "]";
s.flags(ff);
}
events_t::iterator events_t::append_event() {
static event_t empty;
return insert(end(),empty);
}
void events_t::load(istream& s) {
int rs = -1;
for(;;) {
iterator i=append_event();
i->load(rs,s);
if(i->message.is_meta(meta_EOT))
break;
}
}
void events_t::save(ostream& s) const {
int rs = -1;
for(const_iterator i=begin();i!=end();++i) {
i->save(rs,s);
}
}
unsigned long events_t::calculate_save_size() const {
unsigned long rv = 0;
int rs = -1;
for(const_iterator i=begin();i!=end();++i) {
rv += i->calculate_save_size(rs);
}
return rv;
}
}
|