libcsdbg  1.28
C++ exception (and generic) stack trace debug library
streambuf & csdbg::streambuf::operator= ( const streambuf rval)
virtual

Assignment operator.

Parameters
[in]rvalthe assigned object
Returns
*this
Exceptions
std::bad_alloc
csdbg::exception

Definition at line 96 of file streambuf.cpp.

References close(), m_handle, csdbg::string::operator=(), and unlikely.

Referenced by csdbg::filebuf::operator=(), csdbg::sttybuf::operator=(), and csdbg::tcpsockbuf::operator=().

97 {
98  if ( unlikely(this == &rval) )
99  return *this;
100 
101  /* Close the current stream (to sync current data) */
102  close();
103 
104  /* Copy the buffer */
105  string::operator=(rval);
106 
107  i32 fd = rval.m_handle;
108  if ( unlikely(fd < 0) )
109  return *this;
110 
111  /* Duplicate the handle (descriptor) */
112  m_handle = dup(fd);
113  if ( unlikely(m_handle < 0) )
114  throw exception(
115  "failed to duplicate descriptor %d (errno %d - %s)",
116  fd,
117  errno,
118  strerror(errno)
119  );
120 
121  return *this;
122 }
i32 m_handle
Stream handle (descriptor)
Definition: streambuf.hpp:43
virtual string & operator=(const string &)
Assignment operator.
Definition: string.cpp:317
int i32
32-bit signed integer
Definition: config.hpp:82
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
virtual streambuf & close()
Close the stream.
Definition: streambuf.cpp:130

+ Here is the call graph for this function:

+ Here is the caller graph for this function: