C# Class Lawo.EmberPlusSharp.Ember.EmberReader

Represents a reader that provides the means to read BER-encoded input, as specified in "X.690"X.690.
Only the subset defined in the "Ember+ Specification"Ember+ Specification is supported.
Inheritance: IDisposable
Show file Open project: Lawo/ember-plus-sharp Class Usage Examples

Private Properties

Property Type Description
AssertCanReadContents void
AssertNotDisposed void
AssertRead void
CopyCore object
CreateEmberException EmberException
CreateEmberException EmberException
Dispose void
IsContainer bool
ProcessOuter bool
Read7Bit int
Read8Bit long
ReadAndProcessInner void
ReadAndProcessLength void
ReadCore bool
ReadIdentifier EmberId
ReadLength int?
ReadReal double
SkipCore void
ValidateIdentifierAndLength int

Public Methods

Method Description
Copy ( EmberWriter writer ) : object

Reads the current data value and writes it to writer.

If the EmberReader instance is currently placed on the start of a container, then skips to the end of the container, such that calling Read afterwards will place the reader on either a sibling of the container, the end of the parent container or the end of the stream.

This method has no effect, if the reader is currently placed on a data value with primitive encoding (the next call to Read will skip possibly unread contents anyway).

CopyToEndContainer ( EmberWriter writer, EmberId outerId ) : object

Reads data and writes it to writer until the end of the current container is reached.

While Read returns true and InnerNumber is not equal to Ember.InnerNumber.EndContainer, calls Copy.

EmberReader ( Stream stream ) : System

Initializes a new instance of the EmberReader class by calling EmberReader(Stream, int)">EmberReader(

EmberReader ( Stream stream, int bufferSize ) : System

Initializes a new instance of the EmberReader class.

Read ( ) : bool

Advances the reader to the next data value in the stream.

After this method returns true, client code usually examines the values of the EmberReader.InnerNumber and OuterId properties to determine the next steps. This method returns true in the following situations: The identifiers and lengths of a data value with primitive encoding have been read successfully. Call the appropriate ReadContents method to retrieve the contents of the data value. The identifiers and lengths of a sequence, a set or an application-defined type have been read successfully. Call Read to advance the reader to the data values of the container. The reader has read past the end of a sequence, a set or an application-defined type with definite length. Call Read to advance the reader to the data values located after the container. The End-of-contents marker of a sequence, a set or an application-defined type with indefinite length has been read successfully. Call Read to advance the reader to the data values located after the container.

When a EmberReader is first created and initialized, there is no information available. You must call Read to read the first data value.

Possibly unread contents of the previous data value with primitive encoding is skipped automatically.

ReadContentsAsBoolean ( ) : bool

Reads the contents of the current data value as a bool.

ReadContentsAsByteArray ( ) : byte[]

Reads the contents of the current data value as a byte array.

ReadContentsAsDouble ( ) : double

Reads the contents of the current data value as a double.

ReadContentsAsInt32Array ( ) : int[]

Reads the contents of the current data value as an int array.

ReadContentsAsInt64 ( ) : long

Reads the contents of the current data value as a long.

ReadContentsAsObject ( ) : object

Reads the contents of the current data value.

ReadContentsAsString ( ) : string

Reads the contents of the current data value as a string.

Skip ( ) : void

Skips the contents of the current data value.

If the EmberReader instance is currently placed on the start of a container, then skips to the end of the container, such that calling Read afterwards will place the reader on either a sibling of the container, the end of the parent container or the end of the stream.

This method has no effect, if the reader is currently placed on a data value with primitive encoding (the next call to Read will skip possibly unread contents anyway).

SkipToEndContainer ( ) : void

Skips to the end of the current container.

While Read returns true and InnerNumber is not equal to Ember.InnerNumber.EndContainer, calls Skip.

Private Methods

Method Description
AssertCanReadContents ( int expectedInnerNumber ) : void
AssertNotDisposed ( ) : void
AssertRead ( ) : void
CopyCore ( EmberWriter writer, int inner ) : object
CreateEmberException ( EndOfStreamException ex ) : EmberException
CreateEmberException ( string format ) : EmberException
Dispose ( ) : void
IsContainer ( PositionInfo position ) : bool
ProcessOuter ( EmberId id, long idPosition ) : bool
Read7Bit ( ReadBuffer readBuffer ) : int
Read8Bit ( ReadBuffer readBuffer, int length, bool isSigned ) : long
ReadAndProcessInner ( ) : void
ReadAndProcessLength ( EmberId id, bool isInner ) : void
ReadCore ( ) : bool
ReadIdentifier ( ReadBuffer readBuffer ) : EmberId

See "X.690"X.690, chapter 8.1.2.

ReadLength ( ReadBuffer readBuffer ) : int?

See "X.690"X.690, chapter 8.1.3.

ReadReal ( ReadBuffer readBuffer, int length ) : double

See "X.690"X.690, chapter 8.5 and IEEE Floating-Point Representation. Of course the assumption is that C# has the same floating point representation as C++ (pretty safe, as floating point calculations are done by the hardware).

SkipCore ( int inner ) : void
ValidateIdentifierAndLength ( EmberId innerIdentifier, long innerIdentifierPosition ) : int

Method Details

Copy() public method

Reads the current data value and writes it to writer.

If the EmberReader instance is currently placed on the start of a container, then skips to the end of the container, such that calling Read afterwards will place the reader on either a sibling of the container, the end of the parent container or the end of the stream.

This method has no effect, if the reader is currently placed on a data value with primitive encoding (the next call to Read will skip possibly unread contents anyway).

/// /// has never been called, or /// The last call returned false or threw an exception. /// has been called.
public Copy ( EmberWriter writer ) : object
writer EmberWriter
return object

CopyToEndContainer() public method

Reads data and writes it to writer until the end of the current container is reached.

While Read returns true and InnerNumber is not equal to Ember.InnerNumber.EndContainer, calls Copy.

has been called.
public CopyToEndContainer ( EmberWriter writer, EmberId outerId ) : object
writer EmberWriter
outerId EmberId
return object

EmberReader() public method

Initializes a new instance of the EmberReader class by calling EmberReader(Stream, int)">EmberReader(
public EmberReader ( Stream stream ) : System
stream Stream
return System

EmberReader() public method

Initializes a new instance of the EmberReader class.
equals null. is 0 or negative.
public EmberReader ( Stream stream, int bufferSize ) : System
stream Stream The stream from which the EmBER-encoded input will be read.
bufferSize int The size of the internal buffer in bytes.
return System

Read() public method

Advances the reader to the next data value in the stream.

After this method returns true, client code usually examines the values of the EmberReader.InnerNumber and OuterId properties to determine the next steps. This method returns true in the following situations: The identifiers and lengths of a data value with primitive encoding have been read successfully. Call the appropriate ReadContents method to retrieve the contents of the data value. The identifiers and lengths of a sequence, a set or an application-defined type have been read successfully. Call Read to advance the reader to the data values of the container. The reader has read past the end of a sequence, a set or an application-defined type with definite length. Call Read to advance the reader to the data values located after the container. The End-of-contents marker of a sequence, a set or an application-defined type with indefinite length has been read successfully. Call Read to advance the reader to the data values located after the container.

When a EmberReader is first created and initialized, there is no information available. You must call Read to read the first data value.

Possibly unread contents of the previous data value with primitive encoding is skipped automatically.

An error occurred while parsing the EmBER-encoded data, see /// for more information. has been called.
public Read ( ) : bool
return bool

ReadContentsAsBoolean() public method

Reads the contents of the current data value as a bool.
An error occurred while parsing the EmBER-encoded data, see /// for more information. /// /// The value of is not equal to , /// or /// The contents of the current data value has already been read. /// /// has been called.
public ReadContentsAsBoolean ( ) : bool
return bool

ReadContentsAsByteArray() public method

Reads the contents of the current data value as a byte array.
An error occurred while parsing the EmBER-encoded data, see /// for more information. /// /// The value of is not equal to , /// or /// The contents of the current data value has already been read. /// /// has been called.
public ReadContentsAsByteArray ( ) : byte[]
return byte[]

ReadContentsAsDouble() public method

Reads the contents of the current data value as a double.
An error occurred while parsing the EmBER-encoded data, see /// for more information. /// /// The value of is not equal to , or /// The contents of the current data value has already been read. /// /// has been called.
public ReadContentsAsDouble ( ) : double
return double

ReadContentsAsInt32Array() public method

Reads the contents of the current data value as an int array.
An error occurred while parsing the EmBER-encoded data, see /// for more information. /// /// The value of is not equal to /// , or /// The contents of the current data value has already been read. /// /// has been called.
public ReadContentsAsInt32Array ( ) : int[]
return int[]

ReadContentsAsInt64() public method

Reads the contents of the current data value as a long.
An error occurred while parsing the EmBER-encoded data, see /// for more information. /// /// The value of is not equal to , or /// The contents of the current data value has already been read. /// /// has been called.
public ReadContentsAsInt64 ( ) : long
return long

ReadContentsAsObject() public method

Reads the contents of the current data value.
/// /// The value of equals false, or /// One of the ReadContents methods has already been called for the current data value. /// /// has been called.
public ReadContentsAsObject ( ) : object
return object

ReadContentsAsString() public method

Reads the contents of the current data value as a string.
An error occurred while parsing the EmBER-encoded data, see /// for more information. /// /// The value of is not equal to , /// or /// The contents of the current data value has already been read. /// /// has been called.
public ReadContentsAsString ( ) : string
return string

Skip() public method

Skips the contents of the current data value.

If the EmberReader instance is currently placed on the start of a container, then skips to the end of the container, such that calling Read afterwards will place the reader on either a sibling of the container, the end of the parent container or the end of the stream.

This method has no effect, if the reader is currently placed on a data value with primitive encoding (the next call to Read will skip possibly unread contents anyway).

/// /// has never been called, or /// The last call returned false or threw an exception. /// has been called.
public Skip ( ) : void
return void

SkipToEndContainer() public method

Skips to the end of the current container.

While Read returns true and InnerNumber is not equal to Ember.InnerNumber.EndContainer, calls Skip.

has been called.
public SkipToEndContainer ( ) : void
return void