class EnumerationField(Field):
+ """
+ Enumeration field, based on an
+ :class:`EnumerationFieldDeclaration` object.
+ """
+
@property
def container(self):
"""
- Return the enumeration's underlying container field (an integer field).
+ Underlying container (:class:`IntegerField`).
+
+ :exc:`TypeError` is raised on error.
"""
container = IntegerField.__new__(IntegerField)
@property
def value(self):
"""
- Get the enumeration field's mapping name.
+ Current label of this enumeration field (:class:`str`).
+
+ Set this attribute to an integer (:class:`int`) to change the
+ enumeration field's value.
+
+ :exc:`ValueError` is raised on error.
"""
value = nbt._bt_ctf_field_enumeration_get_mapping_name(self._f)
if value is None:
- raise ValueError("Could not get enumeration's mapping name.")
+ raise ValueError("Could not get enumeration mapping name.")
return value
@value.setter
def value(self, value):
- """
- Set the enumeration field's value. Must be an integer as mapping names
- may be ambiguous.
- """
-
if not isinstance(value, int):
raise TypeError("EnumerationField value must be an int")
class FloatingPointField(Field):
+ """
+ Floating point number field, based on a
+ :class:`FloatingPointFieldDeclaration` object.
+ """
+
@property
def value(self):
"""
- Get a floating point field's value.
+ Floating point number value (:class:`float`).
+
+ Set this attribute to change the floating point number field's
+ value.
+
+ :exc:`ValueError` or :exc:`TypeError` are raised on error.
"""
ret, value = nbt._bt_ctf_field_floating_point_get_value(self._f)
@value.setter
def value(self, value):
- """
- Set a floating point field's value.
- """
-
if not isinstance(value, int) and not isinstance(value, float):
raise TypeError("Value must be either a float or an int")
class StructureField(Field):
+ """
+ Structure field, based on a
+ :class:`StructureFieldDeclaration` object.
+ """
+
def field(self, field_name):
"""
- Get the structure's field corresponding to the provided field name.
+ Returns the structure :class:`Field` named *field_name*.
+
+ :exc:`ValueError` is raised on error.
"""
native_instance = nbt._bt_ctf_field_structure_get_field(self._f,
class VariantField(Field):
+ """
+ Variant field, based on a
+ :class:`VariantFieldDeclaration` object.
+ """
+
def field(self, tag):
"""
- Return the variant's selected field. The "tag" field is the selector enum field.
+ Returns the :class:`Field` selected by the current label of
+ *tag* (:class:`EnumerationField`).
+
+ :exc:`ValueError` is raised on error.
"""
native_instance = nbt._bt_ctf_field_variant_get_field(self._f, tag._f)