Asn1PerOutputStream Class Reference

Inheritance diagram for Asn1PerOutputStream:
Asn1OutputStream

List of all members.

Public Member Functions

virtual void AddCaptureBuffer (System.IO.MemoryStream buffer)
 Asn1PerOutputStream (System.IO.Stream os, int bufSize, bool aligned)
 Asn1PerOutputStream (System.IO.Stream os, bool aligned)
virtual void BinDump (System.IO.StreamWriter outs, System.String varName)
virtual void BinDump (System.String varName)
virtual void ByteAlign ()
override void Close ()
virtual void EncodeBit (bool value, System.String ident)
virtual void EncodeBit (bool value)
virtual void EncodeBits (byte[] value, int offset, int nbits, System.String ident)
virtual void EncodeBits (byte[] value, int offset, int nbits)
virtual void EncodeBits (byte value, int nbits)
virtual void EncodeCharString (System.String value, int nchars, int offset, int abpc, int ubpc, Asn1CharSet charSet)
virtual void EncodeConsWholeNumber (long adjustedValue, long rangeValue)
virtual void EncodeConsWholeNumber (long adjustedValue, long rangeValue, System.String ident)
virtual void EncodeInt (long value, bool encodeLen, bool signExtend)
virtual void EncodeInt (long value, bool encodeLen, bool signExtend, System.String ident)
virtual void EncodeInt (long value, int nbits)
virtual void EncodeInt (long value, int nbits, System.String ident)
virtual void EncodeLength (long value, long lower, long upper)
virtual long EncodeLength (long value)
virtual void EncodeLengthEOM (long value)
virtual void EncodeOctetString (byte[] value, int offset, int nbytes)
virtual void EncodeOIDLengthAndValue (int[] value)
virtual void EncodeOpenType (byte[] value, int offset, int nbytes)
virtual void EncodeRelOIDLengthAndValue (int[] value)
virtual void EncodeSmallLength (int value)
virtual void EncodeSmallNonNegWholeNumber (int value)
override void Flush ()
virtual void RemoveCaptureBuffer (System.IO.MemoryStream buffer)
override void Write (System.Byte[] b, int off, int len)
override void Write (byte[] b)
override void WriteByte (byte b)
override void WriteByte (int b)

Protected Attributes

internal
Asn1PerOutputStreamTraceHandler 
mTraceHandler

Properties

virtual bool Aligned [get]
virtual Asn1PerTraceHandler TraceHandler [get]

Detailed Description

This class handles the output stream for encoding of ASN.1 messages as specified in the Packed Encoding Rules (PER) ITU-T X.691 standard.


Constructor & Destructor Documentation

Asn1PerOutputStream ( System.IO.Stream  os,
bool  aligned 
)

This constructor creates a buffered PER output stream object with the default size of buffer. Whenever the buffer becomes full, the buffer will be flushed to the stream.

Parameters:
os The underlying System.IO.Stream object.
aligned Indicates whether PER aligned or unaligned encoding should be done.
Asn1PerOutputStream ( System.IO.Stream  os,
int  bufSize,
bool  aligned 
)

This constructor creates a buffered PER output stream object with the specified size of buffer. Whenever the buffer becomes full, the buffer will be flushed to the stream.

Parameters:
os The underlying System.IO.Stream object.
bufSize The buffer size.
aligned true for PER aligned or false for PER unaligned encoding.

Member Function Documentation

virtual void AddCaptureBuffer ( System.IO.MemoryStream  buffer  )  [virtual]

This method is used to add a capture buffer to the internal capture buffer list. A capture buffer is used to capture all bytes read from this position forward from the input stream.

Parameters:
buffer Buffer into which captured bytes are to be stored
virtual void BinDump ( System.IO.StreamWriter  outs,
System.String  varName 
) [virtual]

This method dumps the encoded message in a human-readable format showing a bit trace of all fields to the given print output stream.

Parameters:
outs StreamWriter object to which output should be written
varName Name of top-level message object variable
virtual void BinDump ( System.String  varName  )  [virtual]

This method invokes an overloaded version of BinDump to dump the encoded message to standard output.

Parameters:
varName Name of top-level message object variable
virtual void ByteAlign (  )  [virtual]

This methods byte-aligns the buffer.

override void Close (  ) 

Close the stream. Writes all bytes (even unfinished) before closing. Throws, exception thrown by the underlying System.IO.Stream object.

Reimplemented from Asn1OutputStream.

virtual void EncodeBit ( bool  value,
System.String  ident 
) [virtual]

This method encodes a single bit value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Boolean value of bit to be encoded.
ident Bit field identifier name for tracing.
Exceptions:
Asn1Exception Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeBit ( bool  value  )  [virtual]

This method encodes a single bit value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Boolean value of bit to be encoded.
Exceptions:
Asn1Exception Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeBits ( byte[]  value,
int  offset,
int  nbits,
System.String  ident 
) [virtual]

This method encodes bit values from an array of octets.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Octet array containing bits to be encoded
offset Starting byte offset in value
nbits Number of bits to encode
ident Bit field identifier name for tracing.
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeBits ( byte[]  value,
int  offset,
int  nbits 
) [virtual]

This method encodes bit values from an array of octets.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Octet array containing bits to be encoded
offset Starting byte offset in value
nbits Number of bits to encode
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeBits ( byte  value,
int  nbits 
) [virtual]

This method encodes bit values from an octet. The most significant bits from the octet are encoded.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Octet containing bits to be encoded
nbits Number of bits to encode
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeCharString ( System.String  value,
int  nchars,
int  offset,
int  abpc,
int  ubpc,
Asn1CharSet  charSet 
) [virtual]

This method encodes the contents of a known-multiplier character string type. This version assumes a permitted alphabet constraint was specified.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value String containing characters to encode
nchars Number of characters from string to encode
offset Offset to first char in string to encode
abpc Number of bits per character (aligned)
ubpc Number of bits per character (unaligned)
charSet Object representing permitted alphabet constraint character set (optional)
Exceptions:
Asn1Exception Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeConsWholeNumber ( long  adjustedValue,
long  rangeValue 
) [virtual]

This method implements the rules to encode a constrained whole number as specified in section 10.5 of the X.691 standard.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
adjustedValue Adjusted value to be encoded = value - lower range endpoint value
rangeValue lower - upper + 1
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeConsWholeNumber ( long  adjustedValue,
long  rangeValue,
System.String  ident 
) [virtual]

This method implements the rules to encode a constrained whole number as specified in section 10.5 of the X.691 standard.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
adjustedValue Adjusted value to be encoded = value - lower range endpoint value
rangeValue lower - upper + 1
ident Bit field identifier name for tracing.
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeInt ( long  value,
bool  encodeLen,
bool  signExtend 
) [virtual]

This method implements the rules to encode either a non-negative binary integer as specified in section 10.3 or a two's complement binary integer as specified in section 10.4 of the X.691 standard.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Integer value to be encoded
encodeLen Flag indicating length determinant should be encoded before encoding integer value.
signExtend Flag indicating if sign extension should be performed.
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeInt ( long  value,
bool  encodeLen,
bool  signExtend,
System.String  ident 
) [virtual]

This method implements the rules to encode either a non-negative binary integer as specified in section 10.3 or a two's complement binary integer as specified in section 10.4 of the X.691 standard.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Integer value to be encoded
encodeLen Flag indicating length determinant should be encoded before encoding integer value.
signExtend Flag indicating if sign extension should be performed.
ident Bit field identifier name for tracing.
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeInt ( long  value,
int  nbits 
) [virtual]

This method encodes bit values from an integer value. The least significant bits from the integer are encoded.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Integer containing bits to be encoded
nbits Number of bits to encode
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeInt ( long  value,
int  nbits,
System.String  ident 
) [virtual]

This method encodes bit values from an integer value. The least significant bits from the integer are encoded.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Integer containing bits to be encoded
nbits Number of bits to encode
ident Bit field identifier name for tracing.
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeLength ( long  value,
long  lower,
long  upper 
) [virtual]

This method encodes a constrained length determinant value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Length value to be encoded
lower Lower bound (inclusive) of length value range
upper Upper bound (inclusive) of length value range
Exceptions:
Asn1Exception Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual long EncodeLength ( long  value  )  [virtual]

This method encodes a general (unconstrained) length determinant value as described in section 10.9 or the X.691 standard.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Length value to be encoded
Returns:
Value that was actually encoded. This may be less than the value that was passed in if fragementation was done (i.e the value was >= 16k).
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeLengthEOM ( long  value  )  [virtual]

This method checks to see if a zero byte needs to be added after a fragmented length has been encoded. It will add it to the byte stream if necessary.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Original length value that was encoded.
Exceptions:
Asn1Exception Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeOctetString ( byte[]  value,
int  offset,
int  nbytes 
) [virtual]

This method encodes the given array of bytes as an unconstrained octet string value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Byte array containing data to encode. This is assumed to contain a previously encoded PER component.
offset Starting offset in byte array value
nbytes Number of bytes to encode
Exceptions:
Asn1Exception Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeOIDLengthAndValue ( int[]  value  )  [virtual]

This method encodes the length and contents of an object identifier value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Integer array containing arcs to encode
Exceptions:
Asn1Exception Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeOpenType ( byte[]  value,
int  offset,
int  nbytes 
) [virtual]

This method encodes the given array of bytes as an open type.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Byte array containing data to encode. This is assumed to contain a previously encoded PER component.
offset Starting offset in byte array value
nbytes Number of bytes to encode
Exceptions:
Asn1Exception Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeRelOIDLengthAndValue ( int[]  value  )  [virtual]

This method encodes the length and contents of a relative object identifier value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Integer array containing arcs to encode
Exceptions:
Asn1Exception Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeSmallLength ( int  value  )  [virtual]

This method implements the rules to encode a normally small length as specified in section 11.9 of the X.691 standard.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Value to be encoded
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
virtual void EncodeSmallNonNegWholeNumber ( int  value  )  [virtual]

This method implements the rules to encode a small non-negative whole number as specified in section 10.6 of the X.691 standard.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters:
value Value to be encoded
Exceptions:
Asn1InvalidArgException Any exception thrown by the underlying Asn1PerEncodeBuffer.
override void Flush (  ) 

Flush the buffer to the stream. It writes whole bytes only. Throws, exception thrown by the underlying System.IO.Stream object.

Reimplemented from Asn1OutputStream.

virtual void RemoveCaptureBuffer ( System.IO.MemoryStream  buffer  )  [virtual]

This method is used to remove a capture buffer from the internal capture buffer list. The add and remove methods can be used to get a set of raw bytes from the input stream for further processing.

Parameters:
buffer Buffer in which captured bytes stored
override void Write ( System.Byte[]  b,
int  off,
int  len 
)

Writes len bytes from the specified byte array to this output stream.

Parameters:
b the data.
off The offset in array at which to begin write.
len The number of bytes to write.
Exceptions:
System.SystemException if an I/O error occurs. In particular, write call after the the output stream is closed.

Reimplemented from Asn1OutputStream.

override void Write ( byte[]  b  )  [virtual]

Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call Write(b, 0, b.length).

Parameters:
b the binary data.
Exceptions:
System.SystemException if an I/O error occurs.

Reimplemented from Asn1OutputStream.

override void WriteByte ( byte  b  ) 

Writes the specified byte to this output stream.

Parameters:
b the byte.
Exceptions:
System.SystemException if an I/O error occurs. In particular, an write call after the output stream has been closed.

Reimplemented from Asn1OutputStream.

override void WriteByte ( int  b  )  [virtual]

Writes the specified byte to this output stream.

Parameters:
b the byte.
Exceptions:
System.SystemException if an I/O error occurs. In particular, an write call after the output stream has been closed.

Reimplemented from Asn1OutputStream.


Member Data Documentation

Variable holds the PER message trace handler


Property Documentation

virtual bool Aligned [get]

Gets PER aligned encoding has been specified.

Value: true is aligned; otherwise false

virtual Asn1PerTraceHandler TraceHandler [get]

Gets a reference to the internal trace handler object used to trace the bit fields within a PER message.

Value: Asn1PerTraceHandler object