![]() ![]() ![]()
|
BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1 |


Limitation
The stream for writing data cannot be obtained, and the function to move the position for reading is not supported.
How to use the SFXSource class
Example 494. Sample code for reading data from ISource interface
Void MyClass::UseSFXSource(Void)
{
SFXSource source;
static ACharConst data[] = "test data"; // read data
SFXAnsiString string; // variable to read data from SFBSource storage
SFXBinaryStreamReader reader; // input stream for reading data from SFBSource storage
SFBSourceUtilSmp util;
SFBSourceSmp bs;
// create from SFBSource storage from memory block
util = SFBSourceUtil::NewInstance();
util->SourceFromMemory(data, sizeof(data), null, null, &bs);
// open SFBSource storage
if (source.Open(bs) == SFERR_NO_ERROR) {
// get input stream for reading data from SFBSource storage
if (source.GetStreamReader(1024, &reader) == SFERR_NO_ERROR) {
reader.Fetch(); // read data from SFBSource storage to input stream
reader >> string; // read data from input stream to string
// display data to read from SFBSource storage on BREW Output Window
TRACE("size = %d", string.GetLength()); // display string length: "size = 9"
TRACE("read = %s", string.GetCString()); // display string: "read = test data"
reader.Release(); // release input stream
}
source.Close(); // close SFBSource storage
}
return;
}
SFBSource | SFBSourceUtil | SFXBinaryStreamReader | SFXAnsiStringStreamReader | SFXWideStringStreamReader
| Constructor/Destructor |
|---|
|
SFXSource( Void ) Constructor of SFXSource class.
|
|
~SFXSource( Void ) Destructor of SFXSource class.
|
| Public Functions | |
|---|---|
| Void |
Cancel( Void ) Cancel the callback.
|
| Void |
Close( Void ) Close the ISource interface used internally.
|
| SFBSourceSmpConstRef |
GetSFBSource( Void ) Get the instance of SFBSource class used internally.
|
| SFCError |
GetStreamReader(
UInt32 size
, SFXStreamReaderPtr result
) GetStreamReader( SFXStreamReaderPtr result ) Get the input stream for reading data from the ISource interface(SFBSource storage).
|
| SFCError |
GetStreamWriter(
UInt32 size
, SFXStreamWriterPtr result
) GetStreamWriter( SFXStreamWriterPtr result ) [ This function cannot be used now. ]
|
| SFCError |
Open(
SFXMemoryConstRef memory
) Open( SFBAStreamSmpConstRef stream ) Open( SFBSourceSmpConstRef source ) Open( SFXTCPSocketConstRef socket ) Open( SFXFileConstRef file ) Open( SFXZIPDecoderConstRef zip ) Register the SFBSource storage.
|
| SFCError |
Read(
VoidPtr buffer
, UInt32Ptr size
) Read data from the ISource interface(SFBSource storage) without using the input stream.
|
| SFCError |
ScheduleRead(
CallbackSPP spp
, VoidPtr reference
) Register callback function and schedule to read data from the ISource interface(SFBSource storage).
|
| SFCError |
ScheduleWrite(
CallbackSPP spp
, VoidPtr reference
) [ This function cannot be used now. ]
|
| SFCError |
Write(
VoidConstPtr buffer
, UInt32Ptr size
) [ This function cannot be used now. ]
|
| Types |
|---|
|
CallbackSPP
(inherits from SFXStorage)
The prototype of the callback function for the SFXStorage class.
|
[ public, explicit ] SFXSource(Void);
The resource is not allocated.
[ public, virtual ] virtual ~SFXSource(Void);
[ public, virtual ] Void Cancel(Void);
Cancel the callback functions registered in the instance of SFBSource class used internally.
[ public ] Void Close(Void);
The registered callback functions are also canceled.
[ public, const ] SFBSourceSmpConstRef GetSFBSource(Void);
[ public, virtual ] SFCError GetStreamReader( UInt32 size // buffer size SFXStreamReaderPtr result // pointer to the input stream for reading data from the ISource interface(SFBSource storage) );
[ public, virtual ] SFCError GetStreamReader( SFXStreamReaderPtr result // pointer to the input stream for reading data from the ISource interface(SFBSource storage) );
The buffer size of the input stream for reading data from the ISource interface(SFBSource storage) can be specified. Use the SFXBinaryStreamReader, SFXAnsiStringStreamReader, or SFXWideStringStreamReader class for the input stream properly according to the type of data to read.
SFXSource::GetStreamWriter | SFXBinaryStreamReader | SFXAnsiStringStreamReader | SFXWideStringStreamReader
[ public, virtual ] SFCError GetStreamWriter( UInt32 size // size SFXStreamWriterPtr result // pointer to the output stream for writing data to the ISource interface(SFBSource storage) );
[ public, virtual ] SFCError GetStreamWriter( SFXStreamWriterPtr result // pointer to the output stream for writing data to the ISource interface(SFBSource storage) );
SFERR_UNSUPPORTED is returned.
[ public ] SFCError Open( SFXMemoryConstRef memory );
[ public ] SFCError Open( SFXZIPDecoderConstRef zip );
[ public ] SFCError Open( SFXFileConstRef file );
[ public ] SFCError Open( SFXTCPSocketConstRef socket );
[ public ] SFCError Open( SFBSourceSmpConstRef source );
[ public ] SFCError Open( SFBAStreamSmpConstRef stream );
[ public, virtual ] SFCError Read( VoidPtr buffer // buffer to read data from the ISource interface(SFBSource storage) UInt32Ptr size // buffer sizee );
Specify the buffer to read data from the ISource interface(SFBSource storage).
Specify the size of buffer when calling SFXSource::Read function. When the SFXMemory::Source function ends, the size of data that is actually read is stored.
Before using the SFXSource::Read function, call the SFXSource::Open function and register the SFBSource storage.
[ public, virtual ] SFCError ScheduleRead( CallbackSPP spp // callback function VoidPtr reference // data passed to callback function );
The SFXFile::ScheduleRead function is used to register the callback function in which the SFXSource::Read function is used to read data from the ISource interface(SFBSource storage).
![]() |
Note |
|---|---|
| When the return value of SFXSource::Read function is AEE_STREAM_WOULDBLOCK or there is still remaining data to read, register the callback function using the SFXSource::ScheduleRead function, and then schedule the SFXSource::Read function in the callback function again. | |
[ public, virtual ] SFCError ScheduleWrite( CallbackSPP spp // callback function VoidPtr reference // data passed to the callback function );
SFERR_UNSUPPORTED is returned.
[ public, virtual ] SFCError Write( VoidConstPtr buffer // data to write UInt32Ptr size // size of data to write );
SFERR_UNSUPPORTED is returned.
|
Copyright (C) 2002 - 2009 Sophia Cradle, Inc. All Rights Reserved. |
![]() ![]() ![]()
|