Create |ASN.1| schema or value object. |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its objects are immutable and duck-type Python :class:`tuple` objects (tuple of non-negative integers). Keyword Args ------------ value: :class:`tuple`, :class:`str` or
| 1160 | |
| 1161 | |
| 1162 | class RelativeOID(base.SimpleAsn1Type): |
| 1163 | """Create |ASN.1| schema or value object. |
| 1164 | |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its |
| 1165 | objects are immutable and duck-type Python :class:`tuple` objects |
| 1166 | (tuple of non-negative integers). |
| 1167 | Keyword Args |
| 1168 | ------------ |
| 1169 | value: :class:`tuple`, :class:`str` or |ASN.1| object |
| 1170 | Python sequence of :class:`int` or :class:`str` literal or |ASN.1| object. |
| 1171 | If `value` is not given, schema object will be created. |
| 1172 | tagSet: :py:class:`~pyasn1.type.tag.TagSet` |
| 1173 | Object representing non-default ASN.1 tag(s) |
| 1174 | subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection` |
| 1175 | Object representing non-default ASN.1 subtype constraint(s). Constraints |
| 1176 | verification for |ASN.1| type occurs automatically on object |
| 1177 | instantiation. |
| 1178 | Raises |
| 1179 | ------ |
| 1180 | ~pyasn1.error.ValueConstraintError, ~pyasn1.error.PyAsn1Error |
| 1181 | On constraint violation or bad initializer. |
| 1182 | Examples |
| 1183 | -------- |
| 1184 | .. code-block:: python |
| 1185 | class RelOID(RelativeOID): |
| 1186 | ''' |
| 1187 | ASN.1 specification: |
| 1188 | id-pad-null RELATIVE-OID ::= { 0 } |
| 1189 | id-pad-once RELATIVE-OID ::= { 5 6 } |
| 1190 | id-pad-twice RELATIVE-OID ::= { 5 6 7 } |
| 1191 | ''' |
| 1192 | id_pad_null = RelOID('0') |
| 1193 | id_pad_once = RelOID('5.6') |
| 1194 | id_pad_twice = id_pad_once + (7,) |
| 1195 | """ |
| 1196 | #: Set (on class, not on instance) or return a |
| 1197 | #: :py:class:`~pyasn1.type.tag.TagSet` object representing ASN.1 tag(s) |
| 1198 | #: associated with |ASN.1| type. |
| 1199 | tagSet = tag.initTagSet( |
| 1200 | tag.Tag(tag.tagClassUniversal, tag.tagFormatSimple, 0x0d) |
| 1201 | ) |
| 1202 | |
| 1203 | #: Set (on class, not on instance) or return a |
| 1204 | #: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection` object |
| 1205 | #: imposing constraints on |ASN.1| type initialization values. |
| 1206 | subtypeSpec = constraint.ConstraintsIntersection() |
| 1207 | |
| 1208 | # Optimization for faster codec lookup |
| 1209 | typeId = base.SimpleAsn1Type.getTypeId() |
| 1210 | |
| 1211 | def __add__(self, other): |
| 1212 | return self.clone(self._value + other) |
| 1213 | |
| 1214 | def __radd__(self, other): |
| 1215 | return self.clone(other + self._value) |
| 1216 | |
| 1217 | def asTuple(self): |
| 1218 | return self._value |
| 1219 |