C# Class BitSharper.IO.ByteBuffer

This type supports the Fluorine infrastructure and is not intended to be used directly from your code. http://java.sun.com/j2se/1.5.0/docs/api/java/nio/ByteBuffer.html The following invariant holds for the mark, position, limit, and capacity values: 0 <= mark <= position <= limit <= capacity
Inheritance: Stream
Afficher le fichier Open project: TangibleCryptography/BitSharper Class Usage Examples

Méthodes publiques

Méthode Description
Allocate ( int capacity ) : ByteBuffer

Allocates a new byte buffer. The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined. It will have a backing array, and its array offset will be zero.

Append ( byte src ) : void

Appends a byte buffer to this ByteArray.

Append ( byte src, int offset, int length ) : void

Appends a byte buffer to this ByteArray.

ByteBuffer ( MemoryStream stream ) : System

Initializes a new instance of the ByteBuffer class.

Clear ( ) : void

Clears this buffer. The position is set to zero, the limit is set to the capacity, and the mark is discarded.

ClearBookmark ( ) : void

Clears the current bookmark.

Close ( ) : void

Closes the current stream and releases any resources associated with the current stream.

Compact ( ) : void

Compacts this buffer The bytes between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the byte at index p = position() is copied to index zero, the byte at index p + 1 is copied to index one, and so forth until the byte at index limit() - 1 is copied to index n = limit() - 1 - p. The buffer's position is then set to n+1 and its limit is set to its capacity. The mark, if defined, is discarded. The buffer's position is set to the number of bytes copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.

Dump ( string file ) : void

Write the buffer content to a file.

Equals ( object obj ) : bool

Tells whether or not this buffer is equal to another object.

Fill ( byte value, int count ) : void

Fills this buffer with the specified value.

Flip ( ) : void

Flips this buffer. The limit is set to the current position and then the position is set to zero. If the mark is defined then it is discarded.

Flush ( ) : void

Clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Get ( ) : byte

Relative get method. Reads the byte at this buffer's current position, and then increments the position.

Get ( int index ) : byte

Absolute get method. Reads the byte at the given index.

Get ( byte dst ) : void

Relative bulk get method.

GetBuffer ( ) : byte[]

Returns the array of unsigned bytes from which this stream was created.

GetHashCode ( ) : int

Returns the current hash code of this buffer.

GetInt ( ) : int

Reads a 4-byte signed integer using network byte order encoding.

GetShort ( ) : short

Reads a 2-byte signed integer using network byte order encoding.

Mark ( ) : long

Sets this buffer's bookmark at its position.

Put ( ByteBuffer output, ByteBuffer input, int numBytesMax ) : int

Puts an in buffer stream onto an out buffer stream and returns the bytes written.

Put ( ByteBuffer src ) : void

This method transfers the bytes remaining in the given source buffer into this buffer. If there are more bytes remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no bytes are transferred and a BufferOverflowException is thrown. Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.

Put ( ByteBuffer src, int count ) : void

Transfers the specified number of bytes from the given source buffer into this buffer.

Put ( byte value ) : void

Writes the given byte into this buffer at the current position, and then increments the position.

Put ( byte src, int offset, int length ) : void

Relative bulk put method. This method transfers bytes into this buffer from the given source array. If there are more bytes to be copied from the array than remain in this buffer, that is, if length > remaining(), then no bytes are transferred and a BufferOverflowException is thrown. Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.

Put ( int index, UInt16 value ) : void
Put ( int index, UInt32 value ) : void

Absolute put method for writing an int value. Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index.

Put ( int index, byte value ) : void

Absolute put method. Writes the given byte into this buffer at the given index.

PutInt ( int value ) : void

Relative put method for writing an int value. Writes four bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by four.

PutInt ( int index, int value ) : void

Absolute put method for writing an int value. Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index.

PutShort ( short value ) : void

Writes a 16-bit unsigned integer to the current position.

Read ( byte buffer ) : int

Relative bulk get method. This method transfers bytes from this buffer into the given destination array. An invocation of this method behaves in exactly the same way as the invocation buffer.Get(a, 0, a.Length)

Read ( byte buffer, int offset, int count ) : int

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

ReadByte ( ) : int

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

ReadBytes ( int count ) : byte[]

Reads count bytes from the current stream into a byte array and advances the current position by count bytes.

ReadReverseInt ( ) : int

Reads a 4-byte signed integer.

ReadUInt24 ( ) : int
Reset ( ) : void

Resets this buffer's position to the previously-marked position. Invoking this method neither changes nor discards the mark's value.

Rewind ( ) : void

Rewinds this buffer. The position is set to zero and the mark is discarded.

Seek ( long offset, SeekOrigin origin ) : long

Sets the position within the current stream.

SetLength ( long value ) : void

Sets the length of the current stream.

Skip ( int size ) : void

Forwards the position of this buffer as the specified size bytes.

ToArray ( ) : byte[]

Writes the stream contents to a byte array, regardless of the Position property.

This method omits unused bytes in ByteBuffer from the array. To get the entire buffer, use the GetBuffer method.

ToString ( ) : string

Returns a string summarizing the state of this buffer.

Wrap ( byte array ) : ByteBuffer

Wraps a byte array into a buffer. The new buffer will be backed by the given byte array; that is, modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity and limit will be array.length, its position will be zero, and its mark will be undefined.

Wrap ( byte array, int offset, int length ) : ByteBuffer

Wraps a byte array into a buffer. The new buffer will be backed by the given byte array; that is, modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity will be array.length, its position will be offset, its limit will be offset + length, and its mark will be undefined.

Write ( byte buffer, int offset, int count ) : void

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

WriteByte ( byte value ) : void

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

WriteMediumInt ( int value ) : void

Writes a 32-bit signed integer to the current position using variable length unsigned 29-bit integer encoding.

WriteReverseInt ( int value ) : void
this ( int index ) : byte

Méthodes protégées

Méthode Description
Dispose ( bool disposing ) : void

Releases all resources used by this object.

Private Methods

Méthode Description
WriteBigEndian ( byte bytes ) : void
WriteBigEndian ( int index, byte bytes ) : void
WriteBytes ( int index, byte bytes ) : void

Method Details

Allocate() public static méthode

Allocates a new byte buffer. The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined. It will have a backing array, and its array offset will be zero.
public static Allocate ( int capacity ) : ByteBuffer
capacity int
Résultat ByteBuffer

Append() public méthode

Appends a byte buffer to this ByteArray.
public Append ( byte src ) : void
src byte The byte buffer to append.
Résultat void

Append() public méthode

Appends a byte buffer to this ByteArray.
public Append ( byte src, int offset, int length ) : void
src byte The byte buffer to append.
offset int Offset in the byte buffer.
length int Number of bytes to append.
Résultat void

ByteBuffer() public méthode

Initializes a new instance of the ByteBuffer class.
public ByteBuffer ( MemoryStream stream ) : System
stream System.IO.MemoryStream Wraps the MemoryStream into a buffer.
Résultat System

Clear() public méthode

Clears this buffer. The position is set to zero, the limit is set to the capacity, and the mark is discarded.
public Clear ( ) : void
Résultat void

ClearBookmark() public méthode

Clears the current bookmark.
public ClearBookmark ( ) : void
Résultat void

Close() public méthode

Closes the current stream and releases any resources associated with the current stream.
public Close ( ) : void
Résultat void

Compact() public méthode

Compacts this buffer The bytes between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the byte at index p = position() is copied to index zero, the byte at index p + 1 is copied to index one, and so forth until the byte at index limit() - 1 is copied to index n = limit() - 1 - p. The buffer's position is then set to n+1 and its limit is set to its capacity. The mark, if defined, is discarded. The buffer's position is set to the number of bytes copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.
public Compact ( ) : void
Résultat void

Dispose() protected méthode

Releases all resources used by this object.
protected Dispose ( bool disposing ) : void
disposing bool Indicates if this is a dispose call dispose.
Résultat void

Dump() public méthode

Write the buffer content to a file.
public Dump ( string file ) : void
file string
Résultat void

Equals() public méthode

Tells whether or not this buffer is equal to another object.
public Equals ( object obj ) : bool
obj object The object to which this buffer is to be compared
Résultat bool

Fill() public méthode

Fills this buffer with the specified value.
public Fill ( byte value, int count ) : void
value byte
count int
Résultat void

Flip() public méthode

Flips this buffer. The limit is set to the current position and then the position is set to zero. If the mark is defined then it is discarded.
public Flip ( ) : void
Résultat void

Flush() public méthode

Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
public Flush ( ) : void
Résultat void

Get() public méthode

Relative get method. Reads the byte at this buffer's current position, and then increments the position.
public Get ( ) : byte
Résultat byte

Get() public méthode

Absolute get method. Reads the byte at the given index.
public Get ( int index ) : byte
index int
Résultat byte

Get() public méthode

Relative bulk get method.
public Get ( byte dst ) : void
dst byte
Résultat void

GetBuffer() public méthode

Returns the array of unsigned bytes from which this stream was created.
public GetBuffer ( ) : byte[]
Résultat byte[]

GetHashCode() public méthode

Returns the current hash code of this buffer.
public GetHashCode ( ) : int
Résultat int

GetInt() public méthode

Reads a 4-byte signed integer using network byte order encoding.
public GetInt ( ) : int
Résultat int

GetShort() public méthode

Reads a 2-byte signed integer using network byte order encoding.
public GetShort ( ) : short
Résultat short

Mark() public méthode

Sets this buffer's bookmark at its position.
public Mark ( ) : long
Résultat long

Put() public static méthode

Puts an in buffer stream onto an out buffer stream and returns the bytes written.
public static Put ( ByteBuffer output, ByteBuffer input, int numBytesMax ) : int
output ByteBuffer
input ByteBuffer
numBytesMax int
Résultat int

Put() public méthode

This method transfers the bytes remaining in the given source buffer into this buffer. If there are more bytes remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no bytes are transferred and a BufferOverflowException is thrown. Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.
public Put ( ByteBuffer src ) : void
src ByteBuffer The source buffer from which bytes are to be read; must not be this buffer.
Résultat void

Put() public méthode

Transfers the specified number of bytes from the given source buffer into this buffer.
public Put ( ByteBuffer src, int count ) : void
src ByteBuffer The source buffer from which bytes are to be read; must not be this buffer.
count int Number of bytes to transfer.
Résultat void

Put() public méthode

Writes the given byte into this buffer at the current position, and then increments the position.
public Put ( byte value ) : void
value byte
Résultat void

Put() public méthode

Relative bulk put method. This method transfers bytes into this buffer from the given source array. If there are more bytes to be copied from the array than remain in this buffer, that is, if length > remaining(), then no bytes are transferred and a BufferOverflowException is thrown. Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.
public Put ( byte src, int offset, int length ) : void
src byte The array from which bytes are to be read.
offset int The offset within the array of the first byte to be read; must be non-negative and no larger than the array length.
length int The number of bytes to be read from the given array; must be non-negative and no larger than length - offset.
Résultat void

Put() public méthode

public Put ( int index, UInt16 value ) : void
index int
value System.UInt16
Résultat void

Put() public méthode

Absolute put method for writing an int value. Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index.
public Put ( int index, UInt32 value ) : void
index int The index at which the bytes will be written.
value System.UInt32 The int value to be written.
Résultat void

Put() public méthode

Absolute put method. Writes the given byte into this buffer at the given index.
public Put ( int index, byte value ) : void
index int The index.
value byte The byte to write.
Résultat void

PutInt() public méthode

Relative put method for writing an int value. Writes four bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by four.
public PutInt ( int value ) : void
value int The int value to be written.
Résultat void

PutInt() public méthode

Absolute put method for writing an int value. Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index.
public PutInt ( int index, int value ) : void
index int The index at which the bytes will be written.
value int The int value to be written.
Résultat void

PutShort() public méthode

Writes a 16-bit unsigned integer to the current position.
public PutShort ( short value ) : void
value short A 16-bit unsigned integer.
Résultat void

Read() public méthode

Relative bulk get method. This method transfers bytes from this buffer into the given destination array. An invocation of this method behaves in exactly the same way as the invocation buffer.Get(a, 0, a.Length)
public Read ( byte buffer ) : int
buffer byte An array of bytes.
Résultat int

Read() public méthode

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public Read ( byte buffer, int offset, int count ) : int
buffer byte An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offset int The zero-based byte offset in buffer at which to begin storing the data read from the current stream.
count int The maximum number of bytes to be read from the current stream.
Résultat int

ReadByte() public méthode

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
public ReadByte ( ) : int
Résultat int

ReadBytes() public méthode

Reads count bytes from the current stream into a byte array and advances the current position by count bytes.
public ReadBytes ( int count ) : byte[]
count int
Résultat byte[]

ReadReverseInt() public méthode

Reads a 4-byte signed integer.
public ReadReverseInt ( ) : int
Résultat int

ReadUInt24() public méthode

public ReadUInt24 ( ) : int
Résultat int

Reset() public méthode

Resets this buffer's position to the previously-marked position. Invoking this method neither changes nor discards the mark's value.
public Reset ( ) : void
Résultat void

Rewind() public méthode

Rewinds this buffer. The position is set to zero and the mark is discarded.
public Rewind ( ) : void
Résultat void

Seek() public méthode

Sets the position within the current stream.
public Seek ( long offset, SeekOrigin origin ) : long
offset long A byte offset relative to the origin parameter.
origin SeekOrigin A value of type SeekOrigin indicating the reference point used to obtain the new position.
Résultat long

SetLength() public méthode

Sets the length of the current stream.
public SetLength ( long value ) : void
value long The desired length of the current stream in bytes.
Résultat void

Skip() public méthode

Forwards the position of this buffer as the specified size bytes.
public Skip ( int size ) : void
size int
Résultat void

ToArray() public méthode

Writes the stream contents to a byte array, regardless of the Position property.
This method omits unused bytes in ByteBuffer from the array. To get the entire buffer, use the GetBuffer method.
public ToArray ( ) : byte[]
Résultat byte[]

ToString() public méthode

Returns a string summarizing the state of this buffer.
public ToString ( ) : string
Résultat string

Wrap() public static méthode

Wraps a byte array into a buffer. The new buffer will be backed by the given byte array; that is, modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity and limit will be array.length, its position will be zero, and its mark will be undefined.
public static Wrap ( byte array ) : ByteBuffer
array byte
Résultat ByteBuffer

Wrap() public static méthode

Wraps a byte array into a buffer. The new buffer will be backed by the given byte array; that is, modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity will be array.length, its position will be offset, its limit will be offset + length, and its mark will be undefined.
public static Wrap ( byte array, int offset, int length ) : ByteBuffer
array byte Byte array to wrap.
offset int Offset in the byte array.
length int
Résultat ByteBuffer

Write() public méthode

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
public Write ( byte buffer, int offset, int count ) : void
buffer byte An array of bytes. This method copies count bytes from buffer to the current stream.
offset int The zero-based byte offset in buffer at which to begin copying bytes to the current stream.
count int The number of bytes to be written to the current stream.
Résultat void

WriteByte() public méthode

Writes a byte to the current position in the stream and advances the position within the stream by one byte.
public WriteByte ( byte value ) : void
value byte The byte to write to the stream.
Résultat void

WriteMediumInt() public méthode

Writes a 32-bit signed integer to the current position using variable length unsigned 29-bit integer encoding.
public WriteMediumInt ( int value ) : void
value int A 32-bit signed integer.
Résultat void

WriteReverseInt() public méthode

public WriteReverseInt ( int value ) : void
value int
Résultat void

this() public méthode

public this ( int index ) : byte
index int
Résultat byte