User Tools

Site Tools


en:code:core:rawdata

RawData

This object represents raw, unformatted data.

Functions

RawData

Constructor function.

Syntax

var myObject = new RawData();
var myObject = new RawData(otherRawData);

Arguments

  1. otherRawData - (RawData) other RawData to copy

Exceptions

  • (ParameterTypeError) incorrect parameter type
  • (ParameterCountError) incorrect parameter count

Example

Create an empty RawData.

var myObject = new RawData();

Create a RawData representing a copy of otherRawData.

var myObject = new RawData(otherRawData);

Methods

clone

Returns a copy of this RawData.

Syntax

myObject.clone();

Returns

  • (RawData) a copy of this RawData

Example

var copyOfMyObject = myObject.clone();

equals

Returns true if this RawData and another are referencing the same data.

Syntax

myObject.equals(other);

Arguments

  1. other - (RawData) another RawData

Returns

  • (bool) true if other is referencing the same data

Example

if(myFirstObject.equals(mySecondObject))
	//Do something

toString

Returns a string representing this RawData.

Syntax

myObject.toString();

Returns

  • (string) a string representing this RawData

Example

Console.print(myObject.toString());

Notes

This method is automatically called when trying to convert a RawData to a string.

append

Appends data to this RawData.

Syntax

myObject.append(data);

Arguments

  1. data - (mixed) the data to append

Returns

  • (RawData) this RawData

Example

myObject.append("some text");
myObject.append(1337);

chop

Removes n bytes from the end of this RawData.

Syntax

myObject.chop(n);

Arguments

  1. n - (integer) the number of bytes to remove

Returns

  • (RawData) this RawData

clear

Clears the content of this RawData.

Syntax

myObject.clear();

Returns

  • (RawData) this RawData

contains

Returns true if this RawData contains an occurrence of some other data.

Syntax

myObject.contains(data);

Arguments

  1. data - (mixed) the data to search for

Returns

  • (boolean) true if this RawData contains an occurrence of some other data

count

Returns the number of occurrences of some other data in this RawData.

Syntax

myObject.count(data);

Arguments

  1. data - (mixed) the data to search for

Returns

  • (integer) the number of occurrences of some other data in this RawData

endsWith

Returns true if this RawData ends with some other data.

Syntax

myObject.endsWith(data);

Arguments

  1. data - (mixed) some other data

Returns

  • (boolean) true if this RawData ends with some other data

indexOf

Returns the position of the first occurrence of some data, starting at from.

Syntax

myObject.indexOf(data);
myObject.indexOf(data, from);

Arguments

  1. data - (mixed) some other data
  2. from - (integer) the position where to start

Returns

  • (integer) the position where the first occurrence was found, or -1 if it cannot be found

isEmpty

Returns true if this RawData is empty.

Syntax

myObject.isEmpty();

Returns

  • (boolean) true if this RawData is empty

lastIndexOf

Returns the position of the last occurrence of some data.

Syntax

myObject.lastIndexOf(data);

Arguments

  1. data - (mixed) some other data

Returns

  • (integer) the position where the last occurrence was found, or -1 if it cannot be found

left

Returns a new RawData that contains the leftmost len bytes of this RawData.

Syntax

myObject.left(len);

Arguments

  1. len - (integer) the number of bytes

Returns

  • (integer) the leftmost len bytes of this RawData

length

Returns the length of this RawData.

Syntax

myObject.length();

Returns

  • (integer) the length of this RawData.

mid

Returns a new RawData containing len bytes, starting at position pos.

Syntax

myObject.mid(pos);
myObject.mid(pos, len);

Arguments

  1. pos - (integer) the starting position
  2. len - (integer) the number of bytes

Returns

  • (RawData) the new RawData

prepend

Prepends data to this RawData.

Syntax

myObject.prepend(data);

Arguments

  1. data - (mixed) the data to prepend

Returns

  • (RawData) this RawData

Example

myObject.prepend("some text");
myObject.prepend(1337);

remove

Remove len bytes, starting at position pos.

Syntax

myObject.remove(pos);
myObject.remove(pos, len);

Arguments

  1. pos - (integer) the starting position
  2. len - (integer) the number of bytes

Returns

  • (RawData) this RawData

replace

Replace every occurrence of before with after.

Syntax

myObject.replace(before, after);

Arguments

  1. before - (string) the string to find
  2. after - (string) the replacement

Returns

  • (RawData) this RawData

resize

Resizes this RawData.

Syntax

myObject.resize(size);

Arguments

  1. size - (integer) the new size

Returns

  • (RawData) this RawData

Returns a new RawData that contains the rightmost len bytes of this RawData.

Syntax

myObject.right(len);

Arguments

  1. len - (integer) the number of bytes

Returns

  • (integer) the rightmost len bytes of this RawData

setData

Sets the data of this RawData.

Syntax

myObject.setData(data);

Arguments

  1. data - (mixed) the new data

Returns

  • (RawData) this RawData

size

Returns the size of this RawData.

Syntax

myObject.size();

Returns

  • (integer) the size of this RawData.

startsWith

Returns true if this RawData starts with some other data.

Syntax

myObject.startsWith(data);

Arguments

  1. data - (mixed) some other data

Returns

  • (boolean) true if this RawData starts with some other data

convertToNumber

Try to convert this RawData to a number.

Syntax

myObject.convertToNumber();

Returns

  • (float) this RawData as a number

convertToString

Try to convert this RawData to a string.

Syntax

myObject.convertToString(encoding);

Arguments

  1. encoding - (Encoding) the encoding to use

Returns

  • (string) this RawData as a string

truncate

Truncates the RawData at index position pos.

Syntax

myObject.truncate(pos);

Arguments

  1. pos - (integer) the index position

Returns

  • (RawData) this RawData
en/code/core/rawdata.txt · Last modified: 2021/02/13 11:23 by 127.0.0.1