//   NOTE: this is a machine generated file--editing not recommended
//
// rfc1155-smi.C - class member functions for ASN.1 module RFC1155-SMI
//
//   This file was generated by snacc on Mon May 25 16:21:56 1998
//   UBC snacc written by Mike Sample
//   A couple of enhancements made by IBM European Networking Center

#include <typeinfo>

#include "asn-incl.h"
#include "rfc1155-smi.h"
#include "rfc1157-snmp.h"
#include "rfc1213-mib2.h"

//------------------------------------------------------------------------------
// value defs

const AsnOid internet (1, 3, 6, 1);

const AsnOid directory (1, 3, 6, 1, 1);

const AsnOid mgmt (1, 3, 6, 1, 2);

const AsnOid experimental (1, 3, 6, 1, 3);

const AsnOid private1 (1, 3, 6, 1, 4);

const AsnOid enterprises (1, 3, 6, 1, 4, 1);


//------------------------------------------------------------------------------
// class member definitions:

AsnType *IpAddress::Clone() const
{
  return new IpAddress;
}

AsnLen IpAddress::BEnc (BUF_TYPE b)
{
    AsnLen l;
    l = BEncContent (b);
    l += BEncDefLen (b, l);

    l += BEncTag1 (b, APPL, PRIM, 0);
    return l;
}

void IpAddress::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
{
    AsnTag tag;
    AsnLen elmtLen1;

    if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (APPL, PRIM, 0))
        && (tag != MAKE_TAG_ID (APPL, CONS, 0)))
    {
        Asn1Error << "IpAddress::BDec: ERROR - wrong tag" << endl;
        longjmp (env, -100);
    }
    elmtLen1 = BDecLen (b, bytesDecoded, env);
    BDecContent (b, tag, elmtLen1, bytesDecoded, env);
}

int IpAddress::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
{
    bytesEncoded = BEnc (b);
    return !b.WriteError();
}

int IpAddress::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
{
    ENV_TYPE env;
    int val;

    bytesDecoded = 0;
    if ((val = setjmp (env)) == 0)
    {
         BDec (b, bytesDecoded, env);
         return !b.ReadError();
    }
    else
        return false;
}

AsnType *Counter::Clone() const
{
  return new Counter;
}

AsnLen Counter::BEnc (BUF_TYPE b)
{
    AsnLen l;
    l = BEncContent (b);
    l += BEncConsLen (b, l);

    l += BEncTag1 (b, APPL, PRIM, 1);
    return l;
}

void Counter::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
{
    AsnTag tag;
    AsnLen elmtLen1;

    if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (APPL, PRIM, 1)))
    {
        Asn1Error << "Counter::BDec: ERROR - wrong tag" << endl;
        longjmp (env, -101);
    }
    elmtLen1 = BDecLen (b, bytesDecoded, env);
    BDecContent (b, tag, elmtLen1, bytesDecoded, env);
}

int Counter::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
{
    bytesEncoded = BEnc (b);
    return !b.WriteError();
}

int Counter::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
{
    ENV_TYPE env;
    int val;

    bytesDecoded = 0;
    if ((val = setjmp (env)) == 0)
    {
         BDec (b, bytesDecoded, env);
         return !b.ReadError();
    }
    else
        return false;
}

AsnType *Gauge::Clone() const
{
  return new Gauge;
}

AsnLen Gauge::BEnc (BUF_TYPE b)
{
    AsnLen l;
    l = BEncContent (b);
    l += BEncConsLen (b, l);

    l += BEncTag1 (b, APPL, PRIM, 2);
    return l;
}

void Gauge::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
{
    AsnTag tag;
    AsnLen elmtLen1;

    if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (APPL, PRIM, 2)))
    {
        Asn1Error << "Gauge::BDec: ERROR - wrong tag" << endl;
        longjmp (env, -102);
    }
    elmtLen1 = BDecLen (b, bytesDecoded, env);
    BDecContent (b, tag, elmtLen1, bytesDecoded, env);
}

int Gauge::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
{
    bytesEncoded = BEnc (b);
    return !b.WriteError();
}

int Gauge::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
{
    ENV_TYPE env;
    int val;

    bytesDecoded = 0;
    if ((val = setjmp (env)) == 0)
    {
         BDec (b, bytesDecoded, env);
         return !b.ReadError();
    }
    else
        return false;
}

AsnType *TimeTicks::Clone() const
{
  return new TimeTicks;
}

AsnLen TimeTicks::BEnc (BUF_TYPE b)
{
    AsnLen l;
    l = BEncContent (b);
    l += BEncConsLen (b, l);

    l += BEncTag1 (b, APPL, PRIM, 3);
    return l;
}

void TimeTicks::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
{
    AsnTag tag;
    AsnLen elmtLen1;

    if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (APPL, PRIM, 3)))
    {
        Asn1Error << "TimeTicks::BDec: ERROR - wrong tag" << endl;
        longjmp (env, -103);
    }
    elmtLen1 = BDecLen (b, bytesDecoded, env);
    BDecContent (b, tag, elmtLen1, bytesDecoded, env);
}

int TimeTicks::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
{
    bytesEncoded = BEnc (b);
    return !b.WriteError();
}

int TimeTicks::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
{
    ENV_TYPE env;
    int val;

    bytesDecoded = 0;
    if ((val = setjmp (env)) == 0)
    {
         BDec (b, bytesDecoded, env);
         return !b.ReadError();
    }
    else
        return false;
}

AsnType *Opaque::Clone() const
{
  return new Opaque;
}

AsnLen Opaque::BEnc (BUF_TYPE b)
{
    AsnLen l;
    l = BEncContent (b);
    l += BEncDefLen (b, l);

    l += BEncTag1 (b, APPL, PRIM, 4);
    return l;
}

void Opaque::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
{
    AsnTag tag;
    AsnLen elmtLen1;

    if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (APPL, PRIM, 4))
        && (tag != MAKE_TAG_ID (APPL, CONS, 4)))
    {
        Asn1Error << "Opaque::BDec: ERROR - wrong tag" << endl;
        longjmp (env, -104);
    }
    elmtLen1 = BDecLen (b, bytesDecoded, env);
    BDecContent (b, tag, elmtLen1, bytesDecoded, env);
}

int Opaque::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
{
    bytesEncoded = BEnc (b);
    return !b.WriteError();
}

int Opaque::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
{
    ENV_TYPE env;
    int val;

    bytesDecoded = 0;
    if ((val = setjmp (env)) == 0)
    {
         BDec (b, bytesDecoded, env);
         return !b.ReadError();
    }
    else
        return false;
}

SimpleSyntax::SimpleSyntax()
{
  choiceId = numberCid;
#if TCL
  number = new AsnInt;
#else
  number = NULL; // incomplete initialization of mandatory element!
#endif // TCL
}

SimpleSyntax::SimpleSyntax (const SimpleSyntax &)
{
  Asn1Error << "use of incompletely defined SimpleSyntax::SimpleSyntax (const SimpleSyntax &)" << endl;
  abort();
}

SimpleSyntax::~SimpleSyntax()
{
  switch (choiceId)
  {
    case numberCid:
      delete number;
      break;
    case stringCid:
      delete string;
      break;
    case objectCid:
      delete object;
      break;
    case emptyCid:
      delete empty;
      break;
  } // end of switch
} // end of destructor

AsnType *SimpleSyntax::Clone() const
{
  return new SimpleSyntax;
}

#if SNACC_DEEP_COPY
SimpleSyntax &SimpleSyntax::operator = (const SimpleSyntax &that)
#else // SNACC_DEEP_COPY
SimpleSyntax &SimpleSyntax::operator = (const SimpleSyntax &)
#endif // SNACC_DEEP_COPY
{
#if SNACC_DEEP_COPY
  if (this != &that)
  {
    switch (choiceId)
    {
      case numberCid:
        delete number;
        break;
      case stringCid:
        delete string;
        break;
      case objectCid:
        delete object;
        break;
      case emptyCid:
        delete empty;
        break;
    }
    switch (choiceId = that.choiceId)
    {
      case numberCid:
        number = new AsnInt;
        *number = *that.number;
        break;
      case stringCid:
        string = new AsnOcts;
        *string = *that.string;
        break;
      case objectCid:
        object = new AsnOid;
        *object = *that.object;
        break;
      case emptyCid:
        empty = new AsnNull;
        *empty = *that.empty;
        break;
    }
  }

  return *this;
#else // SNACC_DEEP_COPY
  Asn1Error << "use of incompletely defined SimpleSyntax &SimpleSyntax::operator = (const SimpleSyntax &)" << endl;
  abort();
  // if your compiler complains here, check the -novolat option
#endif // SNACC_DEEP_COPY
}

AsnLen
SimpleSyntax::BEncContent (BUF_TYPE b)
{
  AsnLen l;
  switch (choiceId)
  {
    case numberCid:
      l = number->BEncContent (b);
    BEncDefLenTo127 (b, l);
    l++;

    l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE);
      break;

    case stringCid:
      l = string->BEncContent (b);
    l += BEncDefLen (b, l);

    l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE);
      break;

    case objectCid:
      l = object->BEncContent (b);
    l += BEncDefLen (b, l);

    l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
      break;

    case emptyCid:
      l = empty->BEncContent (b);
    BEncDefLenTo127 (b, l);
    l++;

    l += BEncTag1 (b, UNIV, PRIM, NULLTYPE_TAG_CODE);
      break;

  } // end switch
  return l;
} // SimpleSyntax::BEncContent


void SimpleSyntax::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
{
  switch (tag)
  {
    case MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE):
      choiceId = numberCid;
      number = new AsnInt;
        number->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    case MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE):
    case MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE):
      choiceId = stringCid;
      string = new AsnOcts;
        string->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    case MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE):
      choiceId = objectCid;
      object = new AsnOid;
        object->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    case MAKE_TAG_ID (UNIV, PRIM, NULLTYPE_TAG_CODE):
      choiceId = emptyCid;
      empty = new AsnNull;
        empty->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    default:
      Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
      longjmp (env, -105);
      break;
  } // end switch
} // SimpleSyntax::BDecContent


AsnLen SimpleSyntax::BEnc (BUF_TYPE b)
{
    AsnLen l;
    l = BEncContent (b);
    return l;
}

void SimpleSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
{
    AsnLen elmtLen;
    AsnTag tag;

    /*  CHOICEs are a special case - grab identifying tag */
    /*  this allows easier handling of nested CHOICEs */
    tag = BDecTag (b, bytesDecoded, env);
    elmtLen = BDecLen (b, bytesDecoded, env);
    BDecContent (b, tag, elmtLen, bytesDecoded, env);
}

int SimpleSyntax::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
{
    bytesEncoded = BEnc (b);
    return !b.WriteError();
}

int SimpleSyntax::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
{
    ENV_TYPE env;
    int val;

    bytesDecoded = 0;
    if ((val = setjmp (env)) == 0)
    {
         BDec (b, bytesDecoded, env);
         return !b.ReadError();
    }
    else
        return false;
}

void SimpleSyntax::Print (ostream &os) const
{
  switch (choiceId)
  {
    case numberCid:
      os << "number ";
      if (number)
        os << *number;
      else
        os << "-- void3 --\n";
      break;

    case stringCid:
      os << "string ";
      if (string)
        os << *string;
      else
        os << "-- void3 --\n";
      break;

    case objectCid:
      os << "object ";
      if (object)
        os << *object;
      else
        os << "-- void3 --\n";
      break;

    case emptyCid:
      os << "empty ";
      if (empty)
        os << *empty;
      else
        os << "-- void3 --\n";
      break;

  } // end of switch
} // SimpleSyntax::Print

NetworkAddress::NetworkAddress()
{
  choiceId = internetCid;
#if TCL
  internet = new IpAddress;
#else
  internet = NULL; // incomplete initialization of mandatory element!
#endif // TCL
}

NetworkAddress::NetworkAddress (const NetworkAddress &)
{
  Asn1Error << "use of incompletely defined NetworkAddress::NetworkAddress (const NetworkAddress &)" << endl;
  abort();
}

NetworkAddress::~NetworkAddress()
{
  switch (choiceId)
  {
    case internetCid:
      delete internet;
      break;
  } // end of switch
} // end of destructor

AsnType *NetworkAddress::Clone() const
{
  return new NetworkAddress;
}

#if SNACC_DEEP_COPY
NetworkAddress &NetworkAddress::operator = (const NetworkAddress &that)
#else // SNACC_DEEP_COPY
NetworkAddress &NetworkAddress::operator = (const NetworkAddress &)
#endif // SNACC_DEEP_COPY
{
#if SNACC_DEEP_COPY
  if (this != &that)
  {
    switch (choiceId)
    {
      case internetCid:
        delete internet;
        break;
    }
    switch (choiceId = that.choiceId)
    {
      case internetCid:
        internet = new IpAddress;
        *internet = *that.internet;
        break;
    }
  }

  return *this;
#else // SNACC_DEEP_COPY
  Asn1Error << "use of incompletely defined NetworkAddress &NetworkAddress::operator = (const NetworkAddress &)" << endl;
  abort();
  // if your compiler complains here, check the -novolat option
#endif // SNACC_DEEP_COPY
}

AsnLen
NetworkAddress::BEncContent (BUF_TYPE b)
{
  AsnLen l;
  switch (choiceId)
  {
    case internetCid:
      l = internet->BEncContent (b);
    l += BEncDefLen (b, l);

    l += BEncTag1 (b, APPL, PRIM, 0);
      break;

  } // end switch
  return l;
} // NetworkAddress::BEncContent


void NetworkAddress::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
{
  switch (tag)
  {
    case MAKE_TAG_ID (APPL, PRIM, 0):
    case MAKE_TAG_ID (APPL, CONS, 0):
      choiceId = internetCid;
      internet = new IpAddress;
        internet->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    default:
      Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
      longjmp (env, -106);
      break;
  } // end switch
} // NetworkAddress::BDecContent


AsnLen NetworkAddress::BEnc (BUF_TYPE b)
{
    AsnLen l;
    l = BEncContent (b);
    return l;
}

void NetworkAddress::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
{
    AsnLen elmtLen;
    AsnTag tag;

    /*  CHOICEs are a special case - grab identifying tag */
    /*  this allows easier handling of nested CHOICEs */
    tag = BDecTag (b, bytesDecoded, env);
    elmtLen = BDecLen (b, bytesDecoded, env);
    BDecContent (b, tag, elmtLen, bytesDecoded, env);
}

int NetworkAddress::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
{
    bytesEncoded = BEnc (b);
    return !b.WriteError();
}

int NetworkAddress::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
{
    ENV_TYPE env;
    int val;

    bytesDecoded = 0;
    if ((val = setjmp (env)) == 0)
    {
         BDec (b, bytesDecoded, env);
         return !b.ReadError();
    }
    else
        return false;
}

void NetworkAddress::Print (ostream &os) const
{
  switch (choiceId)
  {
    case internetCid:
      os << "internet ";
      if (internet)
        os << *internet;
      else
        os << "-- void3 --\n";
      break;

  } // end of switch
} // NetworkAddress::Print

ApplicationSyntax::ApplicationSyntax()
{
  choiceId = addressCid;
#if TCL
  address = new NetworkAddress;
#else
  address = NULL; // incomplete initialization of mandatory element!
#endif // TCL
}

ApplicationSyntax::ApplicationSyntax (const ApplicationSyntax &)
{
  Asn1Error << "use of incompletely defined ApplicationSyntax::ApplicationSyntax (const ApplicationSyntax &)" << endl;
  abort();
}

ApplicationSyntax::~ApplicationSyntax()
{
  switch (choiceId)
  {
    case addressCid:
      delete address;
      break;
    case counterCid:
      delete counter;
      break;
    case gaugeCid:
      delete gauge;
      break;
    case ticksCid:
      delete ticks;
      break;
    case arbitraryCid:
      delete arbitrary;
      break;
  } // end of switch
} // end of destructor

AsnType *ApplicationSyntax::Clone() const
{
  return new ApplicationSyntax;
}

#if SNACC_DEEP_COPY
ApplicationSyntax &ApplicationSyntax::operator = (const ApplicationSyntax &that)
#else // SNACC_DEEP_COPY
ApplicationSyntax &ApplicationSyntax::operator = (const ApplicationSyntax &)
#endif // SNACC_DEEP_COPY
{
#if SNACC_DEEP_COPY
  if (this != &that)
  {
    switch (choiceId)
    {
      case addressCid:
        delete address;
        break;
      case counterCid:
        delete counter;
        break;
      case gaugeCid:
        delete gauge;
        break;
      case ticksCid:
        delete ticks;
        break;
      case arbitraryCid:
        delete arbitrary;
        break;
    }
    switch (choiceId = that.choiceId)
    {
      case addressCid:
        address = new NetworkAddress;
        *address = *that.address;
        break;
      case counterCid:
        counter = new Counter;
        *counter = *that.counter;
        break;
      case gaugeCid:
        gauge = new Gauge;
        *gauge = *that.gauge;
        break;
      case ticksCid:
        ticks = new TimeTicks;
        *ticks = *that.ticks;
        break;
      case arbitraryCid:
        arbitrary = new Opaque;
        *arbitrary = *that.arbitrary;
        break;
    }
  }

  return *this;
#else // SNACC_DEEP_COPY
  Asn1Error << "use of incompletely defined ApplicationSyntax &ApplicationSyntax::operator = (const ApplicationSyntax &)" << endl;
  abort();
  // if your compiler complains here, check the -novolat option
#endif // SNACC_DEEP_COPY
}

AsnLen
ApplicationSyntax::BEncContent (BUF_TYPE b)
{
  AsnLen l;
  switch (choiceId)
  {
    case addressCid:
      l = address->BEncContent (b);
      break;

    case counterCid:
      l = counter->BEncContent (b);
    BEncDefLenTo127 (b, l);
    l++;

    l += BEncTag1 (b, APPL, PRIM, 1);
      break;

    case gaugeCid:
      l = gauge->BEncContent (b);
    BEncDefLenTo127 (b, l);
    l++;

    l += BEncTag1 (b, APPL, PRIM, 2);
      break;

    case ticksCid:
      l = ticks->BEncContent (b);
    BEncDefLenTo127 (b, l);
    l++;

    l += BEncTag1 (b, APPL, PRIM, 3);
      break;

    case arbitraryCid:
      l = arbitrary->BEncContent (b);
    l += BEncDefLen (b, l);

    l += BEncTag1 (b, APPL, PRIM, 4);
      break;

  } // end switch
  return l;
} // ApplicationSyntax::BEncContent


void ApplicationSyntax::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
{
  switch (tag)
  {
    case MAKE_TAG_ID (APPL, PRIM, 0):
    case MAKE_TAG_ID (APPL, CONS, 0):
      choiceId = addressCid;
      address = new NetworkAddress;
        address->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    case MAKE_TAG_ID (APPL, PRIM, 1):
      choiceId = counterCid;
      counter = new Counter;
        counter->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    case MAKE_TAG_ID (APPL, PRIM, 2):
      choiceId = gaugeCid;
      gauge = new Gauge;
        gauge->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    case MAKE_TAG_ID (APPL, PRIM, 3):
      choiceId = ticksCid;
      ticks = new TimeTicks;
        ticks->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    case MAKE_TAG_ID (APPL, PRIM, 4):
    case MAKE_TAG_ID (APPL, CONS, 4):
      choiceId = arbitraryCid;
      arbitrary = new Opaque;
        arbitrary->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    default:
      Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
      longjmp (env, -107);
      break;
  } // end switch
} // ApplicationSyntax::BDecContent


AsnLen ApplicationSyntax::BEnc (BUF_TYPE b)
{
    AsnLen l;
    l = BEncContent (b);
    return l;
}

void ApplicationSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
{
    AsnLen elmtLen;
    AsnTag tag;

    /*  CHOICEs are a special case - grab identifying tag */
    /*  this allows easier handling of nested CHOICEs */
    tag = BDecTag (b, bytesDecoded, env);
    elmtLen = BDecLen (b, bytesDecoded, env);
    BDecContent (b, tag, elmtLen, bytesDecoded, env);
}

int ApplicationSyntax::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
{
    bytesEncoded = BEnc (b);
    return !b.WriteError();
}

int ApplicationSyntax::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
{
    ENV_TYPE env;
    int val;

    bytesDecoded = 0;
    if ((val = setjmp (env)) == 0)
    {
         BDec (b, bytesDecoded, env);
         return !b.ReadError();
    }
    else
        return false;
}

void ApplicationSyntax::Print (ostream &os) const
{
  switch (choiceId)
  {
    case addressCid:
      os << "address ";
      if (address)
        os << *address;
      else
        os << "-- void3 --\n";
      break;

    case counterCid:
      os << "counter ";
      if (counter)
        os << *counter;
      else
        os << "-- void3 --\n";
      break;

    case gaugeCid:
      os << "gauge ";
      if (gauge)
        os << *gauge;
      else
        os << "-- void3 --\n";
      break;

    case ticksCid:
      os << "ticks ";
      if (ticks)
        os << *ticks;
      else
        os << "-- void3 --\n";
      break;

    case arbitraryCid:
      os << "arbitrary ";
      if (arbitrary)
        os << *arbitrary;
      else
        os << "-- void3 --\n";
      break;

  } // end of switch
} // ApplicationSyntax::Print

ObjectSyntax::ObjectSyntax()
{
  choiceId = simpleCid;
#if TCL
  simple = new SimpleSyntax;
#else
  simple = NULL; // incomplete initialization of mandatory element!
#endif // TCL
}

ObjectSyntax::ObjectSyntax (const ObjectSyntax &)
{
  Asn1Error << "use of incompletely defined ObjectSyntax::ObjectSyntax (const ObjectSyntax &)" << endl;
  abort();
}

ObjectSyntax::~ObjectSyntax()
{
  switch (choiceId)
  {
    case simpleCid:
      delete simple;
      break;
    case application_wideCid:
      delete application_wide;
      break;
  } // end of switch
} // end of destructor

AsnType *ObjectSyntax::Clone() const
{
  return new ObjectSyntax;
}

#if SNACC_DEEP_COPY
ObjectSyntax &ObjectSyntax::operator = (const ObjectSyntax &that)
#else // SNACC_DEEP_COPY
ObjectSyntax &ObjectSyntax::operator = (const ObjectSyntax &)
#endif // SNACC_DEEP_COPY
{
#if SNACC_DEEP_COPY
  if (this != &that)
  {
    switch (choiceId)
    {
      case simpleCid:
        delete simple;
        break;
      case application_wideCid:
        delete application_wide;
        break;
    }
    switch (choiceId = that.choiceId)
    {
      case simpleCid:
        simple = new SimpleSyntax;
        *simple = *that.simple;
        break;
      case application_wideCid:
        application_wide = new ApplicationSyntax;
        *application_wide = *that.application_wide;
        break;
    }
  }

  return *this;
#else // SNACC_DEEP_COPY
  Asn1Error << "use of incompletely defined ObjectSyntax &ObjectSyntax::operator = (const ObjectSyntax &)" << endl;
  abort();
  // if your compiler complains here, check the -novolat option
#endif // SNACC_DEEP_COPY
}

AsnLen
ObjectSyntax::BEncContent (BUF_TYPE b)
{
  AsnLen l;
  switch (choiceId)
  {
    case simpleCid:
      l = simple->BEncContent (b);
      break;

    case application_wideCid:
      l = application_wide->BEncContent (b);
      break;

  } // end switch
  return l;
} // ObjectSyntax::BEncContent


void ObjectSyntax::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
{
  switch (tag)
  {
    case MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE):
    case MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE):
    case MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE):
    case MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE):
    case MAKE_TAG_ID (UNIV, PRIM, NULLTYPE_TAG_CODE):
      choiceId = simpleCid;
      simple = new SimpleSyntax;
        simple->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    case MAKE_TAG_ID (APPL, PRIM, 0):
    case MAKE_TAG_ID (APPL, CONS, 0):
    case MAKE_TAG_ID (APPL, PRIM, 1):
    case MAKE_TAG_ID (APPL, PRIM, 2):
    case MAKE_TAG_ID (APPL, PRIM, 3):
    case MAKE_TAG_ID (APPL, PRIM, 4):
    case MAKE_TAG_ID (APPL, CONS, 4):
      choiceId = application_wideCid;
      application_wide = new ApplicationSyntax;
        application_wide->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
      break;

    default:
      Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
      longjmp (env, -108);
      break;
  } // end switch
} // ObjectSyntax::BDecContent


AsnLen ObjectSyntax::BEnc (BUF_TYPE b)
{
    AsnLen l;
    l = BEncContent (b);
    return l;
}

void ObjectSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
{
    AsnLen elmtLen;
    AsnTag tag;

    /*  CHOICEs are a special case - grab identifying tag */
    /*  this allows easier handling of nested CHOICEs */
    tag = BDecTag (b, bytesDecoded, env);
    elmtLen = BDecLen (b, bytesDecoded, env);
    BDecContent (b, tag, elmtLen, bytesDecoded, env);
}

int ObjectSyntax::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
{
    bytesEncoded = BEnc (b);
    return !b.WriteError();
}

int ObjectSyntax::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
{
    ENV_TYPE env;
    int val;

    bytesDecoded = 0;
    if ((val = setjmp (env)) == 0)
    {
         BDec (b, bytesDecoded, env);
         return !b.ReadError();
    }
    else
        return false;
}

void ObjectSyntax::Print (ostream &os) const
{
  switch (choiceId)
  {
    case simpleCid:
      os << "simple ";
      if (simple)
        os << *simple;
      else
        os << "-- void3 --\n";
      break;

    case application_wideCid:
      os << "application-wide ";
      if (application_wide)
        os << *application_wide;
      else
        os << "-- void3 --\n";
      break;

  } // end of switch
} // ObjectSyntax::Print

