![]() ![]() ![]()
|
BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1 |
#include <SFXElasticStreamReader.h.hpp>
class SFXElasticStreamReader : public SFXInputStream;
SFMTYPEDEFCLASS(SFXElasticStreamReader)


What is SFXElasticStreamReader?
The SFXElasticStreamReader class is used to read data from the input stream of elastic buffer such as file, TCP socket and so on.
The SFXBinaryStreamReader, SFXAnsiStringStreamReader, or SFXWideStringStreamReader class can get the elastic buffer stream by using the SFXElasticStreamReader class internally. Therefore, usually it is unnecessary to use the SFXElasticStreamReader class explicitly.
Attach function and Detach function
By using the SFXElasticStreamReader::Attach function, and delegating the control privilege of the SFXBinaryStreamReader, SFXAnsiStringStreamReader, or SFXWideStringStreamReader object that inherites from SFXInputStream to the SFXElasticStreamReader object, the input stream of elastic buffer can be available.
The SFXElasticStreamReader::Detach function has reverse functionality.
What is delegation?: In object oriented programming, delegation means that an object have another deputy object behave like itself.
SFXBinaryStreamReader | SFXAnsiStringStreamReader | SFXWideStringStreamReader | SFXElasticStreamWriter
| Constructor/Destructor |
|---|
|
SFXElasticStreamReader( Void ) Constructor of SFXElasticStreamReader class.
|
|
~SFXElasticStreamReader( Void ) Destructor of SFXElasticStreamReader class.
|
| Public Functions | |
|---|---|
| Void |
Attach(
SFXInputStreamPtr stream
) Delegate the control privilege of SFXInputStream object to the SFXElasticStreamReader object.
|
| Void |
Cancel( Void ) Call the Cancel function for Storage class. And also unregister callback functions.
|
| SFXInputStreamPtr |
Detach( Void ) Delegate the control privilege of SFXElasticStreamReader object to the SFXInputStream object.
|
| Bool |
Ends( Void ) Check whether the stream ends or not.
|
| SFCError |
Fetch( Void ) Fetch( CallbackSPP spp , VoidPtr reference ) Fetch for reading data newly.
|
| SInt32 |
FirstIndexOf(
Byte byte
, SInt32 index = SINT32_MINIMUM
) FirstIndexOf( VoidConstPtr buffer , UInt32 size , SInt32 index = SINT32_MINIMUM ) FirstIndexOf( SFXBufferConstRef buffer , SInt32 index = SINT32_MINIMUM ) Get the first index of SFXElasticStreamReader object to match with the specified data, searching from the beginning.
|
| UInt32 |
GetReadableSize( Void ) Get the size of readable data.
|
| SInt32 |
LastIndexOf(
Byte byte
, SInt32 index = SINT32_MAXIMUM
) LastIndexOf( VoidConstPtr buffer , UInt32 size , SInt32 index = SINT32_MAXIMUM ) LastIndexOf( SFXBufferConstRef buffer , SInt32 index = SINT32_MAXIMUM ) Get the last index of SFXElasticStreamReader object to match with the specified data, searching from the end.
|
| SFCError |
Read(
SFXBufferPtr buffer
) Read( VoidPtr buffer , UInt32 size ) Read data from the input stream.
|
| Void |
Release( Void ) Release the stream.
|
| SFCError |
ResetTrigger( Void ) Reset the trigger when the callback function will be called.
|
| SFCError |
Seek(
UInt32 size
) Move the read pointer foraward.
|
| 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.
|
| Types |
|---|
|
CallbackSPP
(inherits from SFXStream)
Constant that represents Callback function.
|
[ public, explicit ] SFXElasticStreamReader(Void);
[ public, virtual ] virtual ~SFXElasticStreamReader(Void);
[ public ] Void Attach( SFXInputStreamPtr stream // stream to set );
The contents of the SFXElasticStreamReader object before calling the SFXElasticStreamReader::Attach function will be destroyed.
[ public, virtual ] Void Cancel(Void);
Call the SFXFile::Cancel function for file, the SFXTCPSocket::Cancel function for TCP socket, etc.
And also the callback functions registered by the SFXElasticStreamReader::Fetch function are unregistered.
SFXElasticStreamReader::Fetch | SFXFile::Cancel | SFXTCPSocket::Cancel
[ public ] SFXInputStreamPtr Detach(Void);
[ public, virtual, const ] Bool Ends(Void);
[ public, virtual ] SFCError Fetch(Void);
[ public, virtual ] SFCError Fetch( CallbackSPP spp // callback function VoidPtr reference // data sent to callback function );
There are two types of SFXElasticStreamReader::Fetch functions: one is with the registration of callback function, and the other is without it. Which type of SFXElasticStreamReader::Fetch 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 SFXElasticStreamReader::Fetch function without the registration of callback function, data is read into the internal buffer immediately after this function is called.
[ public, virtual, const ] SInt32 FirstIndexOf( Byte byte // byte data to match with SInt32 index = SINT32_MINIMUM // starting index to search from );
[ public, virtual, const ] SInt32 FirstIndexOf( SFXBufferConstRef buffer // buffer object to match with SInt32 index = SINT32_MINIMUM // starting index to search from );
[ public, virtual, const ] SInt32 FirstIndexOf( VoidConstPtr buffer // buffer data to match with UInt32 size // size of buffer data to match with SInt32 index = SINT32_MINIMUM // starting index to search from );
To search from other than the beginning, specify the starting index to match with. (The origin index is 0.)
[ public, virtual, const ] UInt32 GetReadableSize(Void);
It is necessary to check the size of readable data by the SFXElasticStreamReader::GetReadableSize function before calling the SFXElasticStreamReader::Read function.
[ public, virtual, const ] SInt32 LastIndexOf( Byte byte // byte data to match with SInt32 index = SINT32_MAXIMUM // starting index to search from );
[ public, virtual, const ] SInt32 LastIndexOf( SFXBufferConstRef buffer // buffer object to match with SInt32 index = SINT32_MAXIMUM // starting index to search from );
[ public, virtual, const ] SInt32 LastIndexOf( VoidConstPtr buffer // buffer data to match with UInt32 size // size of buffer data to match with SInt32 index = SINT32_MAXIMUM // starting index to search from );
To search from other than the end, specify the starting index to match with. (The origin index is 0.)
[ public, virtual ] SFCError Read( SFXBufferPtr buffer // buffer to read data );
[ public, virtual ] SFCError Read( VoidPtr buffer // pointer to the buffer to read data UInt32 size // size of the buffer to read data );
The size of readable data can be gotten by calling the SFXElasticStreamReader::GetReadableSize function.
When using the SFXBuffer class to receive data , set the size of data to be recieved by the SFXBuffer::SetSize function.
[ public ] Void Release(Void);
[ public, virtual ] SFCError ResetTrigger(Void);
Reset the trigger set with the SFXElasticStreamReader::SetTrigger function.
[ public, virtual, const ] Bool Triggers(Void);
The SFXElasticStreamReader::Triggers function is used for the callback function registered by the SFXElasticStreamReader::Fetch function.
SFXElasticStreamReader::SetTrigger | SFXElasticStreamReader::ResetTrigger | SFXElasticStreamReader::Fetch
[ public, virtual ] SFCError SetTrigger( UInt32 size // data size to be read through input stream );
[ public, virtual ] SFCError SetTrigger( SFXBufferConstRef buffer // SFXBuffer object to be read through input stream );
[ public, virtual ] SFCError SetTrigger( VoidConstPtr buffer // data to be read through input stream UInt32 size // size of data to be read through input stream );
The callback function registered by the SFXElasticStreamReader::Fetch function is called when the stream buffer is full or the end of data is read.
When the "size" parameter of SFXElasticStreamReader::SetTrigger function is specified, callback function is called every time the "size" data is read.
When the "buffer" parameter of SFXElasticStreamReader::SetTrigger function is specified, callback function is called every time the data same with "buffer" is read.
Call the callback on every time the line-feed character is read.
SetTrigger("\r\n", 2)
|
Copyright (C) 2002 - 2009 Sophia Cradle, Inc. All Rights Reserved. |
![]() ![]() ![]()
|