Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Data Encoding

The data encoding and decoding process uses a Visitor pattern implementation to walk the hierarchical chain of ASN1 objects in a PDU. The two templates used for encoding and decoding are called asn_encode and asn_decode. These two templates use a policy based structure that does the actual work of read/write operations for tags and length fields. Currently, the library supports the BER encoding method, through the ber_taglen policy.

asn_base_ptr pduPtr;
string_list.to(pduPtr);

iostream ostrm;
asn_encode<ber_taglen> encoder(ostrm);
encoder.execute(asn_object);

Decoding a PDU requires simply and inverse of the above code:

iostream istrm;
asn_decode<ber_taglen> decoder(istrm);
decoder.execute(asn_object);

And, viola, you have a decoded packet that you can then transform to you sequence<> based object.

Copyright © 2007 Andreas Haberstroh

PrevUpHomeNext