Core runtime library providing primitive types (Bool, Byte, Char, Int, Float, String), the Ref wrappers and array helpers, and system utilities (console, files, threads, sockets). Collections are not here: they are in gen_collect.obl. Every Objeck program links against this bundle automatically via lang.obl.
ByteBuffer
Byte array buffer
Operations
Append # native
Appends a byte array
method : public : native : Append(array:Byte[]) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| array | Byte | array to be copied |
Append # native
Appends a byte array
method : public : native : Append(length:Int, array:Byte[]) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| length | Int | number of characters to copy |
| array | Byte | array to be copied |
Append #
Appends a byte
method : public : Append(c:Byte) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| c | Byte | byte to append |
Capacity #
Gets the current buffer's storage capacity. That is the number of bytes the buffer will hold before it is resized for growth.
method : public : Capacity() ~ IntReturn
| Type | Description |
|---|---|
| Int | buffer capacity |
Clone #
Clones the object instance
method : public : Clone() ~ System.ByteBufferReturn
| Type | Description |
|---|---|
| ByteBuffer | cloned the object instance |
Compare #
Compares two objects
method : public : Compare(rhs:System.Compare) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| rhs | Compare | compare object |
Return
| Type | Description |
|---|---|
| Int | 0 if equal, -1 if right-hand side i greater, 1 if left-hand side is greater |
Get # native
Returns the byte at the given index
method : public : native : Get(index:Int) ~ CharParameters
| Name | Type | Description |
|---|---|---|
| index | Int | index offset |
Return
| Type | Description |
|---|---|
| Char | byte at index |
HashID # native
Returns a unique hash ID for a given byte sequence
method : public : native : HashID() ~ IntReturn
| Type | Description |
|---|---|
| Int | hash ID |
New # constructor
Copy constructor: the buffer holds a copy of the bytes, so later changes to the array do not show through it (ByteBuffer->Wrap takes an array without copying it)
New(buffer:Byte[])Parameters
| Name | Type | Description |
|---|---|---|
| buffer | Byte | bytes to copy |
Raw #
Gets the raw reference to the underlying byte array
method : public : Raw() ~ Byte[]Return
| Type | Description |
|---|---|
| Byte | raw byte array reference |
Size #
Return the size of the string
method : public : Size() ~ IntReturn
| Type | Description |
|---|---|
| Int | size of the string |
ToByteArray #
Returns a trimmed byte array
method : public : ToByteArray() ~ Byte[]Return
| Type | Description |
|---|---|
| Byte | byte array |
ToString #
Returns a string representation of the byte buffer
method : public : ToString() ~ StringReturn
| Type | Description |
|---|---|
| String | string representation of the byte buffer |
Wrap # function
Makes a buffer over an array without copying it. The buffer takes the array as its contents: it must not be changed afterwards, and Raw() returns it until an append outgrows it.
function : Wrap(buffer:Byte[]) ~ ByteBufferParameters
| Name | Type | Description |
|---|---|---|
| buffer | Byte | bytes to take |
Return
| Type | Description |
|---|---|
| ByteBuffer | buffer holding the array's bytes |
Example
bytes := Byte->New[4];
buffer := ByteBuffer->Wrap(bytes);
buffer->Size()->PrintLine(); # 4