PERCodec.hh 1.04 KB
Newer Older
#ifndef CODECPER_H
#define CODECPER_H

#include "Params.hh"

class OCTETSTRING;
class CHARSTRING;
class BITSTRING;
class TTCN_Buffer;
class TTCN_EncDec;
class TTCN_Typedescriptor_t;

struct asn_TYPE_descriptor_s;

class ASN1RecodePer // FIXME Move into file ASN1RecodePer.hh
{
protected:
  int ber2per (const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf);
  int per2ber (const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf);
  int recode  (const asn_TYPE_descriptor_s & td, int from, int to, TTCN_Buffer & buf);
};

template<typename TPDU>
class PERCodec : public ASN1RecodePer
{
public:
  virtual int encode(const TPDU& msg, BITSTRING& bits) = 0;
  virtual int decode(const BITSTRING& bits, TPDU& msg) = 0;
  
protected:
  int _decode (const TTCN_Typedescriptor_t& ttcn, const asn_TYPE_descriptor_s & td, const BITSTRING& p_data, TPDU& msg);
  int _encode (const TTCN_Typedescriptor_t& ttcn, const asn_TYPE_descriptor_s & td, const TPDU& msg, BITSTRING& p_data);
}; // End of class PERCodec

#include "PERCodec.t.hh"

#endif