comparison Resources/CodeGeneration/testCppHandler/main.cpp @ 687:342f3e04bfa9 am-dev

CodeGen: test cleanup + all working again + using same yaml and stimuli files
author Alain Mazy <alain@mazy.be>
date Thu, 16 May 2019 17:51:17 +0200
parents 4eccf698e52f
children
comparison
equal deleted inserted replaced
686:0d42bda615a8 687:342f3e04bfa9
6 namespace fs = std::filesystem; 6 namespace fs = std::filesystem;
7 7
8 #include <boost/program_options.hpp> 8 #include <boost/program_options.hpp>
9 using namespace boost::program_options; 9 using namespace boost::program_options;
10 10
11 #include "VsolMessages_generated.hpp" 11 #include "TestStoneCodeGen_generated.hpp"
12 12
13 /** 13 /**
14 Transforms `str` by replacing occurrences of `oldStr` with `newStr`, using 14 Transforms `str` by replacing occurrences of `oldStr` with `newStr`, using
15 plain text (*not* regular expressions.) 15 plain text (*not* regular expressions.)
16 */ 16 */
37 ifs.read(bytes.data(), fileSize); 37 ifs.read(bytes.data(), fileSize);
38 38
39 return string(bytes.data(), fileSize); 39 return string(bytes.data(), fileSize);
40 } 40 }
41 41
42 class MyHandler : public VsolMessages::IHandler 42 class MyHandler : public TestStoneCodeGen::IHandler
43 { 43 {
44 public: 44 public:
45 virtual bool Handle(const VsolMessages::A& value) override 45 virtual bool Handle(const TestStoneCodeGen::A& value) override
46 { 46 {
47 VsolMessages::StoneDumpValue(cout, value); 47 TestStoneCodeGen::StoneDumpValue(cout, value);
48 return true; 48 return true;
49 } 49 }
50 virtual bool Handle(const VsolMessages::B& value) override 50 virtual bool Handle(const TestStoneCodeGen::B& value) override
51 { 51 {
52 VsolMessages::StoneDumpValue(cout, value); 52 TestStoneCodeGen::StoneDumpValue(cout, value);
53 return true; 53 return true;
54 } 54 }
55 virtual bool Handle(const VsolMessages::C& value) override 55 virtual bool Handle(const TestStoneCodeGen::C& value) override
56 { 56 {
57 VsolMessages::StoneDumpValue(cout, value); 57 TestStoneCodeGen::StoneDumpValue(cout, value);
58 return true; 58 return true;
59 } 59 }
60 virtual bool Handle(const VsolMessages::Message1& value) override 60 virtual bool Handle(const TestStoneCodeGen::Message1& value) override
61 { 61 {
62 VsolMessages::StoneDumpValue(cout, value); 62 TestStoneCodeGen::StoneDumpValue(cout, value);
63 return true; 63 return true;
64 } 64 }
65 virtual bool Handle(const VsolMessages::Message2& value) override 65 virtual bool Handle(const TestStoneCodeGen::Message2& value) override
66 { 66 {
67 VsolMessages::StoneDumpValue(cout, value); 67 TestStoneCodeGen::StoneDumpValue(cout, value);
68 return true; 68 return true;
69 } 69 }
70 }; 70 };
71 71
72 template<typename T> 72 template<typename T>
75 cout << "+--------------------------------------------+\n"; 75 cout << "+--------------------------------------------+\n";
76 cout << "| Processing: " << filePath.path().string() << "\n"; 76 cout << "| Processing: " << filePath.path().string() << "\n";
77 cout << "+--------------------------------------------+\n"; 77 cout << "+--------------------------------------------+\n";
78 MyHandler handler; 78 MyHandler handler;
79 auto contents = SlurpFile(filePath.path().string()); 79 auto contents = SlurpFile(filePath.path().string());
80 VsolMessages::StoneDispatchToHandler(contents, &handler); 80 TestStoneCodeGen::StoneDispatchToHandler(contents, &handler);
81 } 81 }
82 82
83 int main(int argc, char** argv) 83 int main(int argc, char** argv)
84 { 84 {
85 try 85 try