-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsgFormatVerify.cpp
More file actions
83 lines (66 loc) · 2.32 KB
/
msgFormatVerify.cpp
File metadata and controls
83 lines (66 loc) · 2.32 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "msgFormatVerify.h"
// current message formats to veri:e:efy probably should be read from a file for
// logRecordNumber yyyy-mm-dd hh:mm:ss <severity> [scope] [thread] [timing] message ** debug pluse timing
// logRecordNumber yyyy-mm-dd hh:mm:ss <severity> message ** normal logging
msgFormatVerify::msgFormatVerify(const char * filename, const char *regexFile)
{
m_dataFile.open(filename);
boost::filesystem::path p(regexFile);
boost::system::error_code bsyserr;
if (boost::filesystem::exists(p,bsyserr)) {
m_regexFile.open(regexFile);
}else {
m_regexSyn.append(regexFile);
}
}
msgFormatVerify::~msgFormatVerify()
{
//dtor
}
// give a file and a regular expression
// return bool and any lines that don't match
bool msgFormatVerify::compare_syntax(std::vector<std::string> & results)
{
std::string line;
bool rval = m_dataFile.is_open();
m_dataFile.seekg(0,m_dataFile.beg);
boost::regex expr(m_regexSyn.c_str(),boost::regex::perl|boost::match_partial);
boost::cmatch found;
while (getline(m_dataFile,line))
{
if (boost::regex_match(line.c_str(),found,expr )) {
results.push_back(found[2].first);
}else{
rval = false;
results.push_back(found[0].first);
}
}
return rval;
}
// give a file and a file with regular expression and a list of severities
// return bool and any lines that don't match
bool msgFormatVerify::compare_syntax_severity(std::vector<std::string> & results)
{
std::string line;
std::string severity;
bool rval = true;
getline(m_regexFile,m_regexSyn); // read off first line for pattern
boost::regex expr(m_regexSyn.c_str(),boost::regex::perl|boost::match_partial);
boost::cmatch found;
while (getline(m_dataFile,line))
{
if (boost::regex_match(line.c_str(),found,expr) ) {
getline(m_regexFile,severity);
boost::regex svexpr(severity.c_str(), boost::regex::perl|boost::match_partial);
std::string v(found[1].second);
if(boost::regex_match(v.c_str(),found,svexpr)){
results.push_back(line.c_str());
rval=false;
}
}else{
rval = false;
results.push_back(found[0].first);
}
}
return rval;
}