com.amx.duet.tools.io
Interface IStruct

All Superinterfaces:
IBinaryMarshall

public interface IStruct
extends IBinaryMarshall

Interface used to differentiate marshalled data types from marshalled classes. If you want to marshall a class simply implement this interface and the marshalling functions

Here's an example of a marshalled class:

 public class RoomDetails implements IStruct
 {
 	public boolean bValid = false;
 	public String sPrestigeLevel = "";
 	public int nNumberSeats = 0;
 
 	public int binaryEncode(ObjectRef buffer, ObjectRef rPos)
 	{
 		int ret = 0;
 		ByteArrayOutputStream stream = new ByteArrayOutputStream();
 		ObjectRef encoder = new ObjectRef(0);
 
 		// Write start
 		stream.write(TYPE_STRUCT_START);
 		buffer.valueOf(buffer.toString() + stream.toString());
 		rPos.valueOf(rPos.toInt() + 1);
 
 		encoder.valueOf(bValid);
 		if ((ret = NetLinx.VariableToString(encoder, buffer, rPos)) < 0) return ret;
 
 		encoder.valueOf(sPrestigeLevel);
 		if ((ret = NetLinx.VariableToString(encoder, buffer, rPos)) < 0) return ret;
 
 		encoder.valueOf((short)nNumberSeats);
 		if ((ret = NetLinx.VariableToString(encoder, buffer, rPos)) < 0) return ret;
 
 		// Write end
 		stream.reset();
 		stream.write(TYPE_STRUCT_END);
 		buffer.valueOf(buffer.toString() + stream.toString());
 		rPos.valueOf(rPos.toInt() + 1);
 
 		return ret;
 	}
 	public int binaryDecode(ObjectRef buffer, ObjectRef rPos)
 	{
 		int ret = 0;
 		ObjectRef decoder = new ObjectRef(0);
 		rPos.valueOf(rPos.toInt() + 1);
 
 		decoder.valueOf(bValid);
 		if ((ret = NetLinx.StringToVariable(decoder, buffer, rPos)) < 0) return ret;
 		bValid = decoder.toBoolean();
 
 		decoder.valueOf(sPrestigeLevel);
 		if ((ret = NetLinx.StringToVariable(decoder, buffer, rPos)) < 0) return ret;
 		sPrestigeLevel = decoder.toString();
 
 		decoder.valueOf((short)nNumberSeats);
 		if ((ret = NetLinx.StringToVariable(decoder, buffer, rPos)) < 0) return ret;
 		nNumberSeats = decoder.toInt();
 
 		// don't forget the end of struct byte
 		rPos.valueOf(rPos.toInt() + 1);
 
 		return ret;
 	}
 }
 

Since:
AMXTools 1.0.0
Version:
1.0.0

Field Summary
 
Fields inherited from interface com.amx.duet.tools.io.IBinaryMarshall
SIZE_CHAR, SIZE_DWORD, SIZE_QWORD, SIZE_WORD, STV_DECODE_DATA_INCOMPLETE, STV_DECODE_DATA_TOO_SMALL, STV_DECODE_EOS, STV_DECODE_OBJECT_TOO_SMALL, STV_DECODE_OK, STV_DECODE_VARIABLE_MISMATCH, STV_ENCODE_BUFFER_TOO_SMALL, STV_ENCODE_OK, STV_ENCODE_VARIABLE_UNKNOWN, TYPE_ARRAY, TYPE_CHAR, TYPE_CHAR_ARRAY, TYPE_DWORD, TYPE_DWORD_ARRAY, TYPE_LONG_CHAR_ARRAY, TYPE_QWORD, TYPE_QWORD_ARRAY, TYPE_SKIP, TYPE_STRUCT_END, TYPE_STRUCT_START, TYPE_WORD, TYPE_WORD_ARRAY
 
Method Summary
 void dispose()
          This method gives all IStruct objects the opporitunity to clean up their own member data
 
Methods inherited from interface com.amx.duet.tools.io.IBinaryMarshall
binaryDecode, binaryEncode
 

Method Detail

dispose

public void dispose()
This method gives all IStruct objects the opporitunity to clean up their own member data



Copyright © 2008 AMX LLC. All Rights Reserved.