summaryrefslogtreecommitdiff
path: root/pyasn1/type/opentype.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyasn1/type/opentype.py')
-rw-r--r--pyasn1/type/opentype.py45
1 files changed, 37 insertions, 8 deletions
diff --git a/pyasn1/type/opentype.py b/pyasn1/type/opentype.py
index d37a533..29645f0 100644
--- a/pyasn1/type/opentype.py
+++ b/pyasn1/type/opentype.py
@@ -11,11 +11,22 @@ __all__ = ['OpenType']
class OpenType(object):
"""Create ASN.1 type map indexed by a value
- The *DefinedBy* object models the ASN.1 *DEFINED BY* clause which maps
- values to ASN.1 types in the context of the ASN.1 SEQUENCE/SET type.
-
- OpenType objects are duck-type a read-only Python :class:`dict` objects,
- however the passed `typeMap` is stored by reference.
+ The *OpenType* object models an untyped field of a constructed ASN.1
+ type. In ASN.1 syntax it is usually represented by the
+ `ANY DEFINED BY` for scalars or `SET OF ANY DEFINED BY`,
+ `SEQUENCE OF ANY DEFINED BY` for container types clauses. Typically
+ used together with :class:`~pyasn1.type.univ.Any` object.
+
+ OpenType objects duck-type a read-only Python :class:`dict` objects,
+ however the passed `typeMap` is not copied, but stored by reference.
+ That means the user can manipulate `typeMap` at run time having this
+ reflected on *OpenType* object behavior.
+
+ The |OpenType| class models an untyped field of a constructed ASN.1
+ type. In ASN.1 syntax it is usually represented by the
+ `ANY DEFINED BY` for scalars or `SET OF ANY DEFINED BY`,
+ `SEQUENCE OF ANY DEFINED BY` for container types clauses. Typically
+ used with :class:`~pyasn1.type.univ.Any` type.
Parameters
----------
@@ -28,12 +39,14 @@ class OpenType(object):
Examples
--------
+
+ For untyped scalars:
+
.. code-block:: python
openType = OpenType(
- 'id',
- {1: Integer(),
- 2: OctetString()}
+ 'id', {1: Integer(),
+ 2: OctetString()}
)
Sequence(
componentType=NamedTypes(
@@ -41,6 +54,22 @@ class OpenType(object):
NamedType('blob', Any(), openType=openType)
)
)
+
+ For untyped `SET OF` or `SEQUENCE OF` vectors:
+
+ .. code-block:: python
+
+ openType = OpenType(
+ 'id', {1: Integer(),
+ 2: OctetString()}
+ )
+ Sequence(
+ componentType=NamedTypes(
+ NamedType('id', Integer()),
+ NamedType('blob', SetOf(componentType=Any()),
+ openType=openType)
+ )
+ )
"""
def __init__(self, name, typeMap=None):