NCBI C++ ToolKit
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CMultiWriter Class Reference

Search Toolkit Book for CMultiWriter

IWriter which can write simultaneously to the different streams. More...

#include <util/multi_writer.hpp>

+ Inheritance diagram for CMultiWriter:
+ Collaboration diagram for CMultiWriter:

Public Member Functions

 CMultiWriter (const list< CNcbiOstream * > &streams)
 
virtual ~CMultiWriter ()
 
virtual ERW_Result Write (const void *buf, size_t count, size_t *bytes_written=0)
 Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device. More...
 
virtual ERW_Result Flush (void)
 Flush pending data (if any) down to the output device. More...
 
- Public Member Functions inherited from IWriter
virtual ~IWriter ()
 

Private Member Functions

 CMultiWriter (const CMultiWriter &)
 
CMultiWriteroperator= (CMultiWriter &)
 

Private Attributes

list< CNcbiOstream * > m_Dest
 

Detailed Description

IWriter which can write simultaneously to the different streams.

Definition at line 49 of file multi_writer.hpp.

Constructor & Destructor Documentation

◆ CMultiWriter() [1/2]

CMultiWriter::CMultiWriter ( const list< CNcbiOstream * > &  streams)
explicit

Definition at line 39 of file multi_writer.cpp.

◆ ~CMultiWriter()

CMultiWriter::~CMultiWriter ( )
virtual

Definition at line 45 of file multi_writer.cpp.

◆ CMultiWriter() [2/2]

CMultiWriter::CMultiWriter ( const CMultiWriter )
private

Member Function Documentation

◆ Flush()

ERW_Result CMultiWriter::Flush ( void  )
virtual

Flush pending data (if any) down to the output device.

Implements IWriter.

Definition at line 61 of file multi_writer.cpp.

References eRW_Success, m_Dest, and NON_CONST_ITERATE.

◆ operator=()

CMultiWriter& CMultiWriter::operator= ( CMultiWriter )
private

◆ Write()

ERW_Result CMultiWriter::Write ( const void *  buf,
size_t  count,
size_t *  bytes_written = 0 
)
virtual

Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.

Always store the number of bytes actually written, or 0 if "count" has been passed as 0 ("buf" must be ignored in this case), via the "bytes_written" pointer, if provided non-NULL. Note that the method can return non-eRW_Success in case of an I/O error along with indicating (some) data delivered to the output device (and reflected in "*bytes_written").

Note
Apparently, may not return eRW_Success if hasn't been able to write "count" bytes as requested, and "bytes_written" was passed as NULL.
When returning "*bytes_written" as zero for a non-zero "count" requested, the return status should not indicate eRW_Success.
Warning
"*bytes_written" may never be returned greater than "count".
Attention
It is implementation-dependent whether the call blocks until the entire buffer or only some data has been written out. In general, it is advised that this call is made within a loop that checks for errors and proceeds with the writing until the required amount of data has been sent.

Implements IWriter.

Definition at line 50 of file multi_writer.cpp.

References buf, eRW_Success, m_Dest, and NON_CONST_ITERATE.

Member Data Documentation

◆ m_Dest

list<CNcbiOstream*> CMultiWriter::m_Dest
private

Definition at line 66 of file multi_writer.hpp.

Referenced by Flush(), and Write().


The documentation for this class was generated from the following files:
Modified on Tue Feb 27 05:55:21 2024 by modify_doxy.py rev. 669887