Mercurial > hg > orthanc-stone
annotate Resources/CodeGeneration/testCppHandler/main.cpp @ 1284:1bb54005e2bd bugs/2020-02-invisible-slice
merged default into branch
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 11 Feb 2020 14:38:36 +0100 |
parents | 342f3e04bfa9 |
children |
rev | line source |
---|---|
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
1 #include <string> |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
2 #include <fstream> |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
3 #include <filesystem> |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
4 #include <regex> |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
5 using namespace std; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
6 namespace fs = std::filesystem; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
7 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
8 #include <boost/program_options.hpp> |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
9 using namespace boost::program_options; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
10 |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
11 #include "TestStoneCodeGen_generated.hpp" |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
12 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
13 /** |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
14 Transforms `str` by replacing occurrences of `oldStr` with `newStr`, using |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
15 plain text (*not* regular expressions.) |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
16 */ |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
17 static inline void ReplaceInString( |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
18 string& str, |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
19 const std::string& oldStr, |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
20 const std::string& newStr) |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
21 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
22 std::string::size_type pos = 0u; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
23 while ((pos = str.find(oldStr, pos)) != std::string::npos) { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
24 str.replace(pos, oldStr.length(), newStr); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
25 pos += newStr.length(); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
26 } |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
27 } |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
28 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
29 string SlurpFile(const string& fileName) |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
30 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
31 ifstream ifs(fileName.c_str(), ios::in | ios::binary | ios::ate); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
32 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
33 ifstream::pos_type fileSize = ifs.tellg(); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
34 ifs.seekg(0, ios::beg); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
35 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
36 vector<char> bytes(fileSize); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
37 ifs.read(bytes.data(), fileSize); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
38 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
39 return string(bytes.data(), fileSize); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
40 } |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
41 |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
42 class MyHandler : public TestStoneCodeGen::IHandler |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
43 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
44 public: |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
45 virtual bool Handle(const TestStoneCodeGen::A& value) override |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
46 { |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
47 TestStoneCodeGen::StoneDumpValue(cout, value); |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
48 return true; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
49 } |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
50 virtual bool Handle(const TestStoneCodeGen::B& value) override |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
51 { |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
52 TestStoneCodeGen::StoneDumpValue(cout, value); |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
53 return true; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
54 } |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
55 virtual bool Handle(const TestStoneCodeGen::C& value) override |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
56 { |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
57 TestStoneCodeGen::StoneDumpValue(cout, value); |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
58 return true; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
59 } |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
60 virtual bool Handle(const TestStoneCodeGen::Message1& value) override |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
61 { |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
62 TestStoneCodeGen::StoneDumpValue(cout, value); |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
63 return true; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
64 } |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
65 virtual bool Handle(const TestStoneCodeGen::Message2& value) override |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
66 { |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
67 TestStoneCodeGen::StoneDumpValue(cout, value); |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
68 return true; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
69 } |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
70 }; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
71 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
72 template<typename T> |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
73 void ProcessPath(T filePath) |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
74 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
75 cout << "+--------------------------------------------+\n"; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
76 cout << "| Processing: " << filePath.path().string() << "\n"; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
77 cout << "+--------------------------------------------+\n"; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
78 MyHandler handler; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
79 auto contents = SlurpFile(filePath.path().string()); |
687
342f3e04bfa9
CodeGen: test cleanup + all working again + using same yaml and stimuli files
Alain Mazy <alain@mazy.be>
parents:
653
diff
changeset
|
80 TestStoneCodeGen::StoneDispatchToHandler(contents, &handler); |
653
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
81 } |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
82 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
83 int main(int argc, char** argv) |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
84 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
85 try |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
86 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
87 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
88 options_description desc("Allowed options"); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
89 desc.add_options() |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
90 // First parameter describes option name/short name |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
91 // The second is parameter to option |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
92 // The third is description |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
93 ("help,h", "print usage message") |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
94 ("pattern,p", value<string>(), "pattern for input") |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
95 ; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
96 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
97 variables_map vm; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
98 store(parse_command_line(argc, argv, desc), vm); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
99 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
100 if (vm.count("help")) |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
101 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
102 cout << desc << "\n"; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
103 return 0; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
104 } |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
105 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
106 notify(vm); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
107 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
108 string pattern = vm["pattern"].as<string>(); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
109 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
110 // tranform globbing pattern into regex |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
111 // we should deal with -, ., *... |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
112 string regexPatternStr = pattern; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
113 cout << "Pattern is: " << regexPatternStr << endl; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
114 ReplaceInString(regexPatternStr, "\\", "\\\\"); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
115 ReplaceInString(regexPatternStr, "-", "\\-"); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
116 ReplaceInString(regexPatternStr, ".", "\\."); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
117 ReplaceInString(regexPatternStr, "*", ".*"); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
118 ReplaceInString(regexPatternStr, "?", "."); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
119 cout << "Corresponding regex is: " << regexPatternStr << endl; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
120 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
121 regex regexPattern(regexPatternStr); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
122 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
123 for (auto& p : fs::directory_iterator(".")) |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
124 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
125 auto fileName = p.path().filename().string(); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
126 if (regex_match(fileName, regexPattern)) |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
127 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
128 ProcessPath(p); |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
129 } |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
130 } |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
131 return 0; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
132 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
133 |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
134 } |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
135 catch (exception& e) |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
136 { |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
137 cerr << e.what() << "\n"; |
4eccf698e52f
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
495
diff
changeset
|
138 } |
494
fc17251477d6
TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
bgo-osimis
parents:
diff
changeset
|
139 } |