-
Notifications
You must be signed in to change notification settings - Fork 1
/
MsgParser.cpp
47 lines (32 loc) · 972 Bytes
/
MsgParser.cpp
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
#include "MsgParser.hpp"
using namespace std;
using namespace boost; //using boost to split the string
vector<Msg> MsgParser::parse(std::string msgString) {
vector<string> lines;
vector<Msg> messages;
boost::split( lines, msgString, is_any_of( "\n" ) );
lines.pop_back(); //the last line is always just empty - we don't need it
for(std::vector<string>::iterator line_it = lines.begin(); line_it != lines.end(); ++line_it) { //iterate over each line
Msg msg;
vector<string> fields;
split( fields, *line_it, is_any_of( "\t" ) );
msg.title = fields[0];
msg.actFreq0 = fields[1];
if (msg.title.compare("dme") != 0) {
msg.stbyFreq0 = fields[2];
msg.actFreq1 = (const string) fields[3];
msg.stbyFreq1 = (const string) fields[4];
}
messages.push_back(msg);
}
return messages;
}
MsgParser::MsgParser ()
{
}
MsgParser::MsgParser ( const MsgParser &other )
{
}
MsgParser::~MsgParser ()
{
}