Skip to content

ecf

Ecf

Endless Class File

Source code in src/eolib/protocol/_generated/pub/ecf.py
 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
class Ecf:
    """
    Endless Class File
    """
    _byte_size: int = 0
    _rid: tuple[int, ...]
    _total_classes_count: int
    _version: int
    _classes: tuple[EcfRecord, ...]

    def __init__(self, *, rid: Iterable[int], total_classes_count: int, version: int, classes: Iterable[EcfRecord]):
        """
        Create a new instance of Ecf.

        Args:
            rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
            total_classes_count (int): (Value range is 0-64008.)
            version (int): (Value range is 0-252.)
            classes (Iterable[EcfRecord]): 
        """
        self._rid = tuple(rid)
        self._total_classes_count = total_classes_count
        self._version = version
        self._classes = tuple(classes)

    @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) -> tuple[int, ...]:
        return self._rid

    @property
    def total_classes_count(self) -> int:
        return self._total_classes_count

    @property
    def version(self) -> int:
        return self._version

    @property
    def classes(self) -> tuple[EcfRecord, ...]:
        return self._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.
        """
        old_string_sanitization_mode: bool = writer.string_sanitization_mode
        try:
            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])
        finally:
            writer.string_sanitization_mode = old_string_sanitization_mode

    @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.
        """
        old_chunked_reading_mode: bool = reader.chunked_reading_mode
        try:
            reader_start_position: int = reader.position
            reader.get_fixed_string(3, False)
            rid = []
            for i in range(2):
                rid.append(reader.get_short())
            total_classes_count = reader.get_short()
            version = reader.get_char()
            classes = []
            while reader.remaining > 0:
                classes.append(EcfRecord.deserialize(reader))
            result = Ecf(rid=rid, total_classes_count=total_classes_count, version=version, classes=classes)
            result._byte_size = reader.position - reader_start_position
            return result
        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: tuple[int, ...] property

total_classes_count: int property

version: int property

classes: tuple[EcfRecord, ...] property

__init__(*, rid, total_classes_count, version, classes)

Create a new instance of Ecf.

Parameters:

Name Type Description Default
rid Iterable[int]

(Length must be 2.) (Element value range is 0-64008.)

required
total_classes_count int

(Value range is 0-64008.)

required
version int

(Value range is 0-252.)

required
classes Iterable[EcfRecord]
required
Source code in src/eolib/protocol/_generated/pub/ecf.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def __init__(self, *, rid: Iterable[int], total_classes_count: int, version: int, classes: Iterable[EcfRecord]):
    """
    Create a new instance of Ecf.

    Args:
        rid (Iterable[int]): (Length must be `2`.) (Element value range is 0-64008.)
        total_classes_count (int): (Value range is 0-64008.)
        version (int): (Value range is 0-252.)
        classes (Iterable[EcfRecord]): 
    """
    self._rid = tuple(rid)
    self._total_classes_count = total_classes_count
    self._version = version
    self._classes = tuple(classes)

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
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
@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.
    """
    old_string_sanitization_mode: bool = writer.string_sanitization_mode
    try:
        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])
    finally:
        writer.string_sanitization_mode = old_string_sanitization_mode

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
 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
@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.
    """
    old_chunked_reading_mode: bool = reader.chunked_reading_mode
    try:
        reader_start_position: int = reader.position
        reader.get_fixed_string(3, False)
        rid = []
        for i in range(2):
            rid.append(reader.get_short())
        total_classes_count = reader.get_short()
        version = reader.get_char()
        classes = []
        while reader.remaining > 0:
            classes.append(EcfRecord.deserialize(reader))
        result = Ecf(rid=rid, total_classes_count=total_classes_count, version=version, classes=classes)
        result._byte_size = reader.position - reader_start_position
        return result
    finally:
        reader.chunked_reading_mode = old_chunked_reading_mode