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:

MemOutputStream

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 testDate AS DATE INITIAL "4/10/56".
DEFINE VARIABLE testDouble AS DECIMAL INITIAL 42.42.
DEFINE VARIABLE testFloat AS DECIMAL INITIAL 42.42.
DEFINE VARIABLE testLong AS INTEGER INITIAL 42.
DEFINE VARIABLE testShort AS INTEGER INITIAL 42.
DEFINE VARIABLE testString AS CHARACTER INITIAL "Progress".
                
DEFINE VAR InMs AS Progress.io.MemoryInputStream.

outMs  = NEW Progress.io.MemoryOutputStream().
outMs:WriteLong(INTEGER( testDate )).
outMs:WriteDouble(testDouble).
outMs:WriteFloat( testFLOAT).
outMs:WriteLong(testLONG).
outMs:WriteShort(testSHORT).
outMs:Write(testString).   
InMs = NEW Progress.io.MemoryInputStream(INPUT outMs:Data ). 

MESSAGE   
 InMs:ReadLONG()    SKIP
 InMs:ReadDOUBLE()  SKIP
 InMs:ReadFLOAT()   SKIP
 InMs:ReadLONG()    SKIP
 InMs:ReadSHORT()   SKIP
 InMs:ReadSTRING()  VIEW-AS ALERT-BOX.
READ & WRITE string methods
DEFINE VAR InMs1   AS Progress.io.MemoryInputStream. 
DEFINE VAR InMs2   AS Progress.io.MemoryInputStream. 
DEFINE VAR outMs   AS Progress.io.MemoryOutputStream. 
DEFINE VAR len     AS INT64.
DEFINE VAR ret     AS INT64.
DEFINE VAR ch      AS CHAR.
DEFINE VAR lc1     AS CHAR.

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 InMs1:ReadLongchar() VIEW-AS ALERT-BOX.

See also

OpenEdge Development: Programming Interfaces for more information about MEMPTR.

Progress.IO.MemoryInputStream class