serialize data into memory More...
Public Member Functions | |
MemBlock | getDataPtr () |
get the serialized data More... | |
number | getDataSize () |
get the size of the serialized data More... | |
serialize_1 (int val) | |
serialize 1 signed byte More... | |
serialize_1u (uint val) | |
serialize 1 unsigned byte More... | |
serialize_2 (int val) | |
serialize 2 signed bytes More... | |
serialize_2u (uint val) | |
serialize 2 unsigned bytes More... | |
serialize_3u (uint val) | |
serialize 3 unsigned bytes More... | |
serialize_4 (int val) | |
serialize 4 signed bytes More... | |
serialize_4u (uint val) | |
serialize 4 unsigned bytes More... | |
serialize_8 (number val) | |
serialize 8 signed bytes More... | |
serialize_8u (number val) | |
serialize 8 unsigned bytes More... | |
serialize_bool (boolean val) | |
serialize a 1 bit boolean value More... | |
serialize_color (Color val) | |
serialize a Color More... | |
serialize_d (number val) | |
serialize a double precision floating point number More... | |
serialize_f (number val) | |
serialize a single precision floating point number More... | |
serialize_mem (BinaryString mem) | |
serialize a binary string More... | |
serialize_mem (MemBlock mem) | |
serialize a block of memory More... | |
serialize_obj (ISerializable obj) | |
serialize a serializable object More... | |
serialize_offset (Offset val) | |
serialize an Offset's (x,y) values More... | |
serialize_point (Point val) | |
serialize a Point's (x,y) values More... | |
serialize_quad (Quad val) | |
serialize a Quad's (x,y) point values More... | |
serialize_rect (Rect val) | |
serialize a Rect's left, top, right, bottom values More... | |
serialize_ref (object obj) | |
serialize_rotr (RotatedRect val) | |
serialize a RotatedRect's data values More... | |
serialize_str (string str) | |
serialize a JavaScript string More... | |
serialize_uint (uint val) | |
serialize up to 4 unsigned bytes More... | |
serialize_vector (Vector val) | |
serialize a Vector's (x,y) values More... | |
uint | sizeof_1 (int val) |
uint | sizeof_1u (uint val) |
uint | sizeof_2 (int val) |
uint | sizeof_2u (uint val) |
uint | sizeof_3u (uint val) |
uint | sizeof_4 (int val) |
uint | sizeof_4u (uint val) |
uint | sizeof_8 (int val) |
uint | sizeof_8u (uint val) |
uint | sizeof_bool (boolean val) |
get the number of bytes used to serialize the given boolean More... | |
uint | sizeof_color (Color val) |
get the number of bytes used to serialize the given Color More... | |
uint | sizeof_d (number val) |
uint | sizeof_f (number val) |
uint | sizeof_mem (BinaryString mem) |
uint | sizeof_mem (MemBlock mem) |
get the number of bytes used to serialize the given block of memory More... | |
uint | sizeof_obj (ISerializable val) |
get the number of bytes used to serialize the given object, including any objects that it serializes More... | |
uint | sizeof_offset (Offset val) |
get the number of bytes used to serialize the given Offset More... | |
uint | sizeof_point (Point val) |
get the number of bytes used to serialize the given Point More... | |
uint | sizeof_quad (Quad val) |
get the number of bytes used to serialize the given Quad More... | |
uint | sizeof_rect (Rect val) |
get the number of bytes used to serialize the given Rect More... | |
uint | sizeof_ref (object val) |
uint | sizeof_rotr (RotatedRect val) |
get the number of bytes used to serialize the given RotatedRect More... | |
uint | sizeof_str (string val) |
get the number of bytes used to serialize the given string More... | |
uint | sizeof_uint (uint val) |
get the number of bytes used to serialize the given unsigned integer More... | |
uint | sizeof_vector (Vector val) |
get the number of bytes used to serialize the given Vector More... | |
serialize data into memory
Serializer stores complex data into memory in a way that it can be read back from a Deserializer. It can correctly store entire object hierarchies without duplication.
The data stream format is platform neutral, so it is suitable for saved game files and network messages between client and server, using NetConnection.send(ISerializable).
Serializer writes tags at key points that the deserialization process can use to be sure things haven't gotten out of sync. However, if you want your serialized data streams to be versioned, you will have to add that yourself; either on a per object/message basis or for an entire saved stream.
getDataPtr | ( | ) |
get the serialized data
getDataSize | ( | ) |
get the size of the serialized data
serialize_1 | ( | int | val | ) |
serialize 1 signed byte
Write a one byte value in the range of −127 to 127 into the data stream.
serialize_1u | ( | uint | val | ) |
serialize 1 unsigned byte
Write a one byte value in the range of 0 to 255 into the data stream.
serialize_2 | ( | int | val | ) |
serialize 2 signed bytes
Write a two byte value in the range of −32,767 to 32,767 into the data stream.
serialize_2u | ( | uint | val | ) |
serialize 2 unsigned bytes
Write a two byte value in the range of 0 to 65,535 into the data stream.
serialize_3u | ( | uint | val | ) |
serialize 3 unsigned bytes
Write a three byte value in the range of 0 to 16,777,216 into the data stream.
serialize_4 | ( | int | val | ) |
serialize 4 signed bytes
Write a four byte value in the range of −2,147,483,647 to 2,147,483,647 into the data stream.
serialize_4u | ( | uint | val | ) |
serialize 4 unsigned bytes
Write a four byte value in the range of 0 to 4,294,967,295 into the data stream.
serialize_8 | ( | number | val | ) |
serialize 8 signed bytes
Write an eight byte value in the range of −9,223,372,036,854,775,807 to 9,223,372,036,854,775,807 into the data stream.
serialize_8u | ( | number | val | ) |
serialize 8 unsigned bytes
Write an eight byte value in the range of 0 to 18,446,744,073,709,551,615 into the data stream.
serialize_bool | ( | boolean | val | ) |
serialize a 1 bit boolean value
Write a one bit boolean value (true or false) into the data stream. This is optimized collect up to 8 bits in a single byte, so writing a number of boolean values is very space efficient.
serialize_color | ( | Color | val | ) |
serialize a Color
Write a Color's RBGA values into the data stream.
serialize_d | ( | number | val | ) |
serialize a double precision floating point number
Write a double precision floating point value in the range of 10−308 to 10308 with 17 significant digits into the data stream.
serialize_f | ( | number | val | ) |
serialize a single precision floating point number
Write a single precision floating point value in the range of 10−38 to 1038 with 9 significant digits into the data stream.
serialize_mem | ( | BinaryString | mem | ) |
serialize a binary string
Binary strings are a Node.js way of handling blocks of arbitrary binary data. This serializes that data into the stream.
serialize_mem | ( | MemBlock | mem | ) |
serialize a block of memory
MemBlocks are the game engine's way of handling blocks of arbitrary binary data in JavaScript. This serializes that data into the stream.
serialize_obj | ( | ISerializable | obj | ) |
serialize a serializable object
This serializes the object and all its data into the stream. It does this by calling the ISerializable object's serialize method, which would then in turn call serializer methods for each of the object's data members. If the given object's data members include other serializable objects, then serialize_obj() is called recursively to serialize those objects.
The Serializer keeps track of what objects have already been added to the stream, and simply serializes a reference to any object that has already been serialized if serialize_obj is called for it again.
serialize_offset | ( | Offset | val | ) |
serialize an Offset's (x,y) values
Write an Offset's x and y values into the data stream. This is optimized for certain common cases, such as a (0,0) offset and small positive numbers.
serialize_point | ( | Point | val | ) |
serialize a Point's (x,y) values
Write a Point's x and y values into the data stream. This is optimized for certain common cases, such as Point(0,0) and small positive numbers.
serialize_quad | ( | Quad | val | ) |
serialize a Quad's (x,y) point values
Write a Quad's four sets of x and y values into the data stream.
serialize_rect | ( | Rect | val | ) |
serialize a Rect's left, top, right, bottom values
Write a Rect's left, top, right, and bottom values into the data stream. This is optimized for certain common cases, such as empty rectangles and small positive numbers.
serialize_ref | ( | object | obj | ) |
serialize_rotr | ( | RotatedRect | val | ) |
serialize a RotatedRect's data values
Write a RotatedRect's left, top, right, bottom, radians and centerOffset values into the data stream. This is optimized for certain common cases, such as empty rectangles, small positive numbers, and no center offset.
serialize_str | ( | string | str | ) |
serialize a JavaScript string
Writes the string into the data stream.
serialize_uint | ( | uint | val | ) |
serialize up to 4 unsigned bytes
Write a value in the range of 0 to 4,294,967,295 into the data stream. This is optimized for cases where the number is usually small, but can sometimes be quite large. If the number is usually large, you are better off just using serialize_4u.
serialize_vector | ( | Vector | val | ) |
serialize a Vector's (x,y) values
Write a Vector's x and y values into the data stream. This is optimized for certain common cases, such as a (0,0) offset and small positive numbers.
uint sizeof_1 | ( | int | val | ) |
uint sizeof_1u | ( | uint | val | ) |
uint sizeof_2 | ( | int | val | ) |
uint sizeof_2u | ( | uint | val | ) |
uint sizeof_3u | ( | uint | val | ) |
uint sizeof_4 | ( | int | val | ) |
uint sizeof_4u | ( | uint | val | ) |
uint sizeof_8 | ( | int | val | ) |
uint sizeof_8u | ( | uint | val | ) |
sizeof_bool | ( | boolean | val | ) |
get the number of bytes used to serialize the given boolean
Does not actually write any data to stream
sizeof_color | ( | Color | val | ) |
get the number of bytes used to serialize the given Color
Does not actually write any data to stream
uint sizeof_d | ( | number | val | ) |
uint sizeof_f | ( | number | val | ) |
uint sizeof_mem | ( | BinaryString | mem | ) |
sizeof_mem | ( | MemBlock | mem | ) |
get the number of bytes used to serialize the given block of memory
Does not actually write any data to stream
sizeof_obj | ( | ISerializable | obj | ) |
get the number of bytes used to serialize the given object, including any objects that it serializes
Does not actually write any data to stream
sizeof_offset | ( | Offset | val | ) |
get the number of bytes used to serialize the given Offset
Does not actually write any data to stream
sizeof_point | ( | Point | val | ) |
get the number of bytes used to serialize the given Point
Does not actually write any data to stream
sizeof_quad | ( | Quad | val | ) |
get the number of bytes used to serialize the given Quad
Does not actually write any data to stream
sizeof_rect | ( | Rect | val | ) |
get the number of bytes used to serialize the given Rect
Does not actually write any data to stream
uint sizeof_ref | ( | object | val | ) |
sizeof_rotr | ( | RotatedRect | val | ) |
get the number of bytes used to serialize the given RotatedRect
Does not actually write any data to stream
sizeof_str | ( | string | str | ) |
get the number of bytes used to serialize the given string
Does not actually write any data to stream
sizeof_uint | ( | uint | n | ) |
get the number of bytes used to serialize the given unsigned integer
Does not actually write any data to stream.
sizeof_vector | ( | Vector | val | ) |
get the number of bytes used to serialize the given Vector
Does not actually write any data to stream