| 868 | } |
| 869 | |
| 870 | int |
| 871 | SerialStream::GetNumberOfBytesAvailable() |
| 872 | try |
| 873 | { |
| 874 | auto my_buffer = dynamic_cast<SerialStreamBuf *>(this->rdbuf()) ; |
| 875 | |
| 876 | // Make sure that we are dealing with a SerialStreamBuf before |
| 877 | // proceeding. This check also makes sure that we have a non-NULL |
| 878 | // buffer associated with this stream. |
| 879 | if (my_buffer != nullptr) |
| 880 | { |
| 881 | // Try to determine if data is available with the correspoding |
| 882 | // function of the SerialStreamBuf class. |
| 883 | return my_buffer->GetNumberOfBytesAvailable() ; |
| 884 | } |
| 885 | // If the dynamic_cast above failed then we either have a NULL |
| 886 | // streambuf associated with this stream or we have a buffer |
| 887 | // of class other than SerialStreamBuf. In either case, we |
| 888 | // have a problem and we should stop all I/O using this stream. |
| 889 | setstate(badbit) ; |
| 890 | return -1 ; |
| 891 | } |
| 892 | catch (const std::exception&) |
| 893 | { |
| 894 | setstate(std::ios_base::failbit) ; |
| 895 | throw ; |
| 896 | } |
| 897 | |
| 898 | std::vector<std::string> |
| 899 | SerialStream::GetAvailableSerialPorts() |
nothing calls this directly
no outgoing calls
no test coverage detected