ASN1C C# Runtime Library
7.8
|
Inherits Asn1EncodeBitBuffer.
Public Member Functions | |
Asn1OerEncodeBuffer () | |
Asn1OerEncodeBuffer (int size) | |
Asn1OerEncodeBuffer | BeginSetOf () |
override void | BinDump (System.IO.StreamWriter outs, System.String varName) |
void | EncodeIdentifier (int ident) |
void | EncodeIntSigned (long value, int octets) |
void | EncodeIntSigned (long value) |
void | EncodeIntUnsigned (long value, int octets) |
void | EncodeIntUnsigned (long value) |
void | EncodeLength (long length) |
void | EncodeQuantity (int quantity) |
void | EncodeTag (short tagClass, int tagNumber) |
Asn1OerEncodeBuffer | EndSetOf () |
bool | GetCanonicalMode () |
int | GetIdentifierLength (int ident) |
Asn1OerEncodeBuffer | NewBuffer () |
void | SetCanonicalMode (bool value) |
void | SetOfRepDone () |
This class handles the encoding of ASN.1 messages as specified in the Octet Encoding Rules (OER) as specified in the ITU-T X.696 standard. A reference to an object of this type is passed to each of the ASN.1 type encode methods involved in encoding a particular message type.
This constructor creates a OER encode buffer object with the default initial size. Whenever the buffer becomes full, it will be expanded.
Asn1OerEncodeBuffer | ( | int | size | ) |
This constructor creates a OER encode buffer object with the given initial size. Whenever the buffer becomes full, it will be expanded. For best performance, this size should be large enough to prevent resizing in normal operation.
size | The initial size in bytes of an encode buffer. |
Asn1OerEncodeBuffer BeginSetOf | ( | ) |
If canonical mode is on, return a new Asn1OerEncodeBuffer into which the repetitions of a SET OF can be encoded. This should be paired with a later call to EndSetOf (which see).
If canonical mode is off, this simply returns this buffer.
Example usage: buffer = buffer.BeginSetOf(); //buffer is now new, temp buffer for each repetition encode repetition to buffer buffer.SetOfOccurrenceDone(); buffer = buffer.EndSetOf(); //buffer is original buffer again //and SET OF is encoded, sorted, //into it.
|
virtual |
This method dumps the encoded message in a human-readable format to the given print output stream.
Implements Asn1EncodeBuffer.
void EncodeIdentifier | ( | int | ident | ) |
Encode an identifier according to OER. This is the encoding used for a tag number > 62, i.e. in a variable number of octets, with 7 bits of the value encoded in each octet and the first bit serving as a flag bit. It is also the encoding used for the subidentifiers in an OBJECT IDENTIFIER encoding.
ident | The tag number. |
Referenced by Asn1RelativeOID.Encode(), and Asn1ObjectIdentifier.Encode().
void EncodeIntSigned | ( | long | value, |
int | octets | ||
) |
Encode an integer value as a signed value (2's complement form), in the given number of octets. The given value must be able to fit in the given number of octets.
value | The value to encode. It must fit in the given number of octets. |
octets | The number of octets to encode in; 0 < octets <= 8 |
Referenced by Asn1TimeUtil.DecodeTime(), Asn1Enumerated.Encode(), Asn1Integer.Encode(), Asn1UniversalString.Encode(), Asn1TimeUtil.EncodeDuration(), Asn1Integer.EncodeSigned(), Asn1BigInteger.EncodeSigned(), and Asn1BigInteger.EncodeUnsigned().
void EncodeIntSigned | ( | long | value | ) |
Encode an integer value as a variable length, signed integer, including encoding the length, according to OER. This is used for integer values that have a lower bound less than -2^63, no lower bound, or a lower bound less than zero in combination with an upper bound greater than 2^63–1, or no upper bound. (In other words, it doesn't fit in a signed 64-bit integer.)
value | The value to encode. |
void EncodeIntUnsigned | ( | long | value, |
int | octets | ||
) |
Encode an integer value as an unsigned value (binary integer) in the given number of octets.
value | The value to encode. It must be non-negative and fit in the given number of octets. |
octets | The number of octets to encode in; 0 < octets <= 8. |
Referenced by Asn1TimeUtil.DecodeTime(), Asn1BitString.Encode(), Asn1TimeUtil.EncodeDateTime(), Asn1TimeUtil.EncodeDuration(), Asn1Integer.EncodeUnsigned(), and Asn1BigInteger.EncodeUnsigned().
void EncodeIntUnsigned | ( | long | value | ) |
Encode an integer value as a variable length, unsigned integer, including encoding the length, according to OER. This is used for integer values that are constrained to be non-negative but which have no upper bound or an upper bound greater than 2^64 - 1.
value | The value to encode. It must be non-negative. |
void EncodeLength | ( | long | length | ) |
Encode an OER length determinant
Referenced by Asn1VarWidthCharString.Encode(), Asn1RelativeOID.Encode(), Asn1StringRelativeOID.Encode(), Asn1Real10.Encode(), Asn1ObjectIdentifier.Encode(), Asn1StringOID.Encode(), Asn18BitCharString.Encode(), Asn1BMPString.Encode(), Asn1UTF8String.Encode(), Asn1OpenType.Encode(), Asn1OctetString.Encode(), Asn1UniversalString.Encode(), Asn1Real.Encode(), Asn1BitString.Encode(), Asn1Type.EncodeAsOpenType(), Asn1BigInteger.EncodeSigned(), and Asn1BigInteger.EncodeUnsigned().
void EncodeQuantity | ( | int | quantity | ) |
Encode an OER quantity (used for SEQUENCE-OF and SET-OF).
void EncodeTag | ( | short | tagClass, |
int | tagNumber | ||
) |
Encode a tag according to OER.
tagClass | The tag class. The highest 2 bits shall be set equal to the bits specified in the encoding rules for the tag's class. The remaining bits shall be zero. Asn1Tag.UNIV etc. fulfill this. |
tagNumber | The tag number. |
Asn1OerEncodeBuffer EndSetOf | ( | ) |
If canonical mode is on, encode each of the SET OF occurrences, in sorted order, to the original buffer, the one that created this buffer.
If canonical mode is off, this simply returns itself.
References Asn1EncodeBuffer.Copy().
bool GetCanonicalMode | ( | ) |
Return true if canonical mode has been indicated by calling SetCanonicalMode(true);
Referenced by Asn1Type.EncodeAsOpenType().
int GetIdentifierLength | ( | int | ident | ) |
Return the minimal number of octets required to encode the given identifier, where the identifier is encoded following the OER rules for encoding a tag number greater than 62, i.e. in a variable number of octets, with 7 bits of the value encoded in each octet and the first bit serving as a flag bit.
Referenced by Asn1RelativeOID.Encode(), and Asn1ObjectIdentifier.Encode().
Asn1OerEncodeBuffer NewBuffer | ( | ) |
Return a new OER encode buffer with the same canonical mode setting as this buffer.
void SetCanonicalMode | ( | bool | value | ) |
Turn canonical mode on/off. Turning canonical mode on acts as a signal to both generated code and runtime code that the user wants to encode according to the canonical OER rules.
Referenced by Asn1Type.EncodeAsOpenType().
void SetOfRepDone | ( | ) |
Invoke this method to signal to the buffer that another occurrence in a SET OF has been completely encoded into it.
This has no effect if canonical mode is off.