| 354 | } |
| 355 | |
| 356 | CharacterSize |
| 357 | SerialStream::GetCharacterSize() |
| 358 | try |
| 359 | { |
| 360 | auto my_buffer = dynamic_cast<SerialStreamBuf *>(this->rdbuf()) ; |
| 361 | |
| 362 | // Make sure that we are dealing with a SerialStreamBuf before |
| 363 | // proceeding. This check also makes sure that we have a non-NULL |
| 364 | // buffer associated with this stream. |
| 365 | if (my_buffer != nullptr) |
| 366 | { |
| 367 | // Try to get the character size. If the corresponding function of the |
| 368 | // SerialStreamBuf class returns CHAR_SIZE_INVALID, then we have a |
| 369 | // problem and the stream is no longer valid for I/O. |
| 370 | return my_buffer->GetCharacterSize() ; |
| 371 | } |
| 372 | // If the dynamic_cast above failed then we either have a NULL |
| 373 | // streambuf associated with this stream or we have a buffer of |
| 374 | // class other than SerialStreamBuf. In either case, we have a |
| 375 | // problem and we should stop all I/O using this stream. |
| 376 | setstate(badbit) ; |
| 377 | return CharacterSize::CHAR_SIZE_INVALID; |
| 378 | } |
| 379 | catch (const std::exception&) |
| 380 | { |
| 381 | setstate(std::ios_base::failbit) ; |
| 382 | throw ; |
| 383 | } |
| 384 | |
| 385 | void |
| 386 | SerialStream::SetFlowControl(const FlowControl& flowControlType) |
nothing calls this directly
no outgoing calls
no test coverage detected