! * A helper class to Streams. * This takes care of management of communicating * with the child process with the means of the correct * file descriptor. */
| 1187 | * file descriptor. |
| 1188 | */ |
| 1189 | class Communication |
| 1190 | { |
| 1191 | public: |
| 1192 | Communication(Streams* stream): stream_(stream) |
| 1193 | {} |
| 1194 | Communication(const Communication&) = delete; |
| 1195 | Communication& operator=(const Communication&) = delete; |
| 1196 | Communication(Communication&&) = default; |
| 1197 | Communication& operator=(Communication&&) = default; |
| 1198 | public: |
| 1199 | int send(const char* msg, size_t length); |
| 1200 | int send(const std::vector<char>& msg); |
| 1201 | |
| 1202 | std::pair<OutBuffer, ErrBuffer> communicate(const char* msg, size_t length); |
| 1203 | std::pair<OutBuffer, ErrBuffer> communicate(const std::vector<char>& msg) |
| 1204 | { return communicate(msg.data(), msg.size()); } |
| 1205 | |
| 1206 | void set_out_buf_cap(size_t cap) { out_buf_cap_ = cap; } |
| 1207 | void set_err_buf_cap(size_t cap) { err_buf_cap_ = cap; } |
| 1208 | |
| 1209 | private: |
| 1210 | std::pair<OutBuffer, ErrBuffer> communicate_threaded( |
| 1211 | const char* msg, size_t length); |
| 1212 | |
| 1213 | private: |
| 1214 | Streams* stream_; |
| 1215 | size_t out_buf_cap_ = DEFAULT_BUF_CAP_BYTES; |
| 1216 | size_t err_buf_cap_ = DEFAULT_BUF_CAP_BYTES; |
| 1217 | }; |
| 1218 | |
| 1219 | |
| 1220 |
nothing calls this directly
no outgoing calls
no test coverage detected