ASN1C C# Runtime Library  7.6
Public Member Functions | List of all members
Asn1OerEncodeBuffer Class Reference

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 ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Asn1OerEncodeBuffer() [1/2]

This constructor creates a OER encode buffer object with the default initial size. Whenever the buffer becomes full, it will be expanded.

◆ Asn1OerEncodeBuffer() [2/2]

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.

Parameters
sizeThe initial size in bytes of an encode buffer.

Member Function Documentation

◆ BeginSetOf()

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.

◆ BinDump()

override void BinDump ( System.IO.StreamWriter  outs,
System.String  varName 
)
virtual

This method dumps the encoded message in a human-readable format to the given print output stream.

Implements Asn1EncodeBuffer.

◆ EncodeIdentifier()

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.

Parameters
identThe tag number.

Referenced by Asn1RelativeOID.Encode(), and Asn1ObjectIdentifier.Encode().

◆ EncodeIntSigned() [1/2]

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.

Parameters
valueThe value to encode. It must fit in the given number of octets.
octetsThe 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().

◆ EncodeIntSigned() [2/2]

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.)

Parameters
valueThe value to encode.

◆ EncodeIntUnsigned() [1/2]

void EncodeIntUnsigned ( long  value,
int  octets 
)

Encode an integer value as an unsigned value (binary integer) in the given number of octets.

Parameters
valueThe value to encode. It must be non-negative and fit in the given number of octets.
octetsThe number of octets to encode in; 0 < octets <= 8.

Referenced by Asn1TimeUtil.DecodeTime(), Asn1BitString.Encode(), Asn1TimeUtil.EncodeDateTime(), Asn1TimeUtil.EncodeDuration(), Asn1Integer.EncodeUnsigned(), and Asn1BigInteger.EncodeUnsigned().

◆ EncodeIntUnsigned() [2/2]

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.

Parameters
valueThe value to encode. It must be non-negative.

◆ EncodeLength()

void EncodeLength ( long  length)

◆ EncodeQuantity()

void EncodeQuantity ( int  quantity)

Encode an OER quantity (used for SEQUENCE-OF and SET-OF).

◆ EncodeTag()

void EncodeTag ( short  tagClass,
int  tagNumber 
)

Encode a tag according to OER.

Parameters
tagClassThe 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.
tagNumberThe tag number.

◆ EndSetOf()

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.

Returns
In canonical mode, the original buffer, the one that was used to create this buffer by calling BeginSetOf(). Otherwise, this.

References Asn1EncodeBuffer.Copy().

◆ GetCanonicalMode()

bool GetCanonicalMode ( )

Return true if canonical mode has been indicated by calling SetCanonicalMode(true);

Referenced by Asn1Type.EncodeAsOpenType().

◆ GetIdentifierLength()

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().

◆ NewBuffer()

Asn1OerEncodeBuffer NewBuffer ( )

Return a new OER encode buffer with the same canonical mode setting as this buffer.

◆ SetCanonicalMode()

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().

◆ SetOfRepDone()

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.