Progress.IO.MemoryInputStream class

This class is responsible for reading data from memory. It acts as a wrapper for MEMPTR read operations.

Progress.IO.MemoryInputStream extends Progress.IO.InputStream:

As with other input stream classes, the MemoryInputStream class maintains its own internal read position and eliminates the need to keep track of MEMPTR read positions.

For input streams the expected network byte order is controlled by the underlying MEMPTR byte ordering. If the input stream was created using MemoryOutputStream, then the byte order is taken from the value of the ByteOrder property of the MemoryOutputStream. If instead the input stream was created from a MEMPTR, the SET-BYTE-ORDER statement must be used to control the byte ordering used by the MemoryInputStream read methods.

Serializable:

No

Constructor

PUBLIC MemoryInputStream ( INPUT mos AS Progress.IO.MemoryOutputStream )
PUBLIC MemoryInputStream ( INPUT mem AS MEMPTR )
mos
An initialized MemoryOutputStream object that this input stream object will operate on.
mem
An initialized MEMPTR variable that this input stream object will operate on.

Super Class

Progress.IO.InputStream class

Interfaces

This class does not implement an interface.

Public Properties

Public Methods

Public Events

This class does not define events.

Examples

Read and write integer and decimal methods
DEFINE VARIABLE myDate AS DATE INITIAL "1/1/2020".
DEFINE VARIABLE myInt64 AS INT64 INITIAL 42.
DEFINE VARIABLE myDouble AS DECIMAL INITIAL 42.42.
DEFINE VARIABLE myFloat AS DECIMAL INITIAL 42.42.
DEFINE VARIABLE myLong AS INTEGER INITIAL -53.
DEFINE VARIABLE myShort AS INTEGER INITIAL -53.
DEFINE VARIABLE myULong AS INTEGER INITIAL 123456789.
DEFINE VARIABLE myUShort AS INTEGER INITIAL 12345.
DEFINE VARIABLE inMs AS Progress.IO.MemoryInputStream.
DEFINE VARIABLE outMs AS Progress.IO.MemoryOutputStream.

outMs = NEW Progress.IO.MemoryOutputStream().
outMs:WriteLong(INTEGER(myDate)).
outMs:WriteInt64(myInt64).
outMs:WriteDouble(myDouble).
outMs:WriteFloat(myFloat).
outMs:WriteLong(myLong).
outMs:WriteShort(myShort).
outMs:WriteUnsignedLong(myULong).
outMs:WriteUnsignedShort(myUShort).

inMs = NEW Progress.IO.MemoryInputStream(INPUT outMs:Data).
MESSAGE
  "ReadLong:" inMs:ReadLong() SKIP
  "ReadInt64:" inMs:ReadINT64() SKIP
  "ReadDouble:" inMs:ReadDouble() SKIP
  "ReadFloat:" inMs:ReadFloat() SKIP
  "ReadLong:" inMs:ReadLong() SKIP
  "ReadShort:" inMs:ReadShort() SKIP
  "ReadUnsignedLong:" inMs:ReadUnsignedLong() SKIP
  "ReadUnsignedShort:" inMs:ReadUnsignedShort() SKIP
  VIEW-AS ALERT-BOX.
Read and write string methods
DEFINE VARIABLE outMs AS Progress.IO.MemoryOutputStream. 
DEFINE VARIABLE InMs1 AS Progress.IO.MemoryInputStream. 
DEFINE VARIABLE InMs2 AS Progress.IO.MemoryInputStream. 

outMs = NEW Progress.IO.MemoryOutputStream().
outMs:Write("PROGRESS1",YES).
outMs:Write("PROGRESSx2",YES).

InMs1 = NEW Progress.IO.MemoryInputStream(INPUT outMs). 
MESSAGE InMs1:ReadString() 
  VIEW-AS ALERT-BOX.
MESSAGE STRING(InMs1:ReadLongchar()) 
  VIEW-AS ALERT-BOX.

See also

OpenEdge Programming Interfaces for more information about MEMPTR.

Progress.IO.MemoryOutputStream class