ByteBuffer Class

The class whose instances store an array of bytes and populates methods to work with it. It is interchangeable with an array of bytes. It is useable especially in compact framework where List<byte> type is not accesible. The main reason for using is the communication with remote devices. See Communicator class.

Definition

Namespace: OddPrg
Assembly: OddPrg (in OddPrg.dll) Version: 2.0.0.0 (2.0.0.0)
C#
public class ByteBuffer : IEnumerable
Inheritance
Object    ByteBuffer
Implements
IEnumerable

Constructors

ByteBuffer Creates a new empty byte buffer instance.
ByteBuffer(Byte) Creates a new instance of byte buffer and fills it with specified bytes.
ByteBuffer(ByteBuffer) Creates a new instance of byte buffer and copies another byte buffer to it.
ByteBuffer(Int32) Creates a new instance of byte buffer and fills it with count zeros.
ByteBuffer(String) Creates a new instance of byte buffer and fills it byte representations of ASCII characters from a specified string. Every character is added as a LSB byte.
ByteBuffer(Byte, Byte) Creates a new instance of byte buffer and fills it with specified two byte arrays.
ByteBuffer(Byte, Int32) Creates a new instance of byte buffer and fills it with specified count of bytes from a.

Properties

AsBase64String Gets/Sets ByteBuffer as Base64 string
AsHexStringLSB Represents this instance as string, every byte as two characeters - hexadecimal representation. The LSB is first.
AsHexStringLSBSeparated Returns this instance as string, every byte as two characeters - hexadecimal representation, separated by '|'. The LSB is first.
AsHexStringMSB Represents this instance as string, every byte as two characeters - hexadecimal representation. The MSB is first.
Count Returns the count of bytes stored in this instance.
Item Access to particular bytes of this instance. Index i goes from 0 to Count - 1.

Methods

Add(Byte) Adds one byte to the end of the buffer.
Add(Byte) Adds bytes to the end of the buffer.
Add(ByteBuffer) Adds bytes to the end of the buffer.
Add(Object) 
Add(String) Adds ASCII representation of a specified string to the end of the buffer. Every character is added as a LSB byte.
Add(Byte, Int32, Int32) Adds a part of bytes to the end of the buffer.
Add(ByteBuffer, Int32, Int32) Adds a part of bytes to the end of the buffer.
Clear Clears the buffer
CompareLSBTo 
CompareMSBTo Compares this instance to a specified instance of ByteBuffer lexicographically from the MSB first (as long numbers). It cannot be animplementation of IComparable interface because CF does not support it.
Equals 
FromHexString Converts hexadecimal string to byte array. Each two charecters are converted to one byte.
GetEnumerator IEnumerable implemetation for using in foreach.
GetRange(Int32) Returns part of the byte array starting at specified index
GetRange(Int32, Int32) Returns part of the byte array starting at specified index and having specified size
IndexOf(Byte) Returns the position of specified byte in the buffer
IndexOf(ByteBuffer) Returns the position of specified sequence of bytes in the buffer
IndexOf(Char) Returns the position of specified char in the buffer. ASCII encoding is used.
IndexOf(String) Returns the position of specified string in the buffer. ASCII encoding is used.
IndexOf(Byte, Int32) Returns the position of specified sequence of bytes in the buffer
IndexOf(ByteBuffer, Int32) Returns the position of specified sequence of bytes in the buffer, strating searching at a specified index.
Insert Inserts a byte at the specified position in the buffer.
LastIndexOf Returns the last position of specified byte in the buffer
Parse Conversion from string to ByteBuffer. It supposes ASCII encoding
RemoveRange(Int32) Deletes the count bytes from the beginning of the buffer.
RemoveRange(Int32, Int32) Deletes count bytes from the buffer starting from startIndex. If parameters point outside the buffer, only available bytes are deleted.
Split(Int32) Separates source array to the portions of specified length
Split(ByteBuffer, Boolean) Separates source array in locations where occures specified byte sequence
Swap Swaps array bytes in reverse order
ToString Conversion to string. Converts source bytes to ASCII characters Převod bufferu na string. Pokud obsahuje nulové bajty, tak to může výsledný řetězec zkrátit (pouze při zobrazování). Podívej se také na AsHexString.
(Overrides ObjectToString)
Trim Removes specified bytes from the beginning and the end of buffer.
TrimEnd Removes specified bytes from the end of buffer.
TrimStart Removes specified bytes from the beginning of buffer.

Operators

Addition(ByteBuffer, ByteBuffer) Creates new ByteBuffer instance as concatenation of two source ByteBuffers
(Byte to ByteBuffer) Cast of byte array to the ByteBuffer
(ByteBuffer to Byte) Cast of ByteBuffer to array of bytes

See Also