PrevNextUpHome SophiaFramework UNIVERSE 5.3

17.1. Overview of the Stream

In SophiaFramework UNIVERSE, the below is the method to read / write data from / into the storage such as file, network, memory and so on by using the stream.

Method to read / write data through the stream

  1. Open the storage by calling the Open function.
  2. In case of reading:
    1. Get the stream for reading by calling the GetStreamReader function. At this time, various settings of the stream will be done too.
    2. Read data from the storage into the stream buffer by callin the Fetch function.
    3. Read data from the stream buffer into the variable by calling the Read function or using the extractor(>> operator).
  3. In case of writing:
    1. Get the stream for writing by calling the GetStreamWriter function. At this time, various settings of the stream will be done too.
    2. Write data from the variable into the stream buffer by calling the Write function or using the inserter(<< operator).
    3. Write data from stream buffer into the storage by callin the Flush function.
  4. Release the stream by calling the Release function.
  5. Close the storage by calling the Close function.

Figure 17.1. Overview of the Stream

Overview of the Stream
[Note] Stream Classification

The stream can be classified as follows:

Table 17.1. Kind of the Stream 1

Data to read / write Kind of the Stream
String String Stream
Binary(Data of the arbitrary type) Binary Stream

Table 17.2. Kind of the Stream 2

Stream Buffer Kind of the Stream
Variable Length Variable Buffer Stream
Fixed Length Fixed Buffer Stream

Concrete Stream Classes

There are eight types of the concrete stream classes as in the below table. These stream classes will read / write data from / into the storage through the stream buffer. The extractor(>> operator) and inserter(<< operator) which will support the various data types and the function to convert the endian are available too.

Table 17.3. Concrete Stream Classes

Kind of the Stream Kind of the data to read / write For Reading For Writing
String Stream String of the AChar Type SFXAnsiStringStreamReader SFXAnsiStringStreamWriter
String Stream String of the WChar Type SFXWideStringStreamReader SFXWideStringStreamWriter
Binary Stream Binary(Data of the Arbitrary Type) SFXBinaryStreamReader SFXBinaryStreamWriter
Variable Buffer Stream String of the AChar Type / String of the WChar Type / Binary(Data of the Arbtrary Type) SFXElasticStreamReader SFXElasticStreamWriter
[Note] About AChar and WChar

In the BREW environment, there are two kinds of character types: one is the char type that represents the single/multi byte character(or the ANSI character) and the other is the AECHAR type that represents the double byte character of the uint16 type.

In SophiaFramewok UNIVERSE, these two kinds of character types are defined as AChar and WChar using typedef respectively. And two kinds of the following string classes are available:

All the functions of these two string classes are the same except their string types.

[Note] Variable Buffer Stream

The variable buffer stream is internally used to read / write through the string stream or the binary stream, whose buffer is variable. You don't have to use directly the SFXElasticStreamReader / SFXElasticStreamWriter class as the substance of the variable buffer stream.

The variable buffer stream can be gotten by calling the GetStreamReader / GetStreamWriter function of the storage class with the size argument (buffer size) not specified.