Progress.IO.MemoryOutputStream class

This class is responsible for streaming data to memory. A MemoryOutputStream object enables write operations to memory and is expandable. It encapsulates the MEMPTR data type and simplifies MEMPTR operations.

Progress.IO.MemoryOutputStream extends Progress.IO.OutputStream:

As with other output stream classes, the MemoryOutputStream class maintains its own internal write position and eliminates the need to keep track of MEMPTR write positions.

Serializable

No

Constructors

PUBLIC MemoryOutputStream ( )
PUBLIC MemoryOutputStream (INPUT size AS INT64)
size
The Data and Length properties are initialized to the value specified by size.

When size is not specified, the Data and Length properties are initialized to 0.

Super Class

Progress.IO.OutputStream class

Interfaces

This class does not implement an interface.

Public Properties

Public Methods

Public Events

This class does not define events.

Note

The following table illustrates values that result from constructors and Write( )/Clear( ) methods:

Method/Constructor Values
Obj:Length Obj:BytesWritten
Obj = NEW MemoryOutputStream() 0 0
Obj:Write(“12345”) 5 5
Obj:Clear() 0 0
Obj = NEW MemoryOutputStream(100) 100 0
Obj:Write(“12345678”) 100 8
Obj:Clear() 100 0

Examples

READ & WRITE decimal and integer 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 & 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.MemoryInputStream class