zserio.creator module¶
The module implements creator of zserio object tree based on type info.
- class zserio.creator.ZserioTreeCreator(type_info: TypeInfo | RecursiveTypeInfo, *arguments: List[Any])[source]¶
Bases:
object
Allows to build zserio object tree defined by the given type info.
Constructor.
- Parameters:
type_info – Type info defining the tree.
arguments – Arguments for type which defines the tree.
- add_value_element(value: Any) None [source]¶
Adds the value to the array.
- Parameters:
value – Value to add.
- Raises:
PythonRuntimeException – When the creator is not in an array of simple values.
- begin_array(name: str) None [source]¶
Creates an array field within the current compound.
- Parameters:
name – Name of the array field.
- Raises:
PythonRuntimeException – When the field doesn’t exist or when the creator is not in a compound.
- begin_compound(name)[source]¶
Creates a compound field within the current compound.
- Parameters:
name – Name of the compound field.
- Raises:
PythonRuntimeException – When the field doesn’t exist or when the creator is not in a compound.
- begin_compound_element()[source]¶
Creates compound array element within the current array.
- Raises:
PythonRuntimeException – When the creator is not in an array of compounds.
- begin_root() None [source]¶
Creates the top level compound element and move to state of building its children.
- end_array()[source]¶
Finishes the array field.
- Raises:
PythonRuntimeException – When the creator is not in an array field.
- end_compound()[source]¶
Finishes the compound.
- Raises:
PythonRuntimeException – When the creator is not in a compound field.
- end_compound_element() None [source]¶
Finishes the compound element.
- Raises:
PythonRuntimeException – When the creator is not in a compound element.
- end_root() Any [source]¶
Finishes building and returns the created tree.
- Returns:
Zserio object tree.
- Raises:
PythonRuntimeException – When the creator is not in state of building the root object.
- get_element_type() TypeInfo | RecursiveTypeInfo [source]¶
Gets type info of the expected array element.
- Returns:
Type info of the expected array element.
- Raises:
PythonRuntimeException – When the creator is not in an array.
- get_field_type(name: str) TypeInfo | RecursiveTypeInfo [source]¶
Gets type info of the expected field.
- Parameters:
name – Field name.
- Returns:
Type info of the expected field.
- Raises:
PythonRuntimeException – When the creator is not in a compound.
- set_value(name: str, value: Any)[source]¶
Sets field value within the current compound.
- Parameters:
name – Name of the field.
value – Value to set.
- Raises:
PythonRuntimeException – When the field doesn’t exist or when the creator is not in a compound.