OSB_LIB::Asn1Tag Class Reference

Collaboration diagram for OSB_LIB::Asn1Tag:

Collaboration graph
[legend]
List of all members.

Detailed Description

ASN.1 tag: Type identifier of encoded data.

ASN.1 uses tags to identify the type of encoded data. The class supports encoding, decoding and I/O of ASN.1 tags.

Encoding of tags:
+ Bits 8 and 7 of the frist byte contain the type class,
o universal: 00
o application: 01
o context: 10
o private: 11
+ Bit 6 of the first byte indicates if the type is primitive (0) or constructed (1).
+ Tag numbers less than 31 are coded in bits 5 to 1 of the tag's first byte.
+ For tag numbers greater or equal than 31 bits 5 to 1 of the tag's first byte are set to 11111. The actual number is stored in the subsequent bytes. These bytes contain the tag number in the 7 less significant bits and have bit 8 is set to 1 if more bytes with the tag number follow and bit 8 set to 0 for the final tag number byte. Examples:
o The value for the private tag 11, constructed type is 11101011 (binary) or 0xeb (hexadecimal).
o The application tag 195, primitive type is hexadecimal 0x5f8143.

Definition at line 90 of file asn1.h.

Public Types

Public Member Functions

Static Public Attributes

Private Member Functions

Private Attributes


Member Enumeration Documentation

enum OSB_LIB::Asn1Tag::TypeClass

ASN.1 data type class.

TypeClass defines the class of an ASN.1 data type. It is stored in bits 8 and 7 of the tag's first byte.

Enumerator:
tcUniversal  universal tag
tcApplication  application specific tag
tcContext  context specific tag
tcPrivate  private tag

Definition at line 98 of file asn1.h.


Constructor & Destructor Documentation

OSB_LIB::Asn1Tag::Asn1Tag ( size_t  val = tagNotSet  )  [explicit]

Constructor with encoded tag value.

Parameters:
val Value of the encoded tag, incl. class and primitive/constructed.

OSB_LIB::Asn1Tag::Asn1Tag ( TypeClass  typeClass,
size_t  tagNum,
bool  constructed 
)

Constructor with type class, tag value and flag if the type is constructed.

Remarks:
Copy constructor, assignment and destructor by compiler.
Parameters:
typeClass The type class.
tagNum The tag number.
constructed Flag if type is constructed.


Member Function Documentation

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

Encode tag to binary data.

Parameters:
dest Buffer to populate.

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

Get encoded ASN.1 tag 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 tag.

bool OSB_LIB::Asn1Tag::isConstructed (  )  const [inline]

Check if type is constructed.

Definition at line 320 of file asn1.h.

bool OSB_LIB::Asn1Tag::isSet (  )  const [inline]

Check if the tag is set.

Definition at line 304 of file asn1.h.

References tagNotSet, and value_.

void OSB_LIB::Asn1Tag::mkSize (  )  [inline, private]

Compute size_.

bool OSB_LIB::Asn1Tag::operator!= ( const Asn1Tag rhs  )  const [inline]

Not-equal operator.

Definition at line 331 of file asn1.h.

References value_.

bool OSB_LIB::Asn1Tag::operator< ( const Asn1Tag rhs  )  const [inline]

Less than operator.

Definition at line 336 of file asn1.h.

References value_.

bool OSB_LIB::Asn1Tag::operator== ( const Asn1Tag rhs  )  const [inline]

Equality operator.

Definition at line 326 of file asn1.h.

References value_.

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

Return encoded byte at position i.

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

Read encoded ASN.1 tag from an input file.

If a read error on the input file occurs, the tag value is not set.

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

size_t OSB_LIB::Asn1Tag::size (  )  const [inline]

Number of bytes needed for encoded form.

Definition at line 309 of file asn1.h.

References size_.

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

Human readable output of an ASN.1 tag in hex format.

The returned string is empty if the tag is not set.

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

size_t OSB_LIB::Asn1Tag::tagNumber (  )  const

Tag number (excl. type class and composed flag).

Asn1Tag::TypeClass OSB_LIB::Asn1Tag::typeClass (  )  const [inline]

Get the type class.

Definition at line 314 of file asn1.h.

References tcPrivate.

size_t OSB_LIB::Asn1Tag::value (  )  const [inline]

Tag value (incl. type class and composed flag).

Definition at line 299 of file asn1.h.

References value_.

Referenced by OSB_LIB::Asn1Info::tagValue().


Member Data Documentation

size_t OSB_LIB::Asn1Tag::size_ [private]

Number of bytes needed for encode format.

Definition at line 197 of file asn1.h.

Referenced by size().

const size_t OSB_LIB::Asn1Tag::tagNotSet = size_t(-1) [static]

Value of the tag if not set.

Definition at line 106 of file asn1.h.

Referenced by isSet().

size_t OSB_LIB::Asn1Tag::value_ [private]

Tag value incl. type class and composed flag.

Definition at line 195 of file asn1.h.

Referenced by isSet(), operator!=(), operator<(), operator==(), and value().


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