OSB_LIB::Asn1Len Class Reference

Collaboration diagram for OSB_LIB::Asn1Len:

Collaboration graph
[legend]
List of all members.

Detailed Description

ASN.1 length of type data.

The class supports ASN.1 decoding and encoding of length field. The length of ASN.1 data does not include the type identifier and the length field itself.

Encoding rules:
Three different forms exist for encoding of the length. Their usage depends on the actual value of the lenth:
o The short form is used for values less than 128. In this form the first byte is the value of the length.
o The long form is used for values greater or equal than 128. In this form the seven least significant bits of the first byte tell the number of subsequent bytes to provide the data length.
o The indefinite form has a value of 0x80. It can be used for constructed types only. The end of the type's data is indicated by the universal tag 0 and a length of 0, i.e. two bytes of 0.

Definition at line 224 of file asn1.h.

Public Member Functions

Static Public Attributes

Private Attributes


Constructor & Destructor Documentation

OSB_LIB::Asn1Len::Asn1Len ( size_t  len = 0  )  [inline, explicit]

Constructor taking the length's value.

Definition at line 343 of file asn1.h.


Member Function Documentation

void OSB_LIB::Asn1Len::encode ( Asn1Data dest  )  const

Encode tag to binary data.

Parameters:
dest Buffer to populate.

size_t OSB_LIB::Asn1Len::get ( const Asn1Byte data,
size_t  dataSize 
)

Get encoded ASN.1 data length from binary data.

Parameters:
data Array with binary data.
dataSize Size of binary data.
Returns:
size_t(-1) in case of an error,
else the number of bytes used for the length.

bool OSB_LIB::Asn1Len::isInfinite (  )  const [inline]

Infinite length?

Definition at line 364 of file asn1.h.

References infinite, and len_.

Referenced by operator size_t().

OSB_LIB::Asn1Len::operator size_t (  )  const [inline]

Value of the length.

Definition at line 359 of file asn1.h.

References isInfinite(), and len_.

const Asn1Len & OSB_LIB::Asn1Len::operator= ( size_t  len  )  [inline]

Assignment from size_t.

Definition at line 348 of file asn1.h.

References len_.

Asn1Byte OSB_LIB::Asn1Len::operator[] ( size_t  i  )  const

Return encoded byte at position i.

size_t OSB_LIB::Asn1Len::read ( FILE *  in  ) 

Read ASN.1 encoded length from a input file.

If a read error on the input file occurs, the length is set to 0.

Parameters:
in Input file to read from.
Returns:
Number of bytes read.

void OSB_LIB::Asn1Len::setInfinite (  )  [inline]

Set length to infinite.

Definition at line 354 of file asn1.h.

References infinite, and len_.

size_t OSB_LIB::Asn1Len::size (  )  const

Number of bytes needed for encoding.

std::string OSB_LIB::Asn1Len::str (  )  const

Human readable output of an ASN.1 length.

Remarks:
Use the member function encode(...) to get the binary ASN.1 data.


Member Data Documentation

const size_t OSB_LIB::Asn1Len::infinite = static_cast<size_t>(-1) [static]

Value for infinite length.

Definition at line 227 of file asn1.h.

Referenced by isInfinite(), and setInfinite().

size_t OSB_LIB::Asn1Len::len_ [private]

Value of length.

Definition at line 290 of file asn1.h.

Referenced by isInfinite(), operator size_t(), operator=(), and setInfinite().


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:09:04 2006 for OSB Library by  doxygen 1.4.7