XBinder C# Runtime Library  2.7
Public Member Functions | List of all members
com.objsys.xbinder.runtime.XBByteArray Class Reference

XBByteArray is a lightweight wrapper around a byte array. It is intended to help with the reuse an array by combining an array ("the buffer") with a size field. More...

Inheritance diagram for com.objsys.xbinder.runtime.XBByteArray:

Public Member Functions

 XBByteArray (int initialCapacity)
 Create XBByteArray object with the given initial capacity. More...
 
 XBByteArray (sbyte[] initialData)
 Create XBByteArray object using the given array as its initial array. A copy is NOT made. The size will be the size of the array. More...
 
virtual sbyte [] internalArray ()
 Get the internal array. Does NOT make a copy. This has obvious danger, but it helps work with API's that expect an arrays. This is useful for APIs that require an array as input, and avoids copying data. If you must give the array to an API for output, you may want to call manage() to update the size (and buffer, if necessary). More...
 
Object Clone ()
 Return a copy of this object. The copy will contain the same bytes. The size of the internal buffer is unspecified. More...
 
virtual int CompareTo (System.Object obj)
 Compare two XBByteArray objects. A return of zero indicates the objects have the same bytes. A non-zero return indicates the first byte where they differ. More precisely: Return 0 if host and obj have the same number of bytes and (if the number of bytes > 0) all bytes are equal. Otherwise, let retVal be the returned value. Then the following is true: If |retVal| == 1, the arrays have no bytes in common. Otherwise, host[x] == obj[x] for all x 0..|retVal| - 2 if retVal < 0, then host[-retVal-1] < obj[-retVal-1] OR host.size < obj.size else if retVal > 0, then host[retVal-1] > obj[retVal-1] OR host.size > obj.size More...
 
virtual void add (sbyte value_Renamed)
 Add given value to end of buffer. This sets buffer[size] = value, updates size, and expands capacity, if necessary. More...
 
virtual void ensureCapacity (int capacity, int preserveLength)
 Ensure the buffer's length is at least the given capacity. Preserve data from the buffer up preserveLength. Size will be set to preserveLength. More...
 
virtual void ensureCapacity (int capacity)
 Ensure the buffer is at least the given size. Preserves contents of existing buffer (size does not change). More...
 
virtual sbyte get_Renamed (int index)
 Return value at given index. More...
 
virtual void initialize (int capacity)
 Initialize the buffer so that: capacity is at least as given size is set to given capacity 0..size-1 are initialized More...
 
virtual void setInternalArray (sbyte[] newBuffer, int size)
 Give this object a new array to manage. A copy is NOT made. (Note: you can simply change the size by passing the existing array.) More...
 
virtual void reset ()
 Reset size to 0. More...
 
virtual int size ()
 Return the number of valid bytes in the array. More...
 
virtual sbyte [] toArray ()
 Return a newly allocated array, holding the data from this object. The new array will have length == size. More...
 
override System.String ToString ()
 Provides a hex binary representation of the string. More...
 
virtual void writeToStream (System.IO.Stream stream)
 Write the data of this array to the given stream. More...
 

Detailed Description

XBByteArray is a lightweight wrapper around a byte array. It is intended to help with the reuse an array by combining an array ("the buffer") with a size field.

Usage: Dealing with an API that writes to an array you might:

An API designed for this class may use add and get to assign/retrieve values from the array without worrying about capacity.

This class is used in preference to an ArrayList because ArrayList requires boxing/unboxing of primitive values.

Thread Safety: This class does not include synchronization. It is not recommended that you share instances of this class amongst threads.

<author> Kevin

</author>

Constructor & Destructor Documentation

◆ XBByteArray() [1/2]

com.objsys.xbinder.runtime.XBByteArray.XBByteArray ( int  initialCapacity)

Create XBByteArray object with the given initial capacity.

Parameters
initialCapacity

◆ XBByteArray() [2/2]

com.objsys.xbinder.runtime.XBByteArray.XBByteArray ( sbyte []  initialData)

Create XBByteArray object using the given array as its initial array. A copy is NOT made. The size will be the size of the array.

Parameters
initialData

Member Function Documentation

◆ add()

virtual void com.objsys.xbinder.runtime.XBByteArray.add ( sbyte  value_Renamed)
virtual

Add given value to end of buffer. This sets buffer[size] = value, updates size, and expands capacity, if necessary.

Parameters
value

◆ Clone()

Object com.objsys.xbinder.runtime.XBByteArray.Clone ( )

Return a copy of this object. The copy will contain the same bytes. The size of the internal buffer is unspecified.

◆ CompareTo()

virtual int com.objsys.xbinder.runtime.XBByteArray.CompareTo ( System.Object  obj)
virtual

Compare two XBByteArray objects. A return of zero indicates the objects have the same bytes. A non-zero return indicates the first byte where they differ. More precisely: Return 0 if host and obj have the same number of bytes and (if the number of bytes > 0) all bytes are equal. Otherwise, let retVal be the returned value. Then the following is true: If |retVal| == 1, the arrays have no bytes in common. Otherwise, host[x] == obj[x] for all x 0..|retVal| - 2 if retVal < 0, then host[-retVal-1] < obj[-retVal-1] OR host.size < obj.size else if retVal > 0, then host[retVal-1] > obj[retVal-1] OR host.size > obj.size

Parameters
obj
Returns

◆ ensureCapacity() [1/2]

virtual void com.objsys.xbinder.runtime.XBByteArray.ensureCapacity ( int  capacity,
int  preserveLength 
)
virtual

Ensure the buffer's length is at least the given capacity. Preserve data from the buffer up preserveLength. Size will be set to preserveLength.

Parameters
capacity
preserveLength

<throws> ArrayIndexOutOfBoundsException if preserveLength < 0 or </throws>

preserveLength > size.

◆ ensureCapacity() [2/2]

virtual void com.objsys.xbinder.runtime.XBByteArray.ensureCapacity ( int  capacity)
virtual

Ensure the buffer is at least the given size. Preserves contents of existing buffer (size does not change).

Parameters
capacity

◆ get_Renamed()

virtual sbyte com.objsys.xbinder.runtime.XBByteArray.get_Renamed ( int  index)
virtual

Return value at given index.

An array must be under management.

<throws> ArrayIndexOutOfBoundsException if index < 0 or index >= size() </throws>

◆ initialize()

virtual void com.objsys.xbinder.runtime.XBByteArray.initialize ( int  capacity)
virtual

Initialize the buffer so that: capacity is at least as given size is set to given capacity 0..size-1 are initialized

◆ internalArray()

virtual sbyte [] com.objsys.xbinder.runtime.XBByteArray.internalArray ( )
virtual

Get the internal array. Does NOT make a copy. This has obvious danger, but it helps work with API's that expect an arrays. This is useful for APIs that require an array as input, and avoids copying data. If you must give the array to an API for output, you may want to call manage() to update the size (and buffer, if necessary).

Returns

◆ reset()

virtual void com.objsys.xbinder.runtime.XBByteArray.reset ( )
virtual

Reset size to 0.

◆ setInternalArray()

virtual void com.objsys.xbinder.runtime.XBByteArray.setInternalArray ( sbyte []  newBuffer,
int  size 
)
virtual

Give this object a new array to manage. A copy is NOT made. (Note: you can simply change the size by passing the existing array.)

Parameters
newBufferThe new buffer to manage.
sizeThe new size (0..newBuffer.length)

◆ size()

virtual int com.objsys.xbinder.runtime.XBByteArray.size ( )
virtual

Return the number of valid bytes in the array.

Returns

◆ toArray()

virtual sbyte [] com.objsys.xbinder.runtime.XBByteArray.toArray ( )
virtual

Return a newly allocated array, holding the data from this object. The new array will have length == size.

Returns

◆ ToString()

override System.String com.objsys.xbinder.runtime.XBByteArray.ToString ( )

Provides a hex binary representation of the string.

◆ writeToStream()

virtual void com.objsys.xbinder.runtime.XBByteArray.writeToStream ( System.IO.Stream  stream)
virtual

Write the data of this array to the given stream.