Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class asn_base_t

boost::asn1::asn_base_t —

Synopsis

class asn_base_t : public boost::asn1::asn_base_type_t {
public:
  // construct/copy/destruct
  asn_base_t(const primitives_t, const classification_t, const construction_t);
  asn_base_t(const uint32_t, const classification_t, const construction_t);
  ~asn_base_t();

  // public member functions
  const bool isValid() ;
  const bool isIndefinate() const;
  const classification_t classification() const;
  const construction_t construction() const;
  const primitives_t tagid() const;
  const uint32_t appid() const;
  const uint32_t appid(const uint32_t) ;
  const uint32_t tagLength() const;
  const uint32_t lenLength() const;
  const uint32_t length() ;
  const uint32_t length(const uint32_t) ;
  void assign(const asn_base_ptr &) ;
  void assign(const asn_base_t *) ;
  asn_base_t & append(asn_base_t &) ;
  asn_base_t & append(const asn_base_t &) ;
  asn_base_t & append(asn_base_ptr &) ;
  asn_base_t & append(const asn_base_ptr &) ;
  const size_t count() ;
  const asn_base_ptr & get(const size_t = 0) ;
  void setIndefinate(const bool) ;
  uint32_t accept(asn_visitor_t &) ;
  asn_base_ptr clone() const;
  uint32_t encode(asn_visitor_t &) ;
  uint32_t decode(asn_visitor_t &) ;
  size_t size_of() ;

  // protected member functions
  void calcTagLength() ;
  const bool setValid(const bool) ;
};

Description

ASN1 base data type

Overview

All ASN1 data objects inherit from the asn_base_t class. The common functionality that the asn_base_t class provides are tag and length storage, visitor interface, and the required interface methods that every derived ASN1 data object must provide, those being the clone(), encode() and decode() methods.

Memory

The ASN1 library relies heavily on the Boost Smart Pointer Library for pointer storage. The create() and clone() methods return a asn_base_ptr object. This is declared as a typedef:

typedef shared_ptr<asn_base_t> asn_base_ptr;

The asn_base_t class is declared using the Boost shared_ptr template enable_shared_from_this.

Validity

Sometimes, data that is stored in an ASN1 type object does not meet the requirements of valid data. For instance, the time objects require a valid date. It is suggested to use the isValid() method prior to encoding data. When data is stored in a ASN1 container, the container inherits it's validity from all the children present. This makes it easier to know if you have a valid packet of data prior to encoding and transmitting it.

Visitor

Every ASN1 object must provide it's own encode() and decode() methods. These methods are used by the asn_visitor_t objects that execute the encoding and decoding of ASN1 data packets. [NOT COMPLETE]

asn_base_t construct/copy/destruct

  1. asn_base_t(const primitives_t primitive, 
               const classification_t classification, 
               const construction_t construction);

    Consructor for building a primitive ASN1 object.

  2. asn_base_t(const uint32_t appid, const classification_t classification, 
               const construction_t construction);

    Constructor for building a application ASN1 object.

  3. ~asn_base_t();

asn_base_t public member functions

  1. const bool isValid() ;

    Gets whether the ASN1 object is valid

  2. const bool isIndefinate() const;

    Gets whether the ASN1 object has an indefinate length.

  3. const classification_t classification() const;

    Gets the classification of the ASN1 object.

  4. const construction_t construction() const;

    Gets the construction type of the ASN1 object.

  5. const primitives_t tagid() const;

    Gets the primitive type of the ASN1 object.

  6. const uint32_t appid() const;

    Gets the application ID of the ASN1 object.

  7. const uint32_t appid(const uint32_t appid) ;

    Sets the application ID of the ASN1 object.

  8. const uint32_t tagLength() const;

    Gets the length of the tag field for the ASN1 object.

  9. const uint32_t lenLength() const;

    Gets the length of the len field for the ASN1 object.

  10. const uint32_t length() ;

    Gets the length of the payload for the ASN1 object

  11. const uint32_t length(const uint32_t v) ;

    Sets the length of the payload for the ASN1 object

  12. void assign(const asn_base_ptr & asn_object) ;

    Parameters:
    asn_object

    Value to assign

  13. void assign(const asn_base_t * asn_object) ;

    Parameters:
    asn_object

    Value to assign

  14. asn_base_t & append(asn_base_t & v) ;

    Appends an asn_base_t& object to a ASN1 object. This functionality is only used for ASN1 container objects.

    Parameters:
    v

    asn_base_t to append to the container.

  15. asn_base_t & append(const asn_base_t & v) ;

    Appends an asn_base_t& object to a ASN1 object. This functionality is only used for ASN1 container objects.

    Parameters:
    v

    asn_base_t to append to the container.

  16. asn_base_t & append(asn_base_ptr & v) ;

    Appends an asn_base_ptr& object to a ASN1 object. This functionality is only used for ASN1 container objects.

    Parameters:
    v

    asn_base_ptr to append to the container.

  17. asn_base_t & append(const asn_base_ptr & v) ;

    Appends an asn_base_ptr& object to a ASN1 object. This functionality is only used for ASN1 container objects.

    Parameters:
    v

    asn_base_ptr to append to the container.

  18. const size_t count() ;

    Gets the number of ASN1 objects added to this ASN1 object.

  19. const asn_base_ptr & get(const size_t element = 0) ;

    Gets a asn_base_t* from the ASN1 objects added to this ASN1 object.

    Parameters:
    element

    Index of the element to retrieve.

  20. void setIndefinate(const bool v) ;

    Sets whether this ASN1 object is using the indefinate length form.

  21. uint32_t accept(asn_visitor_t & visitor) ;

    Parameters:
    visitor

    Returns:

    Number of bytes visited.

  22. asn_base_ptr clone() const;

    Clone an ASN1 object

    All derived classes must support the clone member function. This is used to copy construct a ASN1 object.

    Returns:

    An asn_base_ptr with the appropriate subclassed object

  23. uint32_t encode(asn_visitor_t & visitor) ;

    Encodes a ASN1 object.

    All derived classes must support the encode member function. This function will encode the ASN1 object using the proper encoding method specified by the ASN1 standard.

    Parameters:
    visitor

    asn_visitor_t used for the encoding.

    Returns:

    The number of bytes used to encode the ASN1 object's data

  24. uint32_t decode(asn_visitor_t & visitor) ;

    Decodes a ASN1 object.

    All derived classes must support the decode member function. This function will decode the ASN1 object using the proper decoding method specified by the ASN1 standard.

    Parameters:
    visitor

    asn_visitor_t used for the decoding.

    Returns:

    The number of bytes used to decode the ASN1 object's data

  25. size_t size_of() ;

    Gets the size of the ASN1 object

    Returns the size of the ASN1 class object sizeof(ASN1)

asn_base_t protected member functions

  1. void calcTagLength() ;

    Calculates the length of the tag

  2. const bool setValid(const bool v) ;

    Sets the validity of a ASN1 object

    ASN1 objects that are not valid should probably not be encoded!

    Parameters:
    v

    If the object is valid or not

Copyright © 2007 Andreas Haberstroh

PrevUpHomeNext