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

Search Toolkit Book for CStringOrWriter

#include <connect/services/grid_rw_impl.hpp>

+ Inheritance diagram for CStringOrWriter:
+ Collaboration diagram for CStringOrWriter:

Public Types

using TWriterCreate = function< IEmbeddedStreamWriter *(string &)>
 

Public Member Functions

 CStringOrWriter (size_t max_data_size, string &data_ref, TWriterCreate writer_create)
 
ERW_Result Write (const void *buf, size_t count, size_t *bytes_written=0) override
 Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device. More...
 
ERW_Result Flush () override
 Flush pending data (if any) down to the output device. More...
 
void Close () override
 
void Abort () override
 
- Public Member Functions inherited from IWriter
virtual ~IWriter ()
 

Private Attributes

size_t m_MaxDataSize
 
stringm_Data
 
TWriterCreate m_WriterCreate
 
unique_ptr< IEmbeddedStreamWriterm_Writer
 

Detailed Description

Definition at line 45 of file grid_rw_impl.hpp.

Member Typedef Documentation

◆ TWriterCreate

Definition at line 48 of file grid_rw_impl.hpp.

Constructor & Destructor Documentation

◆ CStringOrWriter()

CStringOrWriter::CStringOrWriter ( size_t  max_data_size,
string data_ref,
TWriterCreate  writer_create 
)

Definition at line 51 of file grid_rw_impl.cpp.

References m_Data, and s_JobOutputPrefixEmbedded.

Member Function Documentation

◆ Abort()

void CStringOrWriter::Abort ( void  )
overridevirtual

Implements IEmbeddedStreamWriter.

Definition at line 99 of file grid_rw_impl.cpp.

References m_Writer.

◆ Close()

void CStringOrWriter::Close ( void  )
overridevirtual

Implements IEmbeddedStreamWriter.

Definition at line 94 of file grid_rw_impl.cpp.

References m_Writer.

◆ Flush()

ERW_Result CStringOrWriter::Flush ( )
overridevirtual

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

Implements IWriter.

Definition at line 89 of file grid_rw_impl.cpp.

References eRW_Success, and m_Writer.

◆ Write()

ERW_Result CStringOrWriter::Write ( const void *  buf,
size_t  count,
size_t *  bytes_written = 0 
)
overridevirtual

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 59 of file grid_rw_impl.cpp.

References buf, eRW_Error, eRW_Success, JOB_OUTPUT_PREFIX_LEN, ncbi::grid::netcache::search::fields::key, m_Data, m_MaxDataSize, m_Writer, m_WriterCreate, and s_JobOutputPrefixNetCache.

Referenced by CGridCommandLineInterfaceApp::Cmd_CommitJob().

Member Data Documentation

◆ m_Data

string& CStringOrWriter::m_Data
private

Definition at line 60 of file grid_rw_impl.hpp.

Referenced by CStringOrWriter(), and Write().

◆ m_MaxDataSize

size_t CStringOrWriter::m_MaxDataSize
private

Definition at line 59 of file grid_rw_impl.hpp.

Referenced by Write().

◆ m_Writer

unique_ptr<IEmbeddedStreamWriter> CStringOrWriter::m_Writer
private

Definition at line 62 of file grid_rw_impl.hpp.

Referenced by Abort(), Close(), Flush(), and Write().

◆ m_WriterCreate

TWriterCreate CStringOrWriter::m_WriterCreate
private

Definition at line 61 of file grid_rw_impl.hpp.

Referenced by Write().


The documentation for this class was generated from the following files:
Modified on Fri Jun 14 16:53:31 2024 by modify_doxy.py rev. 669887