ccdevnet / openc2e

openc2e

This URL has Read+Write access

openc2e / attFile.cpp
100644 40 lines (32 sloc) 0.837 kb
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
#include "attFile.h"
#include <boost/tokenizer.hpp>
using namespace boost;
using namespace std;
 
istream &operator >> (istream &i, attFile &f) {
f.nolines = 0;
 
std::string s;
while (std::getline(i, s)) {
if (s.size() == 0) return i;
assert(f.nolines < 16);
 
f.noattachments[f.nolines] = 0;
 
bool havefirst = false;
unsigned int x;
tokenizer<> tok(s);
for (tokenizer<>::iterator beg = tok.begin(); beg != tok.end(); beg++) {
unsigned int val = atoi(beg->c_str());
if (havefirst) {
f.attachments[f.nolines][f.noattachments[f.nolines] * 2] = x;
f.attachments[f.nolines][(f.noattachments[f.nolines] * 2) + 1] = val;
havefirst = false;
f.noattachments[f.nolines]++;
} else {
havefirst = true;
x = val;
}
}
 
assert(!havefirst);
f.nolines++;
}
 
return i;
}
 
/* vim: set noet: */