/
message.hpp
39 lines (29 loc) · 917 Bytes
/
message.hpp
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
#ifndef MESSAGE_HPP
#define MESSAGE_HPP
#include "message_header.hpp"
#include "message_body.hpp"
#include <iostream>
class message {
public:
static message from_string(std::string);
static message from_body(uint32_t addr, uint8_t flags, message_body *body);
message(message_header *header, message_body *body) :
_header(header), _body(body) { }
~message() {
delete _header;
delete _body;
}
std::string to_string() const {
return _header->to_string() + _body->to_string();
}
message_header *header() const { return _header; }
message_body *body() const { return _body; }
bool operator==(const message &other) {
return *(body()) == *(other.body()) && *(header()) == *(other.header());
}
bool operator!=(const message &other) { return !(*this==other); }
private:
message_header *_header;
message_body *_body;
};
#endif