PrevNextUpHome BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1
SFXStreamWriter
Class for accessing the output stream.
#include <SFXStreamWriter.h.hpp>
class SFXStreamWriter : public SFXOutputStream;
SFMTYPEDEFCLASS(SFXStreamWriter)

Inheritance diagram

 Inheritance diagram of SFXStreamWriterClass

Collaboration diagram

 Collaboration diagram of SFXStreamWriterClass

Description

The SFXStreamWriter class is used to write data onto the output stream such as file, TCP socket and so on.

According to the type of data to be written, select one among the following classes that inherit from the SFXStreamWriter class: SFXBinaryStreamWriter class, SFXAnsiStringStreamWriter class, SFXWideStringStreamWriter class.

Reference

SFXBinaryStreamWriter | SFXAnsiStringStreamWriter | SFXWideStringStreamWriter | SFXStreamReader

Member

Constructor/Destructor
SFXStreamWriter( Void )
Constructor of SFXStreamWriter class.
~SFXStreamWriter( Void )
Destructor of SFXStreamWriter class.
Public Functions
Void Attach( SFXOutputStreamPtr stream )
Delegate the control privilege of SFXOutputStream object to the SFXStreamWriter object.
Void Cancel( Void )
Call the Cancel function for Storage class. And also unregister the callback functions.
SFXOutputStreamPtr Detach( Void )
Delegate the control privilege of SFXStreamWriter object to the SFXOutputStream object.
SFCError Flush( Void )
Flush( CallbackSPP spp , VoidPtr reference )
Flush the written data.
UInt32 GetWritableSize( Void )
Get the size of writable data.
Void Release( Void )
Release the stream.
SFCError ResetTrigger( Void )
Reset the trigger when the callback function will be called.
SFCError SetTrigger( UInt32 size )
SetTrigger( VoidConstPtr buffer , UInt32 size )
SetTrigger( SFXBufferConstRef buffer )
Set the trigger when the callback function will be called.
Bool Triggers( Void )
Check whether the callback function is called by trigger or not.
SFCError Write( SFXBufferConstRef buffer )
Write( VoidConstPtr buffer , UInt32 size )
Write data onto the stream.
Types
CallbackSPP (inherits from SFXStream)
Constant that represents Callback function.

SFXStreamWriter::SFXStreamWriter
Constructor of SFXStreamWriter class.
[ public, explicit ]
SFXStreamWriter(Void);

SFXStreamWriter::~SFXStreamWriter
Destructor of SFXStreamWriter class.
[ public, virtual ]
virtual ~SFXStreamWriter(Void);

SFXStreamWriter::Attach
Delegate the control privilege of SFXOutputStream object to the SFXStreamWriter object.
[ public ]
Void Attach(
    SFXOutputStreamPtr stream   // stream to set
);

Description

The contents of SFXStreamWriter object before calling the SFXStreamWriter::Attach function will be destroyed.

What is delegation?: In object oriented programming, deligation means that an object have another deputy object behave like itself.

Reference

SFXStreamWriter::Detach


SFXStreamWriter::Cancel
Call the Cancel function for Storage class. And also unregister the callback functions.
[ public, virtual ]
Void Cancel(Void);

Description

Call the SFXFile::Cancel function for file, SFXTCPSocket::Cancel function for TCP socket, etc.

And also the callback functions registered by the SFXStreamWriter::Flush function are unregistered.

Reference

SFXStreamWriter::Flush | SFXFile::Cancel | SFXTCPSocket::Cancel


SFXStreamWriter::Detach
Delegate the control privilege of SFXStreamWriter object to the SFXOutputStream object.
[ public ]
SFXOutputStreamPtr Detach(Void);

Reference

SFXStreamWriter::Attach


SFXStreamWriter::Flush
Flush the written data.
[ public, virtual ]
SFCError Flush(Void);
[ public, virtual ]
SFCError Flush(
    CallbackSPP spp     // callback function
    VoidPtr reference   // data sent to callback function
);

Return value

  • Success : SFERR_NO_ERROR
  • If argument is invalid : SFERR_INVALID_PARAM
  • If stream is not set, or the SFXStreamWriter::Flush function is under processing : SFERR_INVALID_STATE
  • If failed : SFERR_FAILED
  • Otherwise : The Error value that defined in AEEError.h

Description

There are two types of SFXStreamWriter::Flush functions: one is with the registration of callback function, and the other is without it. Which type of SFXStreamWriter::Flush function is available depends upon the storage of stream.

    For example, only the type with the registration of callback function is availavle for TCP stream. However file stream can use both types.

In case of the SFXStreamWriter::Flush function without the registration of callback function, data is flushed immediately after this function is called.


SFXStreamWriter::GetWritableSize
Get the size of writable data.
[ public, virtual, const ]
UInt32 GetWritableSize(Void);

Description

If the size of data to be written is larger than the return value of SFXStreamWriter::GetWritableSize function, it is necessary to call the SFXStreamWriter::Flush function.

Reference

SFXStreamWriter::Flush


SFXStreamWriter::Release
Release the stream.
[ public ]
Void Release(Void);

SFXStreamWriter::ResetTrigger
Reset the trigger when the callback function will be called.
[ public, virtual ]
SFCError ResetTrigger(Void);

Return value

  • Success : SFERR_NO_ERROR
  • If the stream is not set, or the SFXStreamWriter::Flush function is under processing : SFERR_INVALID_STATE

Description

Reset the trigger set with the SFXStreamWriter::SetTrigger function.

Reference

SFXStreamWriter::SetTrigger | SFXStreamWriter::Flush


SFXStreamWriter::SetTrigger
Set the trigger when the callback function will be called.
[ public, virtual ]
SFCError SetTrigger(
    UInt32 size   // data size to be written through output stream
);
[ public, virtual ]
SFCError SetTrigger(
    SFXBufferConstRef buffer   // SFXBuffer object to be written through output stream
);
[ public, virtual ]
SFCError SetTrigger(
    VoidConstPtr buffer   // data to be written through output stream
    UInt32 size           // size of data to be written through output stream
);

Return value

  • Success : SFERR_NO_ERROR
  • If the stream is not set, or the SFXStreamWriter::Flush function is under processing : SFERR_INVALID_STATE
  • If insufficient memory : SFERR_NO_MEMORY

Description

The callback function registered by the SFXStreamWriter::Flush function is called when the stream buffer is full or the end of data is written.

When the "size" parameter of SFXStreamWriter::SetTrigger function is specified, callback function is called every time the "size" data is written.

When the "buffer" parameter of SFXStreamWriter::SetTrigger function is specified, callback function is called every time the data same with "buffer" is written.

Example

The callback function is called every time the line-feed following character is written.

SetTrigger("\r\n", 2)

Reference

SFXStreamWriter::ResetTrigger | SFXStreamWriter::Flush


SFXStreamWriter::Triggers
Check whether the callback function is called by trigger or not.
[ public, virtual, const ]
Bool Triggers(Void);

Return value

Description

The SFXStreamWriter::Triggers function is used for the callback function registered by the SFXStreamWriter::Flush function.

Reference

SFXStreamWriter::SetTrigger | SFXStreamWriter::ResetTrigger | SFXStreamWriter::Flush


SFXStreamWriter::Write
Write data onto the stream.
[ public, virtual ]
SFCError Write(
    SFXBufferConstRef buffer   // writing data
);
[ public, virtual ]
SFCError Write(
    VoidConstPtr buffer   // writing data
    UInt32 size           // size of writing data
);

Return value

  • Success : SFERR_NO_ERROR
  • If stream is not set : SFERR_INVALID_STATE
  • If argument is invalid : SFERR_INVALID_PARAM
  • If data cannot be written : SFERR_FAILED

Description

If the size of data to be written is larger than the return value of SFXStreamWriter::GetWritableSize function, it is necessary to call the SFXStreamWriter::Flush function.

Reference

SFXStreamWriter::GetWritableSize | SFXStreamWriter::Flush