OLD | NEW |
1 #ifndef COMMUNICATION_H | 1 #ifndef COMMUNICATION_H |
2 #define COMMUNICATION_H | 2 #define COMMUNICATION_H |
3 | 3 |
4 #include <memory> | 4 #include <memory> |
5 #include <sstream> | 5 #include <sstream> |
6 #include <stdexcept> | 6 #include <stdexcept> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include <Windows.h> | 10 #include <Windows.h> |
11 | 11 |
12 namespace Communication | 12 namespace Communication |
13 { | 13 { |
14 extern const std::wstring pipeName; | 14 extern const std::wstring pipeName; |
15 const int bufferSize = 1024; | 15 const int bufferSize = 1024; |
16 | 16 |
17 enum ValueType {TYPE_STRING, TYPE_WSTRING, TYPE_INT64, TYPE_INT32, TYPE_BOOL}; | 17 enum ValueType {TYPE_STRING, TYPE_WSTRING, TYPE_INT64, TYPE_INT32, TYPE_BOOL}; |
18 | 18 |
19 class InputBuffer | 19 class InputBuffer |
20 { | 20 { |
21 public: | 21 public: |
22 InputBuffer(const std::string& data) : buffer(data) {} | 22 InputBuffer(const std::string& data) : buffer(data), hasType(false) {} |
23 InputBuffer& operator>>(std::string& value) { return ReadString(value, TYPE_
STRING); } | 23 InputBuffer& operator>>(std::string& value) { return ReadString(value, TYPE_
STRING); } |
24 InputBuffer& operator>>(std::wstring& value) { return ReadString(value, TYPE
_WSTRING); } | 24 InputBuffer& operator>>(std::wstring& value) { return ReadString(value, TYPE
_WSTRING); } |
25 InputBuffer& operator>>(int64_t& value) { return Read(value, TYPE_INT64); } | 25 InputBuffer& operator>>(int64_t& value) { return Read(value, TYPE_INT64); } |
26 InputBuffer& operator>>(int32_t& value) { return Read(value, TYPE_INT32); } | 26 InputBuffer& operator>>(int32_t& value) { return Read(value, TYPE_INT32); } |
27 InputBuffer& operator>>(bool& value) { return Read(value, TYPE_BOOL); } | 27 InputBuffer& operator>>(bool& value) { return Read(value, TYPE_BOOL); } |
28 private: | 28 private: |
29 std::istringstream buffer; | 29 std::istringstream buffer; |
30 int32_t currentType; | 30 int32_t currentType; |
31 bool hasType; | 31 bool hasType; |
32 | 32 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 InputBuffer ReadMessage(); | 148 InputBuffer ReadMessage(); |
149 void WriteMessage(OutputBuffer& message); | 149 void WriteMessage(OutputBuffer& message); |
150 | 150 |
151 protected: | 151 protected: |
152 HANDLE pipe; | 152 HANDLE pipe; |
153 }; | 153 }; |
154 } | 154 } |
155 | 155 |
156 #endif | 156 #endif |
OLD | NEW |