Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cStreamOutput Class Reference

#include <cStream.h>

Inheritance diagram for Gray::cStreamOutput:
Gray::cStreamBase Gray::cAppConsole Gray::cLogProcessor Gray::cStream GrayLib::cAVControlInp GrayLib::cLogFileDay GrayLib::cMailslotWriter GrayLib::cOSPipeClient GrayLib::cWaveStreamOut GrayLib::cXProtocolServerStream GrayX::cCmdTail

Public Member Functions

 cStreamOutput () noexcept
 
virtual ~cStreamOutput ()
 
virtual HRESULT WriteX (const void *pData, size_t nDataSize)
 
HRESULT WriteT (const void *pVal, size_t nDataSize)
 
template<typename TYPE >
HRESULT WriteT (TYPE val)
 
HRESULT WriteSize (size_t nSize)
 
HRESULT WriteHashCode (HASHCODE_t nHashCode)
 
HRESULT WriteN (const void *pBuffer, size_t nSize)
 
template<typename _CH >
HRESULT WriteStringN (const _CH *pszStr)
 
template<typename _CH >
HRESULT WriteCharRepeat (_CH nChar, int nCount=1)
 
virtual HRESULT WriteString (const char *pszStr)
 
virtual HRESULT WriteString (const wchar_t *pszStr)
 
StrLen_t VPrintf (const char *pszFormat, va_list args)
 
StrLen_t VPrintf (const wchar_t *pszFormat, va_list args)
 
StrLen_t _cdecl Printf (const char *pszFormat,...)
 
StrLen_t _cdecl Printf (const wchar_t *pszFormat,...)
 
HRESULT WriteStream (cStreamInput &sInp, STREAM_POS_t nSizeMax=k_FILE_BLOCK_SIZE, IStreamProgressCallback *pProgress=nullptr, TIMESYSD_t nTimeout=0)
 Copy cStreamInput to this stream. More...
 
virtual HRESULT FlushX ()
 
- Public Member Functions inherited from Gray::cStreamBase
virtual ~cStreamBase ()
 
virtual STREAM_SEEKRET_t Seek (STREAM_OFFSET_t iOffset, SEEK_ORIGIN_TYPE eSeekOrigin=SEEK_Set)
 
void SeekToBegin ()
 
STREAM_POS_t SeekToEnd ()
 
virtual STREAM_POS_t GetPosition () const
 
virtual STREAM_POS_t GetLength () const
 

Additional Inherited Members

- Static Public Attributes inherited from Gray::cStreamBase
static const BYTE k_SIZE_MASK = 0x80
 Used for WriteSize() More...
 
static const size_t k_FILE_BLOCK_SIZE = (32 * 1024)
 default arbitrary transfer block size. more than this is NOT more efficient. More...
 

Detailed Description

Write a stream of data/text out to some arbitrary destination. i.e. console, file, socket, telnet, game client, web page client, etc.. May be no Seek() method available / implemented. similar to STL std::ostream, and IWriteStream

Constructor & Destructor Documentation

◆ cStreamOutput()

Gray::cStreamOutput::cStreamOutput ( )
inlinenoexcept

◆ ~cStreamOutput()

virtual Gray::cStreamOutput::~cStreamOutput ( )
inlinevirtual

Member Function Documentation

◆ FlushX()

virtual HRESULT Gray::cStreamOutput::FlushX ( )
inlinevirtual

◆ Printf() [1/2]

StrLen_t _cdecl Gray::cStreamOutput::Printf ( const char *  pszFormat,
  ... 
)
inline

Write just the chars of the string. NOT nullptr Does NOT assume include NewLine or automatically add one.

Note
Use StrArg<GChar_t>(s) for safe "%s" args.
Returns
<0 = error. else number of chars written

◆ Printf() [2/2]

StrLen_t _cdecl Gray::cStreamOutput::Printf ( const wchar_t *  pszFormat,
  ... 
)
inline

Write just the chars of the string. NOT nullptr

Note
Use StrArg<GChar_t>(s) for safe "%s" args.
Returns
<0 = error. else number of chars written

◆ VPrintf() [1/2]

StrLen_t Gray::cStreamOutput::VPrintf ( const char *  pszFormat,
va_list  args 
)
inline

Write just the chars of the string. NOT nullptr

Returns
<0 = error. else number of chars written

◆ VPrintf() [2/2]

StrLen_t Gray::cStreamOutput::VPrintf ( const wchar_t *  pszFormat,
va_list  args 
)
inline

Write just the chars of the string. NOT nullptr

Returns
<0 = error. else number of chars written

◆ WriteCharRepeat()

template<typename _CH >
HRESULT Gray::cStreamOutput::WriteCharRepeat ( _CH  nChar,
int  nCount = 1 
)
inline

Repeat writing of a char/wchar_t * nCount.

Returns
<0 = error.

◆ WriteHashCode()

HRESULT Gray::cStreamOutput::WriteHashCode ( HASHCODE_t  nHashCode)
inline

opposite of ReadHashCode()

◆ WriteN()

HRESULT Gray::cStreamOutput::WriteN ( const void *  pBuffer,
size_t  nSize 
)
inline

Write a block prefixed by its size (Bytes). Write out a string with the length prefix.

Returns
<0 = error.

◆ WriteSize()

HRESULT Gray::cStreamOutput::WriteSize ( size_t  nSize)

Write a packed (unsigned) size_t. opposite of ReadSize(nSize) Packed low to high values. Bit 7 indicates more data needed. similar to ASN1 Length packing.

Returns
<0 = error.

◆ WriteStream()

HRESULT Gray::cStreamOutput::WriteStream ( cStreamInput sInp,
STREAM_POS_t  nSizeMax = k_FILE_BLOCK_SIZE,
IStreamProgressCallback pProgress = nullptr,
TIMESYSD_t  nTimeout = 0 
)

Copy cStreamInput to this stream.

Copy data from one read stream (stmIn) to another write stream (this).

  • nSizeMax = Length of file or some arbitrary max to the stream size. like the IStream::CopyTo() or MFC CopyFrom()
    Returns
    Size of data moved.

◆ WriteString() [1/2]

virtual HRESULT Gray::cStreamOutput::WriteString ( const char *  pszStr)
inlinevirtual

Write just the chars of the string. NOT nullptr. like fputs() Does NOT assume include NewLine or automatically add one.

Note
This can get overloaded for string only protocols. like FILE, fopen()
MFC CStdioFile has void return for this.
Returns
Number of chars written. <0 = error.

Reimplemented in Gray::cLogMgr, GrayLib::cLogFileDay, Gray::cLogAppendDebug, Gray::cLogAppender, Gray::cLogAppendTextArray, Gray::cLogAppendConsole, GrayX::cCmdTail, GrayLib::cXProtocolServerStream, Gray::cFileText, and Gray::cAppConsole.

◆ WriteString() [2/2]

virtual HRESULT Gray::cStreamOutput::WriteString ( const wchar_t *  pszStr)
inlinevirtual

Write just the chars of the string. NOT nullptr. like fputs() Does NOT assume include NewLine or automatically add one.

Note
This can get overloaded for string only protocols. like FILE, fopen()
MFC CStdioFile has void return for this.
Returns
Number of chars written. <0 = error.

Reimplemented in Gray::cLogMgr, Gray::cFileText, Gray::cAppConsole, and Gray::cLogAppender.

◆ WriteStringN()

template<typename _CH >
HRESULT Gray::cStreamOutput::WriteStringN ( const _CH *  pszStr)
inline

Write out a string with the length prefix. ReadStringN()

Returns
<0 = error.

◆ WriteT() [1/2]

HRESULT Gray::cStreamOutput::WriteT ( const void *  pVal,
size_t  nDataSize 
)
inline

Write all or nothing (fail). otherwise same as WriteX() (where partials are allowed)

Returns
Number of bytes written. <0 = error.

◆ WriteT() [2/2]

template<typename TYPE >
HRESULT Gray::cStreamOutput::WriteT ( TYPE  val)

◆ WriteX()

virtual HRESULT Gray::cStreamOutput::WriteX ( const void *  pData,
size_t  nDataSize 
)
inlinevirtual

The documentation for this class was generated from the following files: