| 324 | } |
| 325 | |
| 326 | void |
| 327 | SerialStream::SetCharacterSize(const CharacterSize& characterSize) |
| 328 | try |
| 329 | { |
| 330 | auto my_buffer = dynamic_cast<SerialStreamBuf *>(this->rdbuf()) ; |
| 331 | |
| 332 | // Make sure that we are dealing with a SerialStreamBuf before |
| 333 | // proceeding. This check also makes sure that we have a non-NULL |
| 334 | // buffer associated with this stream. |
| 335 | if (my_buffer != nullptr) |
| 336 | { |
| 337 | // Try to set the character size with the corresponding function of |
| 338 | // the SerialStreamBuf class. |
| 339 | my_buffer->SetCharacterSize(characterSize) ; |
| 340 | } |
| 341 | else |
| 342 | { |
| 343 | // If the dynamic_cast above failed then we either have a NULL |
| 344 | // streambuf associated with this stream or we have a buffer of |
| 345 | // class other than SerialStreamBuf. In either case, we have a |
| 346 | // problem and we should stop all I/O using this stream. |
| 347 | setstate(badbit) ; |
| 348 | } |
| 349 | } |
| 350 | catch (const std::exception&) |
| 351 | { |
| 352 | setstate(std::ios_base::failbit) ; |
| 353 | throw ; |
| 354 | } |
| 355 | |
| 356 | CharacterSize |
| 357 | SerialStream::GetCharacterSize() |