The string stream
The string stream provides access to a character array through the stream I/O interface. The string stream does not handle character data as null-terminated strings. It does not evaluate the contents of the data stream in any way.
To support a data stream on a character array, the DataBlade
API provides
the stream I/O functions in following table.
Stream I/O task | Stream I/O function |
---|---|
Initialize and open a string stream. | mi_stream_open_str() |
Move the string seek position to the desired location. | mi_stream_seek() |
Read a specified number of bytes from the string stream. | mi_stream_read() |
Write a specified number of bytes to the string stream. | mi_stream_write() |
Obtain the current string seek position, returning it from the function. | mi_stream_tell() |
Obtain the current string seek position, returning it in a function parameter. | mi_stream_getpos() |
Set the string seek position. | mi_stream_setpos() |
Obtain the length of the character array.
This is the str_len value to pass to mi_stream_open_str() when you create the string stream. |
mi_stream_length() |
Close the string stream. | mi_stream_close() |
Tip: You can also use the mi_stream_get_error() and mi_stream_eof() functions
on a string stream.
As Table 1 shows, the stream I/O interface for a string stream consists of the generic stream I/O functions plus a type-specific stream-open function, mi_stream_open_str().