-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimpget.cpp
More file actions
32 lines (29 loc) · 1.09 KB
/
impget.cpp
File metadata and controls
32 lines (29 loc) · 1.09 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
#include <iostream>
#include <fstream>
#include <regex>
#include <string>
void handle_imp_strings(const std::string& input_filename, const std::string& output_filename) {
std::ifstream infile(input_filename);
std::ofstream outfile(output_filename);
std::string line;
std::regex pattern(R"(__imp_[^:]*)"); // matches __imp_ up to but not including '('
while (std::getline(infile, line)) {
std::smatch match;
std::string::const_iterator searchStart(line.cbegin());
while (std::regex_search(searchStart, line.cend(), match, pattern)) {
// Find the position of "("
std::string line2 = match.str();
size_t pos = line2.find('(');
std::cout << pos << std::endl;
if (pos != std::string::npos)
// Erase from position of "(" to end
line2.erase(pos);
outfile << "PPC_FUNC_THROW(" << line2 << ");\n";
searchStart = match.suffix().first;
}
}
}
int main() {
handle_imp_strings("in.txt", "out.txt");
return 0;
}