Difference between revisions of "Lua:Class:Stream"
Jump to navigation
Jump to search
m (Reverted edits by This content is not available (Talk) to last revision by TheyCallMeTim13) |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Lua]] | ||
Stream '''class''': ('''Inheritance''': ''[[Object]]'') | Stream '''class''': ('''Inheritance''': ''[[Object]]'') | ||
Line 12: | Line 13: | ||
== Methods == | == Methods == | ||
− | ; copyFrom(stream, count) | + | ; copyFrom(''stream'', ''count'') |
: Copies 'count' number of bytes from the given 'stream' to this stream | : Copies 'count' number of bytes from the given 'stream' to this stream | ||
: Note: Always set 'Postion' before using 'copyFrom' (i.e.: 0 for start of steam). | : Note: Always set 'Postion' before using 'copyFrom' (i.e.: 0 for start of steam). | ||
:'''Example''': | :'''Example''': | ||
− | + | local stringStream = createStringStream() | |
− | + | stringStream.Position = 0 -- if not set before using 'copyFrom' the 'StringStream' object will be inconsistent. | |
− | + | stringStream.copyFrom(tableFile.Stream, tableFile.Stream.Size) | |
− | ; read(count) : table | + | ; read(''count'') : table |
: Returns a byte table containing the bytes of the stream. | : Returns a byte table containing the bytes of the stream. | ||
: This increases the position. | : This increases the position. | ||
− | ; write( | + | ; write(''byteTable'', ''count'' OPTIONAL) |
: Writes the given bytetable to the stream | : Writes the given bytetable to the stream | ||
Latest revision as of 19:07, 18 March 2019
Stream class: (Inheritance: Object)
Base class for byte stream objects.
Properties[edit]
- Size : integer
- The byte size of the stream.
- Position : integer
- The current byte position of the stream.
Methods[edit]
- copyFrom(stream, count)
- Copies 'count' number of bytes from the given 'stream' to this stream
- Note: Always set 'Postion' before using 'copyFrom' (i.e.: 0 for start of steam).
- Example:
local stringStream = createStringStream() stringStream.Position = 0 -- if not set before using 'copyFrom' the 'StringStream' object will be inconsistent. stringStream.copyFrom(tableFile.Stream, tableFile.Stream.Size)
- read(count) : table
- Returns a byte table containing the bytes of the stream.
- This increases the position.
- write(byteTable, count OPTIONAL)
- Writes the given bytetable to the stream