Skip to content

ecf

Ecf

Endless Class File

Source code in src/eolib/protocol/_generated/pub/ecf.py
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
class Ecf:
    """
    Endless Class File
    """
    _byte_size: int = 0
    _rid: list[int] = None # type: ignore [assignment]
    _total_classes_count: int = None # type: ignore [assignment]
    _version: int = None # type: ignore [assignment]
    _classes: list[EcfRecord] = None # type: ignore [assignment]

    @property
    def byte_size(self) -> int:
        """
        Returns the size of the data that this was deserialized from.

        Returns:
            int: The size of the data that this was deserialized from.
        """
        return self._byte_size

    @property
    def rid(self) -> list[int]:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        return self._rid

    @rid.setter
    def rid(self, rid: list[int]) -> None:
        """
        Note:
          - Length must be `2`.
          - Element value range is 0-64008.
        """
        self._rid = rid

    @property
    def total_classes_count(self) -> int:
        """
        Note:
          - Value range is 0-64008.
        """
        return self._total_classes_count

    @total_classes_count.setter
    def total_classes_count(self, total_classes_count: int) -> None:
        """
        Note:
          - Value range is 0-64008.
        """
        self._total_classes_count = total_classes_count

    @property
    def version(self) -> int:
        """
        Note:
          - Value range is 0-252.
        """
        return self._version

    @version.setter
    def version(self, version: int) -> None:
        """
        Note:
          - Value range is 0-252.
        """
        self._version = version

    @property
    def classes(self) -> list[EcfRecord]:
        return self._classes

    @classes.setter
    def classes(self, classes: list[EcfRecord]) -> None:
        self._classes = classes

    @staticmethod
    def serialize(writer: EoWriter, data: "Ecf") -> None:
        """
        Serializes an instance of `Ecf` to the provided `EoWriter`.

        Args:
            writer (EoWriter): The writer that the data will be serialized to.
            data (Ecf): The data to serialize.
        """
        writer.add_fixed_string("ECF", 3, False)
        if data._rid is None:
            raise SerializationError("rid must be provided.")
        if len(data._rid) != 2:
            raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
        for i in range(2):
            writer.add_short(data._rid[i])
        if data._total_classes_count is None:
            raise SerializationError("total_classes_count must be provided.")
        writer.add_short(data._total_classes_count)
        if data._version is None:
            raise SerializationError("version must be provided.")
        writer.add_char(data._version)
        if data._classes is None:
            raise SerializationError("classes must be provided.")
        for i in range(len(data._classes)):
            EcfRecord.serialize(writer, data._classes[i])

    @staticmethod
    def deserialize(reader: EoReader) -> "Ecf":
        """
        Deserializes an instance of `Ecf` from the provided `EoReader`.

        Args:
            reader (EoReader): The writer that the data will be serialized to.

        Returns:
            Ecf: The data to serialize.
        """
        data: Ecf = Ecf()
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            data._rid = []
            for i in range(2):
                data._rid.append(reader.get_short())
            data._total_classes_count = reader.get_short()
            data._version = reader.get_char()
            data._classes = []
            while reader.remaining > 0:
                data._classes.append(EcfRecord.deserialize(reader))
            data._byte_size = reader.position - reader_start_position
            return data
        finally:
            reader.chunked_reading_mode = old_chunked_reading_mode

    def __repr__(self):
        return f"Ecf(byte_size={repr(self._byte_size)}, rid={repr(self._rid)}, total_classes_count={repr(self._total_classes_count)}, version={repr(self._version)}, classes={repr(self._classes)})"

byte_size: int property

Returns the size of the data that this was deserialized from.

Returns:

Name Type Description
int int

The size of the data that this was deserialized from.

rid: list[int] property writable

Note
  • Length must be 2.
  • Element value range is 0-64008.

total_classes_count: int property writable

Note
  • Value range is 0-64008.

version: int property writable

Note
  • Value range is 0-252.

classes: list[EcfRecord] property writable

serialize(writer, data) staticmethod

Serializes an instance of Ecf to the provided EoWriter.

Parameters:

Name Type Description Default
writer EoWriter

The writer that the data will be serialized to.

required
data Ecf

The data to serialize.

required
Source code in src/eolib/protocol/_generated/pub/ecf.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@staticmethod
def serialize(writer: EoWriter, data: "Ecf") -> None:
    """
    Serializes an instance of `Ecf` to the provided `EoWriter`.

    Args:
        writer (EoWriter): The writer that the data will be serialized to.
        data (Ecf): The data to serialize.
    """
    writer.add_fixed_string("ECF", 3, False)
    if data._rid is None:
        raise SerializationError("rid must be provided.")
    if len(data._rid) != 2:
        raise SerializationError(f"Expected length of rid to be exactly 2, got {len(data._rid)}.")
    for i in range(2):
        writer.add_short(data._rid[i])
    if data._total_classes_count is None:
        raise SerializationError("total_classes_count must be provided.")
    writer.add_short(data._total_classes_count)
    if data._version is None:
        raise SerializationError("version must be provided.")
    writer.add_char(data._version)
    if data._classes is None:
        raise SerializationError("classes must be provided.")
    for i in range(len(data._classes)):
        EcfRecord.serialize(writer, data._classes[i])

deserialize(reader) staticmethod

Deserializes an instance of Ecf from the provided EoReader.

Parameters:

Name Type Description Default
reader EoReader

The writer that the data will be serialized to.

required

Returns:

Name Type Description
Ecf 'Ecf'

The data to serialize.

Source code in src/eolib/protocol/_generated/pub/ecf.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
@staticmethod
def deserialize(reader: EoReader) -> "Ecf":
    """
    Deserializes an instance of `Ecf` from the provided `EoReader`.

    Args:
        reader (EoReader): The writer that the data will be serialized to.

    Returns:
        Ecf: The data to serialize.
    """
    data: Ecf = Ecf()
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        data._rid = []
        for i in range(2):
            data._rid.append(reader.get_short())
        data._total_classes_count = reader.get_short()
        data._version = reader.get_char()
        data._classes = []
        while reader.remaining > 0:
            data._classes.append(EcfRecord.deserialize(reader))
        data._byte_size = reader.position - reader_start_position
        return data
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode