-
Notifications
You must be signed in to change notification settings - Fork 5
/
rv_summarizer.cpp
58 lines (44 loc) · 1.18 KB
/
rv_summarizer.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
47
48
49
50
51
52
53
54
55
56
57
58
#include "rv_summarizer.h"
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
std::stringstream ss(s);
std::string item;
while (std::getline(ss, item, delim)) {
elems.push_back(item);
}
return elems;
}
std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
split(s, delim, elems);
return elems;
}
RVSummarizer::RVSummarizer(const string& func, const string& file_path, RVCommands* rv_commands, int side)
{
rv_commands->runSummarizer(func, file_path, side);
convertSummarizerResults(func);
}
RVSummarizer::~RVSummarizer(void)
{
}
void RVSummarizer::convertSummarizerResults( const string& func )
{
string fileName(func + ".sumres");
std::ifstream infile(fileName);
std::string line;
while (std::getline(infile, line))
{
addLineToMap(line);
}
}
void RVSummarizer::addLineToMap( const std::string& line )
{
std::vector<string> splittedLine = split(line, ':');
func_to_summary[splittedLine[0]] = splittedLine[1];
}
string RVSummarizer::getSummary( string name )
{
if (func_to_summary.find( name ) != func_to_summary.end()){
return func_to_summary[name];
}
else return "1";
}