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> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 std::ostringstream buffer; | 125 std::ostringstream buffer; |
126 | 126 |
127 // Disallow copying | 127 // Disallow copying |
128 const OutputBuffer& operator=(const OutputBuffer&); | 128 const OutputBuffer& operator=(const OutputBuffer&); |
129 | 129 |
130 template<class T> | 130 template<class T> |
131 OutputBuffer& WriteString(const T& value, ValueType type) | 131 OutputBuffer& WriteString(const T& value, ValueType type) |
132 { | 132 { |
133 WriteBinary(type); | 133 WriteBinary(type); |
134 | 134 |
135 SizeType length = value.size(); | 135 SizeType length = static_cast<SizeType>(value.size()); |
136 WriteBinary(length); | 136 WriteBinary(length); |
137 | 137 |
138 buffer.write(reinterpret_cast<const char*>(value.c_str()), sizeof(T::value
_type) * length); | 138 buffer.write(reinterpret_cast<const char*>(value.c_str()), sizeof(T::value
_type) * length); |
139 if (buffer.fail()) | 139 if (buffer.fail()) |
140 throw new std::runtime_error("Unexpected error writing to output buffer"
); | 140 throw new std::runtime_error("Unexpected error writing to output buffer"
); |
141 | 141 |
142 return *this; | 142 return *this; |
143 } | 143 } |
144 | 144 |
145 template<class T> | 145 template<class T> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 InputBuffer ReadMessage(); | 188 InputBuffer ReadMessage(); |
189 void WriteMessage(OutputBuffer& message); | 189 void WriteMessage(OutputBuffer& message); |
190 | 190 |
191 protected: | 191 protected: |
192 HANDLE pipe; | 192 HANDLE pipe; |
193 }; | 193 }; |
194 } | 194 } |
195 | 195 |
196 #endif | 196 #endif |
OLD | NEW |