Logo Search packages:      
Sourcecode: libserial version File versions  Download package

streambuf::int_type SerialStreamBuf::pbackfail ( int_type  c = traits_type::eof()  )  [protected, virtual]

This function is called when a putback of a character fails. This must be implemented for unbuffered I/O as all streambuf subclasses are required to provide putback of at lease on character.

Definition at line 913 of file SerialStreamBuf.cc.

References mFileDescriptor, mPutbackAvailable, and mPutbackChar.

                                     {
    //
    // If we do not have a valid file descriptor, then we return eof. 
    //
    if( -1 == mFileDescriptor ) {
        return traits_type::eof() ;
    }
    //
    // If a putback character is already available, then we cannot
    // do any more putback and hence need to return eof.
    //
    if( mPutbackAvailable ) {
        return traits_type::eof() ;
    } else if ( traits_type::eq_int_type(c, traits_type::eof()) ) {
        //
        // If an eof character is passed in, then we are required to
        // backup one character. However, we cannot do this for a serial
        // port. Hence we return eof to signal an error.
        //
        return traits_type::eof() ;
    } else {
        //
        // If no putback character is available at present, then make
        // c the putback character and return it. 
        //
        mPutbackChar = traits_type::to_char_type(c) ;
        mPutbackAvailable = true ;
        return traits_type::not_eof(c) ;
    }
}


Generated by  Doxygen 1.6.0   Back to index