// This C++ source file was generated by the TTCN-3 compiler
// of the TTCN-3 Test Executor version 11.1.0
// The generation of user and time information were disabled by the -D flag.

// Copyright (c) 2000-2025 Ericsson Telecom AB

// Do not edit this file unless you know what you are doing.

/* Including header files */

#include "AMR_Types.hh"

namespace AMR__Types {

/* Literal string constants */

const unsigned char bs_3_bits[] = { 0 },
bs_1_bits[] = { 0 },
bs_0_bits[] = { 0 },
bs_2_bits[] = { 1 };
extern const BITSTRING bs_3(1, bs_3_bits),
bs_1(2, bs_1_bits),
bs_0(4, bs_0_bits),
bs_2(1, bs_2_bits);
const unsigned char module_checksum[] = { 0x18, 0xfd, 0x71, 0xad, 0x9f, 0xa0, 0xa6, 0xd0, 0x3c, 0x4d, 0x93, 0xa4, 0x0c, 0xfe, 0x51, 0xec };

/* Global variable definitions */

const TTCN_RAWdescriptor_t AMRFT_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
// No XER for AMRFT
const TTCN_Typedescriptor_t AMRFT_descr_ = { "@AMR_Types.AMRFT", NULL, &AMRFT_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING AMRFT_default_coding("RAW");
VALUE_ARRAY<INTEGER, 9, 0> const_c__AMRFT__len;
const VALUE_ARRAY<INTEGER, 9, 0>& c__AMRFT__len = const_c__AMRFT__len;
VALUE_ARRAY<INTEGER, 9, 0> const_c__AMRFT__bits__len;
const VALUE_ARRAY<INTEGER, 9, 0>& c__AMRFT__bits__len = const_c__AMRFT__bits__len;
const TTCN_RAWdescriptor_t RTP__AMR__Hdr_cmr_raw_ = {4,SG_NO,ORDER_MSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__Hdr_cmr_xer_ = { {"cmr>\n", "cmr>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t RTP__AMR__Hdr_cmr_descr_ = { "@AMR_Types.RTP_AMR_Hdr.cmr", &INTEGER_ber_, &RTP__AMR__Hdr_cmr_raw_, &INTEGER_text_, &RTP__AMR__Hdr_cmr_xer_, &INTEGER_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__Hdr_cmr_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__Hdr_padding1_raw_ = {4,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,4,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__Hdr_padding1_xer_ = { {"padding1>\n", "padding1>\n"}, {10, 10}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t RTP__AMR__Hdr_padding1_descr_ = { "@AMR_Types.RTP_AMR_Hdr.padding1", &BITSTRING_ber_, &RTP__AMR__Hdr_padding1_raw_, NULL, &RTP__AMR__Hdr_padding1_xer_, &BITSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__Hdr_padding1_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__Hdr_f_raw_ = {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__Hdr_f_xer_ = { {"f>\n", "f>\n"}, {3, 3}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t RTP__AMR__Hdr_f_descr_ = { "@AMR_Types.RTP_AMR_Hdr.f", &BITSTRING_ber_, &RTP__AMR__Hdr_f_raw_, NULL, &RTP__AMR__Hdr_f_xer_, &BITSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__Hdr_f_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__Hdr_ft_raw_ = {4,SG_NO,ORDER_MSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__Hdr_ft_xer_ = { {"ft>\n", "ft>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t RTP__AMR__Hdr_ft_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t RTP__AMR__Hdr_ft_descr_ = { "@AMR_Types.RTP_AMR_Hdr.ft", &INTEGER_ber_, &RTP__AMR__Hdr_ft_raw_, &INTEGER_text_, &RTP__AMR__Hdr_ft_xer_, &INTEGER_json_, &RTP__AMR__Hdr_ft_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__Hdr_ft_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__Hdr_q_raw_ = {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__Hdr_q_xer_ = { {"q>\n", "q>\n"}, {3, 3}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t RTP__AMR__Hdr_q_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t RTP__AMR__Hdr_q_descr_ = { "@AMR_Types.RTP_AMR_Hdr.q", &BITSTRING_ber_, &RTP__AMR__Hdr_q_raw_, NULL, &RTP__AMR__Hdr_q_xer_, &BITSTRING_json_, &RTP__AMR__Hdr_q_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__Hdr_q_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__Hdr_padding2_raw_ = {2,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,2,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__Hdr_padding2_xer_ = { {"padding2>\n", "padding2>\n"}, {10, 10}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t RTP__AMR__Hdr_padding2_descr_ = { "@AMR_Types.RTP_AMR_Hdr.padding2", &BITSTRING_ber_, &RTP__AMR__Hdr_padding2_raw_, NULL, &RTP__AMR__Hdr_padding2_xer_, &BITSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__Hdr_padding2_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__Hdr_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
// No XER for RTP__AMR__Hdr
const TTCN_Typedescriptor_t RTP__AMR__Hdr_descr_ = { "@AMR_Types.RTP_AMR_Hdr", NULL, &RTP__AMR__Hdr_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__Hdr_default_coding("RAW");
BITSTRING_template template_ts__RTP__AMR__Hdr_q_defval;
const BITSTRING_template& ts__RTP__AMR__Hdr_q_defval = template_ts__RTP__AMR__Hdr_q_defval;
BITSTRING_template template_ts__RTP__AMR__Hdr_f_defval;
const BITSTRING_template& ts__RTP__AMR__Hdr_f_defval = template_ts__RTP__AMR__Hdr_f_defval;
const TTCN_RAWdescriptor_t RTP__AMR__BWE__Hdr_cmr_raw_ = {4,SG_NO,ORDER_MSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__BWE__Hdr_cmr_xer_ = { {"cmr>\n", "cmr>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t RTP__AMR__BWE__Hdr_cmr_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t RTP__AMR__BWE__Hdr_cmr_descr_ = { "@AMR_Types.RTP_AMR_BWE_Hdr.cmr", &INTEGER_ber_, &RTP__AMR__BWE__Hdr_cmr_raw_, &INTEGER_text_, &RTP__AMR__BWE__Hdr_cmr_xer_, &INTEGER_json_, &RTP__AMR__BWE__Hdr_cmr_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__BWE__Hdr_cmr_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__BWE__Hdr_f_raw_ = {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__BWE__Hdr_f_xer_ = { {"f>\n", "f>\n"}, {3, 3}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t RTP__AMR__BWE__Hdr_f_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t RTP__AMR__BWE__Hdr_f_descr_ = { "@AMR_Types.RTP_AMR_BWE_Hdr.f", &BITSTRING_ber_, &RTP__AMR__BWE__Hdr_f_raw_, NULL, &RTP__AMR__BWE__Hdr_f_xer_, &BITSTRING_json_, &RTP__AMR__BWE__Hdr_f_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__BWE__Hdr_f_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__BWE__Hdr_ft_raw_ = {4,SG_NO,ORDER_MSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__BWE__Hdr_ft_xer_ = { {"ft>\n", "ft>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t RTP__AMR__BWE__Hdr_ft_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t RTP__AMR__BWE__Hdr_ft_descr_ = { "@AMR_Types.RTP_AMR_BWE_Hdr.ft", &INTEGER_ber_, &RTP__AMR__BWE__Hdr_ft_raw_, &INTEGER_text_, &RTP__AMR__BWE__Hdr_ft_xer_, &INTEGER_json_, &RTP__AMR__BWE__Hdr_ft_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__BWE__Hdr_ft_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__BWE__Hdr_q_raw_ = {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
const XERdescriptor_t       RTP__AMR__BWE__Hdr_q_xer_ = { {"q>\n", "q>\n"}, {3, 3}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t RTP__AMR__BWE__Hdr_q_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t RTP__AMR__BWE__Hdr_q_descr_ = { "@AMR_Types.RTP_AMR_BWE_Hdr.q", &BITSTRING_ber_, &RTP__AMR__BWE__Hdr_q_raw_, NULL, &RTP__AMR__BWE__Hdr_q_xer_, &BITSTRING_json_, &RTP__AMR__BWE__Hdr_q_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__BWE__Hdr_q_default_coding("RAW");
const TTCN_RAWdescriptor_t RTP__AMR__BWE__Hdr_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN_CHAR_CODING,NULL,false};
// No XER for RTP__AMR__BWE__Hdr
const TTCN_Typedescriptor_t RTP__AMR__BWE__Hdr_descr_ = { "@AMR_Types.RTP_AMR_BWE_Hdr", NULL, &RTP__AMR__BWE__Hdr_raw_, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
UNIVERSAL_CHARSTRING RTP__AMR__BWE__Hdr_default_coding("RAW");
BITSTRING_template template_ts__RTP__AMR__BWE__Hdr_q_defval;
const BITSTRING_template& ts__RTP__AMR__BWE__Hdr_q_defval = template_ts__RTP__AMR__BWE__Hdr_q_defval;
BITSTRING_template template_ts__RTP__AMR__BWE__Hdr_f_defval;
const BITSTRING_template& ts__RTP__AMR__BWE__Hdr_f_defval = template_ts__RTP__AMR__BWE__Hdr_f_defval;
TTCN_Module module_object("AMR_Types", __DATE__, __TIME__, module_checksum, pre_init_module, NULL, 0U, 4294967295U, 4294967295U, 4294967295U, NULL, 0LU, 0, post_init_module, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

const RuntimeVersionChecker ver_checker(  current_runtime_version.requires_major_version_11,
  current_runtime_version.requires_minor_version_1,
  current_runtime_version.requires_patch_level_0,  current_runtime_version.requires_runtime_1);

/* Member functions of C++ classes */

AMRFT::AMRFT()
{
enum_value = UNBOUND_VALUE;
}

AMRFT::AMRFT(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @AMR_Types.AMRFT with invalid numeric value %d.", other_value);
enum_value = (enum_type)other_value;
}

AMRFT::AMRFT(enum_type other_value)
{
enum_value = other_value;
}

AMRFT::AMRFT(const AMRFT& other_value)
: Base_Type()
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @AMR_Types.AMRFT.");
enum_value = other_value.enum_value;
}

AMRFT& AMRFT::operator=(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @AMR_Types.AMRFT.", other_value);
enum_value = (enum_type)other_value;
return *this;
}

AMRFT& AMRFT::operator=(enum_type other_value)
{
enum_value = other_value;
return *this;
}

AMRFT& AMRFT::operator=(const AMRFT& other_value)
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @AMR_Types.AMRFT.");
enum_value = other_value.enum_value;
return *this;
}

boolean AMRFT::operator==(int other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @AMR_Types.AMRFT comparison is an unknown numeric value %d", other_value);
return enum_value == other_value;
}

boolean AMRFT::operator==(enum_type other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
return enum_value == other_value;
}

boolean AMRFT::operator==(const AMRFT& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
return enum_value == other_value.enum_value;
}

boolean AMRFT::operator<(int other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @AMR_Types.AMRFT comparison is an unknown numeric value %d", other_value);
return enum_value < other_value;
}

boolean AMRFT::operator<(enum_type other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
return enum_value < other_value;
}

boolean AMRFT::operator<(const AMRFT& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
return enum_value < other_value.enum_value;
}

boolean AMRFT::operator>(int other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @AMR_Types.AMRFT comparison is an unknown numeric value %d", other_value);
return enum_value > other_value;
}

boolean AMRFT::operator>(enum_type other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
return enum_value > other_value;
}

boolean AMRFT::operator>(const AMRFT& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @AMR_Types.AMRFT.");
return enum_value > other_value.enum_value;
}

const char *AMRFT::enum_to_str(enum_type enum_par)
{
switch (enum_par) {
case AMR__FT__0: return "AMR_FT_0";
case AMR__FT__1: return "AMR_FT_1";
case AMR__FT__2: return "AMR_FT_2";
case AMR__FT__3: return "AMR_FT_3";
case AMR__FT__4: return "AMR_FT_4";
case AMR__FT__5: return "AMR_FT_5";
case AMR__FT__6: return "AMR_FT_6";
case AMR__FT__7: return "AMR_FT_7";
case AMR__FT__SID: return "AMR_FT_SID";
default:
return "<unknown>";
}
}

AMRFT::enum_type AMRFT::str_to_enum(const char *str_par, const int* int_par, const int* int_par2)
{
if (int_par == NULL && int_par2 == NULL) {
if (!strcmp(str_par, "AMR_FT_0")) return AMR__FT__0;
if (!strcmp(str_par, "AMR_FT_1")) return AMR__FT__1;
if (!strcmp(str_par, "AMR_FT_2")) return AMR__FT__2;
if (!strcmp(str_par, "AMR_FT_3")) return AMR__FT__3;
if (!strcmp(str_par, "AMR_FT_4")) return AMR__FT__4;
if (!strcmp(str_par, "AMR_FT_5")) return AMR__FT__5;
if (!strcmp(str_par, "AMR_FT_6")) return AMR__FT__6;
if (!strcmp(str_par, "AMR_FT_7")) return AMR__FT__7;
if (!strcmp(str_par, "AMR_FT_SID")) return AMR__FT__SID;
}
return UNKNOWN_VALUE;
}

boolean AMRFT::is_valid_enum(int int_par)
{
switch (int_par) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
return TRUE;
default:
return FALSE;
}
}

int AMRFT::enum2int(enum_type enum_par)
{
if (enum_par==UNBOUND_VALUE || enum_par==UNKNOWN_VALUE) TTCN_error("The argument of function enum2int() is an %s value of enumerated type @AMR_Types.AMRFT.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par;
}

int AMRFT::enum2int(const AMRFT& enum_par)
{
if (enum_par.enum_value==UNBOUND_VALUE || enum_par.enum_value==UNKNOWN_VALUE) TTCN_error("The argument of function enum2int() is an %s value of enumerated type @AMR_Types.AMRFT.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par.enum_value;
}

void AMRFT::int2enum(int int_val)
{
if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @AMR_Types.AMRFT.", int_val);
enum_value = (enum_type)int_val;
}

AMRFT::operator AMRFT::enum_type() const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @AMR_Types.AMRFT.");
return enum_value;
}

void AMRFT::log() const
{
if (enum_value != UNBOUND_VALUE) TTCN_Logger::log_event_enum(enum_to_str(enum_value), enum_value);
else TTCN_Logger::log_event_unbound();
}

void AMRFT::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "enumerated value");
  if (param.get_type()!=Module_Param::MP_Enumerated) param.type_error("enumerated value", "@AMR_Types.AMRFT");
  enum_value = str_to_enum(param.get_enumerated(), param.get_enumerated_value());
  if (!is_valid_enum(enum_value)) {
    param.error("Invalid enumerated value for type @AMR_Types.AMRFT.");
  }
}

void AMRFT::encode_text(Text_Buf& text_buf) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @AMR_Types.AMRFT.");
text_buf.push_int(enum_value);
}

void AMRFT::decode_text(Text_Buf& text_buf)
{
enum_value = (enum_type)text_buf.pull_int().get_val();
if (!is_valid_enum(enum_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for enumerated type @AMR_Types.AMRFT.", enum_value);
}

void AMRFT::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
    unsigned BER_coding=va_arg(pvar, unsigned);
    BER_encode_chk_coding(BER_coding);
    ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
    tlv->put_in_buffer(p_buf);
    ASN_BER_TLV_t::destruct(tlv);
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    RAW_enc_tr_pos rp;
    rp.level=0;
    rp.pos=NULL;
    RAW_enc_tree root(TRUE, NULL, &rp, 1, p_td.raw);
    RAW_encode(p_td, root);
    root.put_to_buf(p_buf);
    break;}
  case TTCN_EncDec::CT_TEXT: {
    TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
      ("No TEXT descriptor available for type '%s'.", p_td.name);
    TEXT_encode(p_td,p_buf);
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
    p_buf.put_c('\n');
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok(va_arg(pvar, int) != 0);
    JSON_encode(p_td, tok, FALSE);
    p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
    OER_encode(p_td, p_buf);
    break;}
  case TTCN_EncDec::CT_PER: {
    TTCN_EncDec_ErrorContext ec("While PER-encoding type '%s': ", p_td.name);
    if (!p_td.per) TTCN_EncDec_ErrorContext::error_internal(
      "No PER descriptor available for type '%s'.", p_td.name);
    int opt = va_arg(pvar, int);
    PER_encode(p_td, p_buf, opt);
    break; }
  default:
    TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
  }
  va_end(pvar);
}

void AMRFT::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
    unsigned L_form=va_arg(pvar, unsigned);
    ASN_BER_TLV_t tlv;
    BER_decode_str2TLV(p_buf, tlv, L_form);
    BER_decode_TLV(p_td, tlv, L_form);
    if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    raw_order_t r_order;
    switch(p_td.raw->top_bit_order) {
    case TOP_BIT_LEFT:
      r_order=ORDER_LSB;
      break;
    case TOP_BIT_RIGHT:
    default:
      r_order=ORDER_MSB;
    }
    int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
    if(rawr<0) switch (-rawr) {
    case TTCN_EncDec::ET_INCOMPL_MSG:
    case TTCN_EncDec::ET_LEN_ERR:
      ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
      break;
    case 1:
    default:
      ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
      break;
    }
    break;}
  case TTCN_EncDec::CT_TEXT: {
    Limit_Token_List limit;
    TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
        ("No TEXT descriptor available for type '%s'.", p_td.name);
    const unsigned char *b_data=p_buf.get_data();
    int null_added=0;
    if(b_data[p_buf.get_len()-1]!='\0'){
      null_added=1;
      p_buf.set_pos(p_buf.get_len());
      p_buf.put_zero(8,ORDER_LSB);
      p_buf.rewind();
    }
    if(TEXT_decode(p_td,p_buf,limit)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    if(null_added){
      size_t actpos=p_buf.get_pos();
      p_buf.set_pos(p_buf.get_len()-1);
      p_buf.cut_end();
      p_buf.set_pos(actpos);
    }
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XmlReaderWrap reader(p_buf);
    for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
      if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
    }
    XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
    size_t bytes = reader.ByteConsumed();
    p_buf.set_pos(bytes);
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
    if(JSON_decode(p_td, tok, FALSE, FALSE)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    p_buf.set_pos(tok.get_buf_pos());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
     OER_struct p_oer;
    OER_decode(p_td, p_buf, p_oer);
    break;}
  case TTCN_EncDec::CT_PER: {
    TTCN_EncDec_ErrorContext ec("While PER-decoding type '%s': ", p_td.name);
    if(!p_td.per)  TTCN_EncDec_ErrorContext::error_internal(
      "No PER descriptor available for type '%s'.", p_td.name);
    int opt = va_arg(pvar, int);
    try {
      PER_decode(p_td, p_buf, opt);
      p_buf.PER_octet_align(FALSE);
    }
    catch (PER_Buffer_Exception) { }
    break; }
  default:
    TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
  }
  va_end(pvar);
}

int AMRFT::RAW_decode(const TTCN_Typedescriptor_t& p_td,TTCN_Buffer& p_buf,int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit*)
{
  int decoded_value = 0;
  int decoded_length = RAW_decode_enum_type(p_td, p_buf, limit, top_bit_ord, decoded_value, 4, no_err);
  if (decoded_length < 0) return decoded_length;
  if (is_valid_enum(decoded_value)) enum_value = (enum_type)decoded_value;
  else {
    if(no_err){
     return -1;
    } else {
    TTCN_EncDec_ErrorContext::error
      (TTCN_EncDec::ET_ENC_ENUM, "Invalid enum value '%d' for '%s': ",decoded_value, p_td.name);
    enum_value = UNKNOWN_VALUE;
    }
  }
  return decoded_length;
}

int AMRFT::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) const
{
  return RAW_encode_enum_type(p_td, myleaf, (int)enum_value, 4);
}

void AMRFT_template::copy_template(const AMRFT_template& other_value)
{
set_selection(other_value);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = other_value.single_value;
break;
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new AMRFT_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
break;
case IMPLICATION_MATCH:
implication_.precondition = new AMRFT_template(*other_value.implication_.precondition);
implication_.implied_template = new AMRFT_template(*other_value.implication_.implied_template);
break;
case DYNAMIC_MATCH:
dyn_match = other_value.dyn_match;
dyn_match->ref_count++;
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of enumerated type @AMR_Types.AMRFT.");
}
}

AMRFT_template::AMRFT_template()
{
}

AMRFT_template::AMRFT_template(template_sel other_value)
 : Base_Template(other_value)
{
check_single_selection(other_value);
}

AMRFT_template::AMRFT_template(int other_value)
 : Base_Template(SPECIFIC_VALUE)
{
if (!AMRFT::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @AMR_Types.AMRFT with unknown numeric value %d.", other_value);
single_value = (AMRFT::enum_type)other_value;
}

AMRFT_template::AMRFT_template(AMRFT::enum_type other_value)
 : Base_Template(SPECIFIC_VALUE)
{
single_value = other_value;
}

AMRFT_template::AMRFT_template(const AMRFT& other_value)
 : Base_Template(SPECIFIC_VALUE)
{
if (other_value.enum_value == AMRFT::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @AMR_Types.AMRFT.");
single_value = other_value.enum_value;
}

AMRFT_template::AMRFT_template(const OPTIONAL<AMRFT>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (AMRFT::enum_type)(const AMRFT&)other_value;
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of enumerated type @AMR_Types.AMRFT from an unbound optional field.");
}
}

AMRFT_template::AMRFT_template(AMRFT_template* p_precondition, AMRFT_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

AMRFT_template::AMRFT_template(Dynamic_Match_Interface<AMRFT>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<AMRFT>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

AMRFT_template::AMRFT_template(const AMRFT_template& other_value)
 : Base_Template()
{
copy_template(other_value);
}

AMRFT_template::~AMRFT_template()
{
clean_up();
}

boolean AMRFT_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
return TRUE;
}

boolean AMRFT_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value != AMRFT::UNBOUND_VALUE;
}

void AMRFT_template::clean_up()
{
switch (template_selection) {
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
delete [] value_list.list_value;
break;
case IMPLICATION_MATCH:
delete implication_.precondition;
delete implication_.implied_template;
break;
case DYNAMIC_MATCH:
dyn_match->ref_count--;
if (dyn_match->ref_count == 0) {
delete dyn_match->ptr;
delete dyn_match;
}
break;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}

AMRFT_template& AMRFT_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

AMRFT_template& AMRFT_template::operator=(int other_value)
{
if (!AMRFT::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @AMR_Types.AMRFT.", other_value);
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = (AMRFT::enum_type)other_value;
return *this;
}

AMRFT_template& AMRFT_template::operator=(AMRFT::enum_type other_value)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value;
return *this;
}

AMRFT_template& AMRFT_template::operator=(const AMRFT& other_value)
{
if (other_value.enum_value == AMRFT::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @AMR_Types.AMRFT to a template.");
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value.enum_value;
return *this;
}

AMRFT_template& AMRFT_template::operator=(const OPTIONAL<AMRFT>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (AMRFT::enum_type)(const AMRFT&)other_value;
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of enumerated type @AMR_Types.AMRFT.");
}
return *this;
}

AMRFT_template& AMRFT_template::operator=(const AMRFT_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

boolean AMRFT_template::match(AMRFT::enum_type other_value, boolean) const
{
switch (template_selection) {
case SPECIFIC_VALUE:
return single_value == other_value;
case OMIT_VALUE:
return FALSE;
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
case CONJUNCTION_MATCH:
for (unsigned int i = 0; i < value_list.n_values; i++) {
if (!value_list.list_value[i].match(other_value)) {
return FALSE;
}
}
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value);
case DYNAMIC_MATCH:
return dyn_match->ptr->match(other_value);
default:
TTCN_error("Matching an uninitialized/unsupported template of enumerated type @AMR_Types.AMRFT.");
}
return FALSE;
}

boolean AMRFT_template::match(const AMRFT& other_value, boolean) const
{
if (other_value.enum_value == AMRFT::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @AMR_Types.AMRFT with an unbound value.");
return match(other_value.enum_value);
}

AMRFT::enum_type AMRFT_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) TTCN_error("Performing a valueof or send operation on a non-specific template of enumerated type @AMR_Types.AMRFT.");
return single_value;
}

void AMRFT_template::set_type(template_sel template_type, unsigned int list_length)
{
clean_up();
switch (template_type) {
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new AMRFT_template[list_length];
break;
default:
TTCN_error("Setting an invalid type for a template of enumerated type @AMR_Types.AMRFT.");
}
}

AMRFT_template& AMRFT_template::list_item(unsigned int list_index)
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST && template_selection != CONJUNCTION_MATCH) TTCN_error("Accessing a list element in a non-list template of enumerated type @AMR_Types.AMRFT.");
if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @AMR_Types.AMRFT.");
return value_list.list_value[list_index];
}

void AMRFT_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_enum(AMRFT::enum_to_str(single_value), single_value);
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case CONJUNCTION_MATCH:
if (template_selection == CONJUNCTION_MATCH) {
TTCN_Logger::log_event_str("conjunct");
}
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[elem_count].log();
}
TTCN_Logger::log_char(')');
break;
case IMPLICATION_MATCH:
implication_.precondition->log();
TTCN_Logger::log_event_str(" implies ");
implication_.implied_template->log();
break;
case DYNAMIC_MATCH:
TTCN_Logger::log_event_str("@dynamic template");
break;
default:
log_generic();
}
log_ifpresent();
}

void AMRFT_template::log_match(const AMRFT& match_value, boolean) const
{
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}

void AMRFT_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
text_buf.push_int(single_value);
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
text_buf.push_int(value_list.n_values);
for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++)
value_list.list_value[elem_count].encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of enumerated type @AMR_Types.AMRFT.");
}
}

void AMRFT_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = (AMRFT::enum_type)text_buf.pull_int().get_val();
if (!AMRFT::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @AMR_Types.AMRFT.", single_value);
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = text_buf.pull_int().get_val();
value_list.list_value = new AMRFT_template[value_list.n_values];
for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++)
value_list.list_value[elem_count].decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: An unknown/unsupported selection was received for a template of enumerated type @AMR_Types.AMRFT.");
}
}

boolean AMRFT_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean AMRFT_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match_omit() || implication_.implied_template->match_omit();
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int i=0; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

void AMRFT_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "enumerated template");
  Module_Param_Ptr m_p = &param;
  switch (m_p->get_type()) {
  case Module_Param::MP_Omit:
    *this = OMIT_VALUE;
    break;
  case Module_Param::MP_Any:
    *this = ANY_VALUE;
    break;
  case Module_Param::MP_AnyOrNone:
    *this = ANY_OR_OMIT;
    break;
  case Module_Param::MP_List_Template:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    AMRFT_template new_temp;
    new_temp.set_type(m_p->get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (m_p->get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), m_p->get_size());
    for (size_t p_i=0; p_i<m_p->get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Enumerated: {
    AMRFT::enum_type enum_val = AMRFT::str_to_enum(m_p->get_enumerated(), m_p->get_enumerated_value());
    if (!AMRFT::is_valid_enum(enum_val)) {
      param.error("Invalid enumerated value for type @AMR_Types.AMRFT.");
    }
    *this = enum_val;
  } break;
  case Module_Param::MP_Implication_Template: {
    AMRFT_template* precondition = new AMRFT_template;
    precondition->set_param(*m_p->get_elem(0));
    AMRFT_template* implied_template = new AMRFT_template;
    implied_template->set_param(*m_p->get_elem(1));
    *this = AMRFT_template(precondition, implied_template);
  } break;
  default:
    param.type_error("enumerated template", "@AMR_Types.AMRFT");
  }
  is_ifpresent = param.get_ifpresent();
}

void AMRFT_template::check_restriction(template_res t_res, const char* t_name,
boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return;
switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
case TR_VALUE:
if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return;
break;
case TR_OMIT:
if (!is_ifpresent && (template_selection==OMIT_VALUE || template_selection==SPECIFIC_VALUE)) return;
break;
case TR_PRESENT:
if (!match_omit(legacy)) return;
break;
default:
return;
}
TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@AMR_Types.AMRFT");
}

RTP__AMR__Hdr::RTP__AMR__Hdr()
{
}

RTP__AMR__Hdr::RTP__AMR__Hdr(const INTEGER& par_cmr,
    const BITSTRING& par_padding1,
    const BITSTRING& par_f,
    const INTEGER& par_ft,
    const BITSTRING& par_q,
    const BITSTRING& par_padding2)
  :   field_cmr(par_cmr),
  field_padding1(par_padding1),
  field_f(par_f),
  field_ft(par_ft),
  field_q(par_q),
  field_padding2(par_padding2)
{
}

RTP__AMR__Hdr::RTP__AMR__Hdr(const RTP__AMR__Hdr& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @AMR_Types.RTP_AMR_Hdr.");
if (other_value.cmr().is_bound()) field_cmr = other_value.cmr();
else field_cmr.clean_up();
if (other_value.padding1().is_bound()) field_padding1 = other_value.padding1();
else field_padding1.clean_up();
if (other_value.f().is_bound()) field_f = other_value.f();
else field_f.clean_up();
if (other_value.ft().is_bound()) field_ft = other_value.ft();
else field_ft.clean_up();
if (other_value.q().is_bound()) field_q = other_value.q();
else field_q.clean_up();
if (other_value.padding2().is_bound()) field_padding2 = other_value.padding2();
else field_padding2.clean_up();
}

void RTP__AMR__Hdr::clean_up()
{
field_cmr.clean_up();
field_padding1.clean_up();
field_f.clean_up();
field_ft.clean_up();
field_q.clean_up();
field_padding2.clean_up();
}

const TTCN_Typedescriptor_t* RTP__AMR__Hdr::get_descriptor() const { return &RTP__AMR__Hdr_descr_; }
RTP__AMR__Hdr& RTP__AMR__Hdr::operator=(const RTP__AMR__Hdr& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @AMR_Types.RTP_AMR_Hdr.");
  if (other_value.cmr().is_bound()) field_cmr = other_value.cmr();
  else field_cmr.clean_up();
  if (other_value.padding1().is_bound()) field_padding1 = other_value.padding1();
  else field_padding1.clean_up();
  if (other_value.f().is_bound()) field_f = other_value.f();
  else field_f.clean_up();
  if (other_value.ft().is_bound()) field_ft = other_value.ft();
  else field_ft.clean_up();
  if (other_value.q().is_bound()) field_q = other_value.q();
  else field_q.clean_up();
  if (other_value.padding2().is_bound()) field_padding2 = other_value.padding2();
  else field_padding2.clean_up();
}
return *this;
}

boolean RTP__AMR__Hdr::operator==(const RTP__AMR__Hdr& other_value) const
{
return field_cmr==other_value.field_cmr
  && field_padding1==other_value.field_padding1
  && field_f==other_value.field_f
  && field_ft==other_value.field_ft
  && field_q==other_value.field_q
  && field_padding2==other_value.field_padding2;
}

boolean RTP__AMR__Hdr::is_bound() const
{
return (field_cmr.is_bound())
  || (field_padding1.is_bound())
  || (field_f.is_bound())
  || (field_ft.is_bound())
  || (field_q.is_bound())
  || (field_padding2.is_bound());
}
boolean RTP__AMR__Hdr::is_value() const
{
return field_cmr.is_value()
  && field_padding1.is_value()
  && field_f.is_value()
  && field_ft.is_value()
  && field_q.is_value()
  && field_padding2.is_value();
}
void RTP__AMR__Hdr::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ cmr := ");
field_cmr.log();
TTCN_Logger::log_event_str(", padding1 := ");
field_padding1.log();
TTCN_Logger::log_event_str(", f := ");
field_f.log();
TTCN_Logger::log_event_str(", ft := ");
field_ft.log();
TTCN_Logger::log_event_str(", q := ");
field_q.log();
TTCN_Logger::log_event_str(", padding2 := ");
field_padding2.log();
TTCN_Logger::log_event_str(" }");
}

void RTP__AMR__Hdr::set_implicit_omit()
{
if (cmr().is_bound()) cmr().set_implicit_omit();
if (padding1().is_bound()) padding1().set_implicit_omit();
if (f().is_bound()) f().set_implicit_omit();
if (ft().is_bound()) ft().set_implicit_omit();
if (q().is_bound()) q().set_implicit_omit();
if (padding2().is_bound()) padding2().set_implicit_omit();
}

void RTP__AMR__Hdr::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
  switch (param.get_type()) {
  case Module_Param::MP_Value_List:
    if (6<param.get_size()) {
      param.error("record value of type @AMR_Types.RTP_AMR_Hdr has 6 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) cmr().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) padding1().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) f().set_param(*param.get_elem(2));
    if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) ft().set_param(*param.get_elem(3));
    if (param.get_size()>4 && param.get_elem(4)->get_type()!=Module_Param::MP_NotUsed) q().set_param(*param.get_elem(4));
    if (param.get_size()>5 && param.get_elem(5)->get_type()!=Module_Param::MP_NotUsed) padding2().set_param(*param.get_elem(5));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "cmr")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          cmr().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "padding1")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          padding1().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "f")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          f().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "ft")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          ft().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "q")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          q().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "padding2")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          padding2().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @AMR_Types.RTP_AMR_Hdr: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@AMR_Types.RTP_AMR_Hdr");
  }
}

void RTP__AMR__Hdr::encode_text(Text_Buf& text_buf) const
{
field_cmr.encode_text(text_buf);
field_padding1.encode_text(text_buf);
field_f.encode_text(text_buf);
field_ft.encode_text(text_buf);
field_q.encode_text(text_buf);
field_padding2.encode_text(text_buf);
}

void RTP__AMR__Hdr::decode_text(Text_Buf& text_buf)
{
field_cmr.decode_text(text_buf);
field_padding1.decode_text(text_buf);
field_f.decode_text(text_buf);
field_ft.decode_text(text_buf);
field_q.decode_text(text_buf);
field_padding2.decode_text(text_buf);
}

void RTP__AMR__Hdr::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
    unsigned BER_coding=va_arg(pvar, unsigned);
    BER_encode_chk_coding(BER_coding);
    ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
    tlv->put_in_buffer(p_buf);
    ASN_BER_TLV_t::destruct(tlv);
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    RAW_enc_tr_pos rp;
    rp.level=0;
    rp.pos=NULL;
    RAW_enc_tree root(FALSE, NULL, &rp, 1, p_td.raw);
    RAW_encode(p_td, root);
    root.put_to_buf(p_buf);
    break;}
  case TTCN_EncDec::CT_TEXT: {
    TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
      ("No TEXT descriptor available for type '%s'.", p_td.name);
    TEXT_encode(p_td,p_buf);
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
    p_buf.put_c('\n');
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok(va_arg(pvar, int) != 0);
    JSON_encode(p_td, tok, FALSE);
    p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
    OER_encode(p_td, p_buf);
    break;}
  case TTCN_EncDec::CT_PER: {
    TTCN_EncDec_ErrorContext ec("While PER-encoding type '%s': ", p_td.name);
    if (!p_td.per) TTCN_EncDec_ErrorContext::error_internal(
      "No PER descriptor available for type '%s'.", p_td.name);
    int opt = va_arg(pvar, int);
    PER_encode(p_td, p_buf, opt);
    break; }
  default:
    TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
  }
  va_end(pvar);
}

void RTP__AMR__Hdr::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
    unsigned L_form=va_arg(pvar, unsigned);
    ASN_BER_TLV_t tlv;
    BER_decode_str2TLV(p_buf, tlv, L_form);
    BER_decode_TLV(p_td, tlv, L_form);
    if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    raw_order_t r_order;
    switch(p_td.raw->top_bit_order) {
    case TOP_BIT_LEFT:
      r_order=ORDER_LSB;
      break;
    case TOP_BIT_RIGHT:
    default:
      r_order=ORDER_MSB;
    }
    int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
    if(rawr<0) switch (-rawr) {
    case TTCN_EncDec::ET_INCOMPL_MSG:
    case TTCN_EncDec::ET_LEN_ERR:
      ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
      break;
    case 1:
    default:
      ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
      break;
    }
    break;}
  case TTCN_EncDec::CT_TEXT: {
    Limit_Token_List limit;
    TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
        ("No TEXT descriptor available for type '%s'.", p_td.name);
    const unsigned char *b_data=p_buf.get_data();
    int null_added=0;
    if(b_data[p_buf.get_len()-1]!='\0'){
      null_added=1;
      p_buf.set_pos(p_buf.get_len());
      p_buf.put_zero(8,ORDER_LSB);
      p_buf.rewind();
    }
    if(TEXT_decode(p_td,p_buf,limit)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    if(null_added){
      size_t actpos=p_buf.get_pos();
      p_buf.set_pos(p_buf.get_len()-1);
      p_buf.cut_end();
      p_buf.set_pos(actpos);
    }
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XmlReaderWrap reader(p_buf);
    for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
      if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
    }
    XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
    size_t bytes = reader.ByteConsumed();
    p_buf.set_pos(bytes);
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
    if(JSON_decode(p_td, tok, FALSE, FALSE)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    p_buf.set_pos(tok.get_buf_pos());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
     OER_struct p_oer;
    OER_decode(p_td, p_buf, p_oer);
    break;}
  case TTCN_EncDec::CT_PER: {
    TTCN_EncDec_ErrorContext ec("While PER-decoding type '%s': ", p_td.name);
    if(!p_td.per)  TTCN_EncDec_ErrorContext::error_internal(
      "No PER descriptor available for type '%s'.", p_td.name);
    int opt = va_arg(pvar, int);
    try {
      PER_decode(p_td, p_buf, opt);
      p_buf.PER_octet_align(FALSE);
    }
    catch (PER_Buffer_Exception) { }
    break; }
  default:
    TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
  }
  va_end(pvar);
}

int RTP__AMR__Hdr::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit* force_omit)
{ (void)no_err;
  int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);
  limit-=prepaddlength;
  size_t last_decoded_pos = p_buf.get_pos_bit();
  int decoded_length = 0;
  int decoded_field_length = 0;
  raw_order_t local_top_order;
  if(p_td.raw->top_bit_order==TOP_BIT_INHERITED)local_top_order=top_bit_ord;
  else if(p_td.raw->top_bit_order==TOP_BIT_RIGHT)local_top_order=ORDER_MSB;
  else local_top_order=ORDER_LSB;
  RAW_Force_Omit field_0_force_omit(0, force_omit, RTP__AMR__Hdr_cmr_descr_.raw->forceomit);
  decoded_field_length = field_cmr.RAW_decode(RTP__AMR__Hdr_cmr_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_0_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  RAW_Force_Omit field_1_force_omit(1, force_omit, RTP__AMR__Hdr_padding1_descr_.raw->forceomit);
  decoded_field_length = field_padding1.RAW_decode(RTP__AMR__Hdr_padding1_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_1_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  RAW_Force_Omit field_2_force_omit(2, force_omit, RTP__AMR__Hdr_f_descr_.raw->forceomit);
  decoded_field_length = field_f.RAW_decode(RTP__AMR__Hdr_f_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_2_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  RAW_Force_Omit field_3_force_omit(3, force_omit, RTP__AMR__Hdr_ft_descr_.raw->forceomit);
  decoded_field_length = field_ft.RAW_decode(RTP__AMR__Hdr_ft_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_3_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  RAW_Force_Omit field_4_force_omit(4, force_omit, RTP__AMR__Hdr_q_descr_.raw->forceomit);
  decoded_field_length = field_q.RAW_decode(RTP__AMR__Hdr_q_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_4_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  RAW_Force_Omit field_5_force_omit(5, force_omit, RTP__AMR__Hdr_padding2_descr_.raw->forceomit);
  decoded_field_length = field_padding2.RAW_decode(RTP__AMR__Hdr_padding2_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_5_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  p_buf.set_pos_bit(last_decoded_pos);
  return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding);
}

int RTP__AMR__Hdr::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const {
  if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
  int encoded_length = 0;
  myleaf.isleaf = FALSE;
  myleaf.body.node.num_of_nodes = 6;
  myleaf.body.node.nodes = init_nodes_of_enc_tree(6);
  myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, RTP__AMR__Hdr_cmr_descr_.raw);
  myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, RTP__AMR__Hdr_padding1_descr_.raw);
  myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 2, RTP__AMR__Hdr_f_descr_.raw);
  myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 3, RTP__AMR__Hdr_ft_descr_.raw);
  myleaf.body.node.nodes[4] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 4, RTP__AMR__Hdr_q_descr_.raw);
  myleaf.body.node.nodes[5] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 5, RTP__AMR__Hdr_padding2_descr_.raw);
  encoded_length += field_cmr.RAW_encode(RTP__AMR__Hdr_cmr_descr_, *myleaf.body.node.nodes[0]);
  encoded_length += field_padding1.RAW_encode(RTP__AMR__Hdr_padding1_descr_, *myleaf.body.node.nodes[1]);
  encoded_length += field_f.RAW_encode(RTP__AMR__Hdr_f_descr_, *myleaf.body.node.nodes[2]);
  encoded_length += field_ft.RAW_encode(RTP__AMR__Hdr_ft_descr_, *myleaf.body.node.nodes[3]);
  encoded_length += field_q.RAW_encode(RTP__AMR__Hdr_q_descr_, *myleaf.body.node.nodes[4]);
  encoded_length += field_padding2.RAW_encode(RTP__AMR__Hdr_padding2_descr_, *myleaf.body.node.nodes[5]);
  return myleaf.length = encoded_length;
}

struct RTP__AMR__Hdr_template::single_value_struct {
INTEGER_template field_cmr;
BITSTRING_template field_padding1;
BITSTRING_template field_f;
INTEGER_template field_ft;
BITSTRING_template field_q;
BITSTRING_template field_padding2;
};

void RTP__AMR__Hdr_template::set_specific()
{
if (template_selection != SPECIFIC_VALUE) {
template_sel old_selection = template_selection;
clean_up();
single_value = new single_value_struct;
set_selection(SPECIFIC_VALUE);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
single_value->field_cmr = ANY_VALUE;
single_value->field_padding1 = ANY_VALUE;
single_value->field_f = ANY_VALUE;
single_value->field_ft = ANY_VALUE;
single_value->field_q = ANY_VALUE;
single_value->field_padding2 = ANY_VALUE;
}
}
}

void RTP__AMR__Hdr_template::copy_value(const RTP__AMR__Hdr& other_value)
{
single_value = new single_value_struct;
if (other_value.cmr().is_bound()) {
  single_value->field_cmr = other_value.cmr();
} else {
  single_value->field_cmr.clean_up();
}
if (other_value.padding1().is_bound()) {
  single_value->field_padding1 = other_value.padding1();
} else {
  single_value->field_padding1.clean_up();
}
if (other_value.f().is_bound()) {
  single_value->field_f = other_value.f();
} else {
  single_value->field_f.clean_up();
}
if (other_value.ft().is_bound()) {
  single_value->field_ft = other_value.ft();
} else {
  single_value->field_ft.clean_up();
}
if (other_value.q().is_bound()) {
  single_value->field_q = other_value.q();
} else {
  single_value->field_q.clean_up();
}
if (other_value.padding2().is_bound()) {
  single_value->field_padding2 = other_value.padding2();
} else {
  single_value->field_padding2.clean_up();
}
set_selection(SPECIFIC_VALUE);
}

void RTP__AMR__Hdr_template::copy_template(const RTP__AMR__Hdr_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.cmr().get_selection()) {
single_value->field_cmr = other_value.cmr();
} else {
single_value->field_cmr.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.padding1().get_selection()) {
single_value->field_padding1 = other_value.padding1();
} else {
single_value->field_padding1.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.f().get_selection()) {
single_value->field_f = other_value.f();
} else {
single_value->field_f.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.ft().get_selection()) {
single_value->field_ft = other_value.ft();
} else {
single_value->field_ft.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.q().get_selection()) {
single_value->field_q = other_value.q();
} else {
single_value->field_q.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.padding2().get_selection()) {
single_value->field_padding2 = other_value.padding2();
} else {
single_value->field_padding2.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new RTP__AMR__Hdr_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
break;
case IMPLICATION_MATCH:
implication_.precondition = new RTP__AMR__Hdr_template(*other_value.implication_.precondition);
implication_.implied_template = new RTP__AMR__Hdr_template(*other_value.implication_.implied_template);
break;
case DYNAMIC_MATCH:
dyn_match = other_value.dyn_match;
dyn_match->ref_count++;
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @AMR_Types.RTP_AMR_Hdr.");
break;
}
set_selection(other_value);
}

RTP__AMR__Hdr_template::RTP__AMR__Hdr_template()
{
}

RTP__AMR__Hdr_template::RTP__AMR__Hdr_template(template_sel other_value)
 : Base_Template(other_value)
{
check_single_selection(other_value);
}

RTP__AMR__Hdr_template::RTP__AMR__Hdr_template(const RTP__AMR__Hdr& other_value)
{
copy_value(other_value);
}

RTP__AMR__Hdr_template::RTP__AMR__Hdr_template(const OPTIONAL<RTP__AMR__Hdr>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const RTP__AMR__Hdr&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @AMR_Types.RTP_AMR_Hdr from an unbound optional field.");
}
}

RTP__AMR__Hdr_template::RTP__AMR__Hdr_template(RTP__AMR__Hdr_template* p_precondition, RTP__AMR__Hdr_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

RTP__AMR__Hdr_template::RTP__AMR__Hdr_template(Dynamic_Match_Interface<RTP__AMR__Hdr>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<RTP__AMR__Hdr>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

RTP__AMR__Hdr_template::RTP__AMR__Hdr_template(const RTP__AMR__Hdr_template& other_value)
: Base_Template()
{
copy_template(other_value);
}

RTP__AMR__Hdr_template::~RTP__AMR__Hdr_template()
{
clean_up();
}

RTP__AMR__Hdr_template& RTP__AMR__Hdr_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

RTP__AMR__Hdr_template& RTP__AMR__Hdr_template::operator=(const RTP__AMR__Hdr& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}

RTP__AMR__Hdr_template& RTP__AMR__Hdr_template::operator=(const OPTIONAL<RTP__AMR__Hdr>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const RTP__AMR__Hdr&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of type @AMR_Types.RTP_AMR_Hdr.");
}
return *this;
}

RTP__AMR__Hdr_template& RTP__AMR__Hdr_template::operator=(const RTP__AMR__Hdr_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

boolean RTP__AMR__Hdr_template::match(const RTP__AMR__Hdr& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case OMIT_VALUE:
return FALSE;
case SPECIFIC_VALUE:
if(!other_value.cmr().is_bound()) return FALSE;
if(!single_value->field_cmr.match(other_value.cmr(), legacy))return FALSE;
if(!other_value.padding1().is_bound()) return FALSE;
if(!single_value->field_padding1.match(other_value.padding1(), legacy))return FALSE;
if(!other_value.f().is_bound()) return FALSE;
if(!single_value->field_f.match(other_value.f(), legacy))return FALSE;
if(!other_value.ft().is_bound()) return FALSE;
if(!single_value->field_ft.match(other_value.ft(), legacy))return FALSE;
if(!other_value.q().is_bound()) return FALSE;
if(!single_value->field_q.match(other_value.q(), legacy))return FALSE;
if(!other_value.padding2().is_bound()) return FALSE;
if(!single_value->field_padding2.match(other_value.padding2(), legacy))return FALSE;
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
if (value_list.list_value[list_count].match(other_value, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
case CONJUNCTION_MATCH:
for (unsigned int i = 0; i < value_list.n_values; i++) {
if (!value_list.list_value[i].match(other_value)) {
return FALSE;
}
}
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value);
case DYNAMIC_MATCH:
return dyn_match->ptr->match(other_value);
default:
TTCN_error("Matching an uninitialized/unsupported template of type @AMR_Types.RTP_AMR_Hdr.");
}
return FALSE;
}

boolean RTP__AMR__Hdr_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_cmr.is_bound()
 || single_value->field_padding1.is_bound()
 || single_value->field_f.is_bound()
 || single_value->field_ft.is_bound()
 || single_value->field_q.is_bound()
 || single_value->field_padding2.is_bound();
}

boolean RTP__AMR__Hdr_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_cmr.is_value()
 && single_value->field_padding1.is_value()
 && single_value->field_f.is_value()
 && single_value->field_ft.is_value()
 && single_value->field_q.is_value()
 && single_value->field_padding2.is_value();
}

void RTP__AMR__Hdr_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
delete [] value_list.list_value;
break;
case IMPLICATION_MATCH:
delete implication_.precondition;
delete implication_.implied_template;
break;
case DYNAMIC_MATCH:
dyn_match->ref_count--;
if (dyn_match->ref_count == 0) {
delete dyn_match->ptr;
delete dyn_match;
}
break;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}

RTP__AMR__Hdr RTP__AMR__Hdr_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of type @AMR_Types.RTP_AMR_Hdr.");
RTP__AMR__Hdr ret_val;
if (single_value->field_cmr.is_bound()) {
ret_val.cmr() = single_value->field_cmr.valueof();
}
if (single_value->field_padding1.is_bound()) {
ret_val.padding1() = single_value->field_padding1.valueof();
}
if (single_value->field_f.is_bound()) {
ret_val.f() = single_value->field_f.valueof();
}
if (single_value->field_ft.is_bound()) {
ret_val.ft() = single_value->field_ft.valueof();
}
if (single_value->field_q.is_bound()) {
ret_val.q() = single_value->field_q.valueof();
}
if (single_value->field_padding2.is_bound()) {
ret_val.padding2() = single_value->field_padding2.valueof();
}
return ret_val;
}

void RTP__AMR__Hdr_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST&& template_type != CONJUNCTION_MATCH)
TTCN_error("Setting an invalid list for a template of type @AMR_Types.RTP_AMR_Hdr.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new RTP__AMR__Hdr_template[list_length];
}

RTP__AMR__Hdr_template& RTP__AMR__Hdr_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST&& template_selection != CONJUNCTION_MATCH)
TTCN_error("Accessing a list element of a non-list template of type @AMR_Types.RTP_AMR_Hdr.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @AMR_Types.RTP_AMR_Hdr.");
return value_list.list_value[list_index];
}

INTEGER_template& RTP__AMR__Hdr_template::cmr()
{
set_specific();
return single_value->field_cmr;
}

const INTEGER_template& RTP__AMR__Hdr_template::cmr() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field cmr of a non-specific template of type @AMR_Types.RTP_AMR_Hdr.");
return single_value->field_cmr;
}

BITSTRING_template& RTP__AMR__Hdr_template::padding1()
{
set_specific();
return single_value->field_padding1;
}

const BITSTRING_template& RTP__AMR__Hdr_template::padding1() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field padding1 of a non-specific template of type @AMR_Types.RTP_AMR_Hdr.");
return single_value->field_padding1;
}

BITSTRING_template& RTP__AMR__Hdr_template::f()
{
set_specific();
return single_value->field_f;
}

const BITSTRING_template& RTP__AMR__Hdr_template::f() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field f of a non-specific template of type @AMR_Types.RTP_AMR_Hdr.");
return single_value->field_f;
}

INTEGER_template& RTP__AMR__Hdr_template::ft()
{
set_specific();
return single_value->field_ft;
}

const INTEGER_template& RTP__AMR__Hdr_template::ft() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field ft of a non-specific template of type @AMR_Types.RTP_AMR_Hdr.");
return single_value->field_ft;
}

BITSTRING_template& RTP__AMR__Hdr_template::q()
{
set_specific();
return single_value->field_q;
}

const BITSTRING_template& RTP__AMR__Hdr_template::q() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field q of a non-specific template of type @AMR_Types.RTP_AMR_Hdr.");
return single_value->field_q;
}

BITSTRING_template& RTP__AMR__Hdr_template::padding2()
{
set_specific();
return single_value->field_padding2;
}

const BITSTRING_template& RTP__AMR__Hdr_template::padding2() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field padding2 of a non-specific template of type @AMR_Types.RTP_AMR_Hdr.");
return single_value->field_padding2;
}

int RTP__AMR__Hdr_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_Hdr which has an ifpresent attribute.");
  switch (template_selection)
  {
  case SPECIFIC_VALUE:
    return 6;
  case VALUE_LIST:
   {
     if (value_list.n_values<1)
       TTCN_error("Internal error: Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_Hdr containing an empty list.");
      int item_size = value_list.list_value[0].size_of();
      for (unsigned int l_idx = 1; l_idx < value_list.n_values; l_idx++)
      {
        if (value_list.list_value[l_idx].size_of()!=item_size)
          TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_Hdr containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_Hdr containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_Hdr containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_Hdr containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_Hdr containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_Hdr containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_Hdr containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @AMR_Types.RTP_AMR_Hdr.");
  }
  return 0;
}

void RTP__AMR__Hdr_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ cmr := ");
single_value->field_cmr.log();
TTCN_Logger::log_event_str(", padding1 := ");
single_value->field_padding1.log();
TTCN_Logger::log_event_str(", f := ");
single_value->field_f.log();
TTCN_Logger::log_event_str(", ft := ");
single_value->field_ft.log();
TTCN_Logger::log_event_str(", q := ");
single_value->field_q.log();
TTCN_Logger::log_event_str(", padding2 := ");
single_value->field_padding2.log();
TTCN_Logger::log_event_str(" }");
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case CONJUNCTION_MATCH:
if (template_selection == CONJUNCTION_MATCH) {
TTCN_Logger::log_event_str("conjunct");
}
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) {
if (list_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[list_count].log();
}
TTCN_Logger::log_char(')');
break;
case IMPLICATION_MATCH:
implication_.precondition->log();
TTCN_Logger::log_event_str(" implies ");
implication_.implied_template->log();
break;
case DYNAMIC_MATCH:
TTCN_Logger::log_event_str("@dynamic template");
break;
default:
log_generic();
}
log_ifpresent();
}

void RTP__AMR__Hdr_template::log_match(const RTP__AMR__Hdr& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
if(match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
} else{
if (template_selection == SPECIFIC_VALUE) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
if(!single_value->field_cmr.match(match_value.cmr(), legacy)){
TTCN_Logger::log_logmatch_info(".cmr");
single_value->field_cmr.log_match(match_value.cmr(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_padding1.match(match_value.padding1(), legacy)){
TTCN_Logger::log_logmatch_info(".padding1");
single_value->field_padding1.log_match(match_value.padding1(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_f.match(match_value.f(), legacy)){
TTCN_Logger::log_logmatch_info(".f");
single_value->field_f.log_match(match_value.f(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_ft.match(match_value.ft(), legacy)){
TTCN_Logger::log_logmatch_info(".ft");
single_value->field_ft.log_match(match_value.ft(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_q.match(match_value.q(), legacy)){
TTCN_Logger::log_logmatch_info(".q");
single_value->field_q.log_match(match_value.q(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_padding2.match(match_value.padding2(), legacy)){
TTCN_Logger::log_logmatch_info(".padding2");
single_value->field_padding2.log_match(match_value.padding2(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
}else {
TTCN_Logger::print_logmatch_buffer();
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
TTCN_Logger::log_event_str(" unmatched");
}
}
return;
}
if (template_selection == SPECIFIC_VALUE) {
TTCN_Logger::log_event_str("{ cmr := ");
single_value->field_cmr.log_match(match_value.cmr(), legacy);
TTCN_Logger::log_event_str(", padding1 := ");
single_value->field_padding1.log_match(match_value.padding1(), legacy);
TTCN_Logger::log_event_str(", f := ");
single_value->field_f.log_match(match_value.f(), legacy);
TTCN_Logger::log_event_str(", ft := ");
single_value->field_ft.log_match(match_value.ft(), legacy);
TTCN_Logger::log_event_str(", q := ");
single_value->field_q.log_match(match_value.q(), legacy);
TTCN_Logger::log_event_str(", padding2 := ");
single_value->field_padding2.log_match(match_value.padding2(), legacy);
TTCN_Logger::log_event_str(" }");
} else {
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value, legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
}

void RTP__AMR__Hdr_template::set_implicit_omit()
{
if (template_selection != SPECIFIC_VALUE) return;
if (cmr().is_bound()) cmr().set_implicit_omit();
if (padding1().is_bound()) padding1().set_implicit_omit();
if (f().is_bound()) f().set_implicit_omit();
if (ft().is_bound()) ft().set_implicit_omit();
if (q().is_bound()) q().set_implicit_omit();
if (padding2().is_bound()) padding2().set_implicit_omit();
}

void RTP__AMR__Hdr_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_cmr.encode_text(text_buf);
single_value->field_padding1.encode_text(text_buf);
single_value->field_f.encode_text(text_buf);
single_value->field_ft.encode_text(text_buf);
single_value->field_q.encode_text(text_buf);
single_value->field_padding2.encode_text(text_buf);
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
text_buf.push_int(value_list.n_values);
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type @AMR_Types.RTP_AMR_Hdr.");
}
}

void RTP__AMR__Hdr_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
single_value->field_cmr.decode_text(text_buf);
single_value->field_padding1.decode_text(text_buf);
single_value->field_f.decode_text(text_buf);
single_value->field_ft.decode_text(text_buf);
single_value->field_q.decode_text(text_buf);
single_value->field_padding2.decode_text(text_buf);
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = text_buf.pull_int().get_val();
value_list.list_value = new RTP__AMR__Hdr_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type @AMR_Types.RTP_AMR_Hdr.");
}
}

void RTP__AMR__Hdr_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "record template");
  switch (param.get_type()) {
  case Module_Param::MP_Omit:
    *this = OMIT_VALUE;
    break;
  case Module_Param::MP_Any:
    *this = ANY_VALUE;
    break;
  case Module_Param::MP_AnyOrNone:
    *this = ANY_OR_OMIT;
    break;
  case Module_Param::MP_List_Template:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    RTP__AMR__Hdr_template new_temp;
    new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size());
    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (6<param.get_size()) {
      param.error("record template of type @AMR_Types.RTP_AMR_Hdr has 6 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) cmr().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) padding1().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) f().set_param(*param.get_elem(2));
    if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) ft().set_param(*param.get_elem(3));
    if (param.get_size()>4 && param.get_elem(4)->get_type()!=Module_Param::MP_NotUsed) q().set_param(*param.get_elem(4));
    if (param.get_size()>5 && param.get_elem(5)->get_type()!=Module_Param::MP_NotUsed) padding2().set_param(*param.get_elem(5));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "cmr")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          cmr().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "padding1")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          padding1().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "f")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          f().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "ft")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          ft().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "q")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          q().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "padding2")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          padding2().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @AMR_Types.RTP_AMR_Hdr: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    RTP__AMR__Hdr_template* precondition = new RTP__AMR__Hdr_template;
    precondition->set_param(*param.get_elem(0));
    RTP__AMR__Hdr_template* implied_template = new RTP__AMR__Hdr_template;
    implied_template->set_param(*param.get_elem(1));
    *this = RTP__AMR__Hdr_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@AMR_Types.RTP_AMR_Hdr");
  }
  is_ifpresent = param.get_ifpresent();
}

void RTP__AMR__Hdr_template::check_restriction(template_res t_res, const char* t_name, boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return;
switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
case TR_OMIT:
if (template_selection==OMIT_VALUE) return;
case TR_VALUE:
if (template_selection!=SPECIFIC_VALUE || is_ifpresent) break;
single_value->field_cmr.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_Hdr");
single_value->field_padding1.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_Hdr");
single_value->field_f.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_Hdr");
single_value->field_ft.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_Hdr");
single_value->field_q.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_Hdr");
single_value->field_padding2.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_Hdr");
return;
case TR_PRESENT:
if (!match_omit(legacy)) return;
break;
default:
return;
}
TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@AMR_Types.RTP_AMR_Hdr");
}

boolean RTP__AMR__Hdr_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean RTP__AMR__Hdr_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match_omit() || implication_.implied_template->match_omit();
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

RTP__AMR__BWE__Hdr::RTP__AMR__BWE__Hdr()
{
}

RTP__AMR__BWE__Hdr::RTP__AMR__BWE__Hdr(const INTEGER& par_cmr,
    const BITSTRING& par_f,
    const INTEGER& par_ft,
    const BITSTRING& par_q)
  :   field_cmr(par_cmr),
  field_f(par_f),
  field_ft(par_ft),
  field_q(par_q)
{
}

RTP__AMR__BWE__Hdr::RTP__AMR__BWE__Hdr(const RTP__AMR__BWE__Hdr& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @AMR_Types.RTP_AMR_BWE_Hdr.");
if (other_value.cmr().is_bound()) field_cmr = other_value.cmr();
else field_cmr.clean_up();
if (other_value.f().is_bound()) field_f = other_value.f();
else field_f.clean_up();
if (other_value.ft().is_bound()) field_ft = other_value.ft();
else field_ft.clean_up();
if (other_value.q().is_bound()) field_q = other_value.q();
else field_q.clean_up();
}

void RTP__AMR__BWE__Hdr::clean_up()
{
field_cmr.clean_up();
field_f.clean_up();
field_ft.clean_up();
field_q.clean_up();
}

const TTCN_Typedescriptor_t* RTP__AMR__BWE__Hdr::get_descriptor() const { return &RTP__AMR__BWE__Hdr_descr_; }
RTP__AMR__BWE__Hdr& RTP__AMR__BWE__Hdr::operator=(const RTP__AMR__BWE__Hdr& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @AMR_Types.RTP_AMR_BWE_Hdr.");
  if (other_value.cmr().is_bound()) field_cmr = other_value.cmr();
  else field_cmr.clean_up();
  if (other_value.f().is_bound()) field_f = other_value.f();
  else field_f.clean_up();
  if (other_value.ft().is_bound()) field_ft = other_value.ft();
  else field_ft.clean_up();
  if (other_value.q().is_bound()) field_q = other_value.q();
  else field_q.clean_up();
}
return *this;
}

boolean RTP__AMR__BWE__Hdr::operator==(const RTP__AMR__BWE__Hdr& other_value) const
{
return field_cmr==other_value.field_cmr
  && field_f==other_value.field_f
  && field_ft==other_value.field_ft
  && field_q==other_value.field_q;
}

boolean RTP__AMR__BWE__Hdr::is_bound() const
{
return (field_cmr.is_bound())
  || (field_f.is_bound())
  || (field_ft.is_bound())
  || (field_q.is_bound());
}
boolean RTP__AMR__BWE__Hdr::is_value() const
{
return field_cmr.is_value()
  && field_f.is_value()
  && field_ft.is_value()
  && field_q.is_value();
}
void RTP__AMR__BWE__Hdr::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ cmr := ");
field_cmr.log();
TTCN_Logger::log_event_str(", f := ");
field_f.log();
TTCN_Logger::log_event_str(", ft := ");
field_ft.log();
TTCN_Logger::log_event_str(", q := ");
field_q.log();
TTCN_Logger::log_event_str(" }");
}

void RTP__AMR__BWE__Hdr::set_implicit_omit()
{
if (cmr().is_bound()) cmr().set_implicit_omit();
if (f().is_bound()) f().set_implicit_omit();
if (ft().is_bound()) ft().set_implicit_omit();
if (q().is_bound()) q().set_implicit_omit();
}

void RTP__AMR__BWE__Hdr::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
  switch (param.get_type()) {
  case Module_Param::MP_Value_List:
    if (4<param.get_size()) {
      param.error("record value of type @AMR_Types.RTP_AMR_BWE_Hdr has 4 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) cmr().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) f().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) ft().set_param(*param.get_elem(2));
    if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) q().set_param(*param.get_elem(3));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "cmr")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          cmr().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "f")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          f().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "ft")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          ft().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "q")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          q().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @AMR_Types.RTP_AMR_BWE_Hdr: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@AMR_Types.RTP_AMR_BWE_Hdr");
  }
}

void RTP__AMR__BWE__Hdr::encode_text(Text_Buf& text_buf) const
{
field_cmr.encode_text(text_buf);
field_f.encode_text(text_buf);
field_ft.encode_text(text_buf);
field_q.encode_text(text_buf);
}

void RTP__AMR__BWE__Hdr::decode_text(Text_Buf& text_buf)
{
field_cmr.decode_text(text_buf);
field_f.decode_text(text_buf);
field_ft.decode_text(text_buf);
field_q.decode_text(text_buf);
}

void RTP__AMR__BWE__Hdr::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...) const
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
    unsigned BER_coding=va_arg(pvar, unsigned);
    BER_encode_chk_coding(BER_coding);
    ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
    tlv->put_in_buffer(p_buf);
    ASN_BER_TLV_t::destruct(tlv);
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    RAW_enc_tr_pos rp;
    rp.level=0;
    rp.pos=NULL;
    RAW_enc_tree root(FALSE, NULL, &rp, 1, p_td.raw);
    RAW_encode(p_td, root);
    root.put_to_buf(p_buf);
    break;}
  case TTCN_EncDec::CT_TEXT: {
    TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
      ("No TEXT descriptor available for type '%s'.", p_td.name);
    TEXT_encode(p_td,p_buf);
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
    p_buf.put_c('\n');
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok(va_arg(pvar, int) != 0);
    JSON_encode(p_td, tok, FALSE);
    p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
    OER_encode(p_td, p_buf);
    break;}
  case TTCN_EncDec::CT_PER: {
    TTCN_EncDec_ErrorContext ec("While PER-encoding type '%s': ", p_td.name);
    if (!p_td.per) TTCN_EncDec_ErrorContext::error_internal(
      "No PER descriptor available for type '%s'.", p_td.name);
    int opt = va_arg(pvar, int);
    PER_encode(p_td, p_buf, opt);
    break; }
  default:
    TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
  }
  va_end(pvar);
}

void RTP__AMR__BWE__Hdr::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int p_coding, ...)
{
  va_list pvar;
  va_start(pvar, p_coding);
  switch(p_coding) {
  case TTCN_EncDec::CT_BER: {
    TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
    unsigned L_form=va_arg(pvar, unsigned);
    ASN_BER_TLV_t tlv;
    BER_decode_str2TLV(p_buf, tlv, L_form);
    BER_decode_TLV(p_td, tlv, L_form);
    if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
    break;}
  case TTCN_EncDec::CT_RAW: {
    TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
    if(!p_td.raw)
      TTCN_EncDec_ErrorContext::error_internal
        ("No RAW descriptor available for type '%s'.", p_td.name);
    raw_order_t r_order;
    switch(p_td.raw->top_bit_order) {
    case TOP_BIT_LEFT:
      r_order=ORDER_LSB;
      break;
    case TOP_BIT_RIGHT:
    default:
      r_order=ORDER_MSB;
    }
    int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
    if(rawr<0) switch (-rawr) {
    case TTCN_EncDec::ET_INCOMPL_MSG:
    case TTCN_EncDec::ET_LEN_ERR:
      ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
      break;
    case 1:
    default:
      ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
      break;
    }
    break;}
  case TTCN_EncDec::CT_TEXT: {
    Limit_Token_List limit;
    TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
    if(!p_td.text)
      TTCN_EncDec_ErrorContext::error_internal
        ("No TEXT descriptor available for type '%s'.", p_td.name);
    const unsigned char *b_data=p_buf.get_data();
    int null_added=0;
    if(b_data[p_buf.get_len()-1]!='\0'){
      null_added=1;
      p_buf.set_pos(p_buf.get_len());
      p_buf.put_zero(8,ORDER_LSB);
      p_buf.rewind();
    }
    if(TEXT_decode(p_td,p_buf,limit)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    if(null_added){
      size_t actpos=p_buf.get_pos();
      p_buf.set_pos(p_buf.get_len()-1);
      p_buf.cut_end();
      p_buf.set_pos(actpos);
    }
    break;}
  case TTCN_EncDec::CT_XER: {
    TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
    unsigned XER_coding=va_arg(pvar, unsigned);
    XER_encode_chk_coding(XER_coding, p_td);
    XmlReaderWrap reader(p_buf);
    for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
      if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
    }
    XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
    size_t bytes = reader.ByteConsumed();
    p_buf.set_pos(bytes);
    break;}
  case TTCN_EncDec::CT_JSON: {
    TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
    if(!p_td.json)
      TTCN_EncDec_ErrorContext::error_internal
        ("No JSON descriptor available for type '%s'.", p_td.name);
    JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
    if(JSON_decode(p_td, tok, FALSE, FALSE)<0)
      ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
    p_buf.set_pos(tok.get_buf_pos());
    break;}
  case TTCN_EncDec::CT_OER: {
    TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
    if(!p_td.oer)
      TTCN_EncDec_ErrorContext::error_internal
        ("No OER descriptor available for type '%s'.", p_td.name);
     OER_struct p_oer;
    OER_decode(p_td, p_buf, p_oer);
    break;}
  case TTCN_EncDec::CT_PER: {
    TTCN_EncDec_ErrorContext ec("While PER-decoding type '%s': ", p_td.name);
    if(!p_td.per)  TTCN_EncDec_ErrorContext::error_internal(
      "No PER descriptor available for type '%s'.", p_td.name);
    int opt = va_arg(pvar, int);
    try {
      PER_decode(p_td, p_buf, opt);
      p_buf.PER_octet_align(FALSE);
    }
    catch (PER_Buffer_Exception) { }
    break; }
  default:
    TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
  }
  va_end(pvar);
}

int RTP__AMR__BWE__Hdr::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit* force_omit)
{ (void)no_err;
  int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);
  limit-=prepaddlength;
  size_t last_decoded_pos = p_buf.get_pos_bit();
  int decoded_length = 0;
  int decoded_field_length = 0;
  raw_order_t local_top_order;
  if(p_td.raw->top_bit_order==TOP_BIT_INHERITED)local_top_order=top_bit_ord;
  else if(p_td.raw->top_bit_order==TOP_BIT_RIGHT)local_top_order=ORDER_MSB;
  else local_top_order=ORDER_LSB;
  RAW_Force_Omit field_0_force_omit(0, force_omit, RTP__AMR__BWE__Hdr_cmr_descr_.raw->forceomit);
  decoded_field_length = field_cmr.RAW_decode(RTP__AMR__BWE__Hdr_cmr_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_0_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  RAW_Force_Omit field_1_force_omit(1, force_omit, RTP__AMR__BWE__Hdr_f_descr_.raw->forceomit);
  decoded_field_length = field_f.RAW_decode(RTP__AMR__BWE__Hdr_f_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_1_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  RAW_Force_Omit field_2_force_omit(2, force_omit, RTP__AMR__BWE__Hdr_ft_descr_.raw->forceomit);
  decoded_field_length = field_ft.RAW_decode(RTP__AMR__BWE__Hdr_ft_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_2_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  RAW_Force_Omit field_3_force_omit(3, force_omit, RTP__AMR__BWE__Hdr_q_descr_.raw->forceomit);
  decoded_field_length = field_q.RAW_decode(RTP__AMR__BWE__Hdr_q_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_3_force_omit);
  if (decoded_field_length < 0) return decoded_field_length;
  decoded_length+=decoded_field_length;
  limit-=decoded_field_length;
  last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
  p_buf.set_pos_bit(last_decoded_pos);
  return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding);
}

int RTP__AMR__BWE__Hdr::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const {
  if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
  int encoded_length = 0;
  myleaf.isleaf = FALSE;
  myleaf.body.node.num_of_nodes = 4;
  myleaf.body.node.nodes = init_nodes_of_enc_tree(4);
  myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, RTP__AMR__BWE__Hdr_cmr_descr_.raw);
  myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, RTP__AMR__BWE__Hdr_f_descr_.raw);
  myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 2, RTP__AMR__BWE__Hdr_ft_descr_.raw);
  myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 3, RTP__AMR__BWE__Hdr_q_descr_.raw);
  encoded_length += field_cmr.RAW_encode(RTP__AMR__BWE__Hdr_cmr_descr_, *myleaf.body.node.nodes[0]);
  encoded_length += field_f.RAW_encode(RTP__AMR__BWE__Hdr_f_descr_, *myleaf.body.node.nodes[1]);
  encoded_length += field_ft.RAW_encode(RTP__AMR__BWE__Hdr_ft_descr_, *myleaf.body.node.nodes[2]);
  encoded_length += field_q.RAW_encode(RTP__AMR__BWE__Hdr_q_descr_, *myleaf.body.node.nodes[3]);
  return myleaf.length = encoded_length;
}

struct RTP__AMR__BWE__Hdr_template::single_value_struct {
INTEGER_template field_cmr;
BITSTRING_template field_f;
INTEGER_template field_ft;
BITSTRING_template field_q;
};

void RTP__AMR__BWE__Hdr_template::set_specific()
{
if (template_selection != SPECIFIC_VALUE) {
template_sel old_selection = template_selection;
clean_up();
single_value = new single_value_struct;
set_selection(SPECIFIC_VALUE);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
single_value->field_cmr = ANY_VALUE;
single_value->field_f = ANY_VALUE;
single_value->field_ft = ANY_VALUE;
single_value->field_q = ANY_VALUE;
}
}
}

void RTP__AMR__BWE__Hdr_template::copy_value(const RTP__AMR__BWE__Hdr& other_value)
{
single_value = new single_value_struct;
if (other_value.cmr().is_bound()) {
  single_value->field_cmr = other_value.cmr();
} else {
  single_value->field_cmr.clean_up();
}
if (other_value.f().is_bound()) {
  single_value->field_f = other_value.f();
} else {
  single_value->field_f.clean_up();
}
if (other_value.ft().is_bound()) {
  single_value->field_ft = other_value.ft();
} else {
  single_value->field_ft.clean_up();
}
if (other_value.q().is_bound()) {
  single_value->field_q = other_value.q();
} else {
  single_value->field_q.clean_up();
}
set_selection(SPECIFIC_VALUE);
}

void RTP__AMR__BWE__Hdr_template::copy_template(const RTP__AMR__BWE__Hdr_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.cmr().get_selection()) {
single_value->field_cmr = other_value.cmr();
} else {
single_value->field_cmr.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.f().get_selection()) {
single_value->field_f = other_value.f();
} else {
single_value->field_f.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.ft().get_selection()) {
single_value->field_ft = other_value.ft();
} else {
single_value->field_ft.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.q().get_selection()) {
single_value->field_q = other_value.q();
} else {
single_value->field_q.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new RTP__AMR__BWE__Hdr_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
break;
case IMPLICATION_MATCH:
implication_.precondition = new RTP__AMR__BWE__Hdr_template(*other_value.implication_.precondition);
implication_.implied_template = new RTP__AMR__BWE__Hdr_template(*other_value.implication_.implied_template);
break;
case DYNAMIC_MATCH:
dyn_match = other_value.dyn_match;
dyn_match->ref_count++;
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
break;
}
set_selection(other_value);
}

RTP__AMR__BWE__Hdr_template::RTP__AMR__BWE__Hdr_template()
{
}

RTP__AMR__BWE__Hdr_template::RTP__AMR__BWE__Hdr_template(template_sel other_value)
 : Base_Template(other_value)
{
check_single_selection(other_value);
}

RTP__AMR__BWE__Hdr_template::RTP__AMR__BWE__Hdr_template(const RTP__AMR__BWE__Hdr& other_value)
{
copy_value(other_value);
}

RTP__AMR__BWE__Hdr_template::RTP__AMR__BWE__Hdr_template(const OPTIONAL<RTP__AMR__BWE__Hdr>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const RTP__AMR__BWE__Hdr&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @AMR_Types.RTP_AMR_BWE_Hdr from an unbound optional field.");
}
}

RTP__AMR__BWE__Hdr_template::RTP__AMR__BWE__Hdr_template(RTP__AMR__BWE__Hdr_template* p_precondition, RTP__AMR__BWE__Hdr_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

RTP__AMR__BWE__Hdr_template::RTP__AMR__BWE__Hdr_template(Dynamic_Match_Interface<RTP__AMR__BWE__Hdr>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<RTP__AMR__BWE__Hdr>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

RTP__AMR__BWE__Hdr_template::RTP__AMR__BWE__Hdr_template(const RTP__AMR__BWE__Hdr_template& other_value)
: Base_Template()
{
copy_template(other_value);
}

RTP__AMR__BWE__Hdr_template::~RTP__AMR__BWE__Hdr_template()
{
clean_up();
}

RTP__AMR__BWE__Hdr_template& RTP__AMR__BWE__Hdr_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

RTP__AMR__BWE__Hdr_template& RTP__AMR__BWE__Hdr_template::operator=(const RTP__AMR__BWE__Hdr& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}

RTP__AMR__BWE__Hdr_template& RTP__AMR__BWE__Hdr_template::operator=(const OPTIONAL<RTP__AMR__BWE__Hdr>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const RTP__AMR__BWE__Hdr&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
}
return *this;
}

RTP__AMR__BWE__Hdr_template& RTP__AMR__BWE__Hdr_template::operator=(const RTP__AMR__BWE__Hdr_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

boolean RTP__AMR__BWE__Hdr_template::match(const RTP__AMR__BWE__Hdr& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case OMIT_VALUE:
return FALSE;
case SPECIFIC_VALUE:
if(!other_value.cmr().is_bound()) return FALSE;
if(!single_value->field_cmr.match(other_value.cmr(), legacy))return FALSE;
if(!other_value.f().is_bound()) return FALSE;
if(!single_value->field_f.match(other_value.f(), legacy))return FALSE;
if(!other_value.ft().is_bound()) return FALSE;
if(!single_value->field_ft.match(other_value.ft(), legacy))return FALSE;
if(!other_value.q().is_bound()) return FALSE;
if(!single_value->field_q.match(other_value.q(), legacy))return FALSE;
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
if (value_list.list_value[list_count].match(other_value, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
case CONJUNCTION_MATCH:
for (unsigned int i = 0; i < value_list.n_values; i++) {
if (!value_list.list_value[i].match(other_value)) {
return FALSE;
}
}
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value);
case DYNAMIC_MATCH:
return dyn_match->ptr->match(other_value);
default:
TTCN_error("Matching an uninitialized/unsupported template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
}
return FALSE;
}

boolean RTP__AMR__BWE__Hdr_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_cmr.is_bound()
 || single_value->field_f.is_bound()
 || single_value->field_ft.is_bound()
 || single_value->field_q.is_bound();
}

boolean RTP__AMR__BWE__Hdr_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_cmr.is_value()
 && single_value->field_f.is_value()
 && single_value->field_ft.is_value()
 && single_value->field_q.is_value();
}

void RTP__AMR__BWE__Hdr_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
case CONJUNCTION_MATCH:
delete [] value_list.list_value;
break;
case IMPLICATION_MATCH:
delete implication_.precondition;
delete implication_.implied_template;
break;
case DYNAMIC_MATCH:
dyn_match->ref_count--;
if (dyn_match->ref_count == 0) {
delete dyn_match->ptr;
delete dyn_match;
}
break;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}

RTP__AMR__BWE__Hdr RTP__AMR__BWE__Hdr_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
RTP__AMR__BWE__Hdr ret_val;
if (single_value->field_cmr.is_bound()) {
ret_val.cmr() = single_value->field_cmr.valueof();
}
if (single_value->field_f.is_bound()) {
ret_val.f() = single_value->field_f.valueof();
}
if (single_value->field_ft.is_bound()) {
ret_val.ft() = single_value->field_ft.valueof();
}
if (single_value->field_q.is_bound()) {
ret_val.q() = single_value->field_q.valueof();
}
return ret_val;
}

void RTP__AMR__BWE__Hdr_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST&& template_type != CONJUNCTION_MATCH)
TTCN_error("Setting an invalid list for a template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new RTP__AMR__BWE__Hdr_template[list_length];
}

RTP__AMR__BWE__Hdr_template& RTP__AMR__BWE__Hdr_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST&& template_selection != CONJUNCTION_MATCH)
TTCN_error("Accessing a list element of a non-list template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
return value_list.list_value[list_index];
}

INTEGER_template& RTP__AMR__BWE__Hdr_template::cmr()
{
set_specific();
return single_value->field_cmr;
}

const INTEGER_template& RTP__AMR__BWE__Hdr_template::cmr() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field cmr of a non-specific template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
return single_value->field_cmr;
}

BITSTRING_template& RTP__AMR__BWE__Hdr_template::f()
{
set_specific();
return single_value->field_f;
}

const BITSTRING_template& RTP__AMR__BWE__Hdr_template::f() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field f of a non-specific template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
return single_value->field_f;
}

INTEGER_template& RTP__AMR__BWE__Hdr_template::ft()
{
set_specific();
return single_value->field_ft;
}

const INTEGER_template& RTP__AMR__BWE__Hdr_template::ft() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field ft of a non-specific template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
return single_value->field_ft;
}

BITSTRING_template& RTP__AMR__BWE__Hdr_template::q()
{
set_specific();
return single_value->field_q;
}

const BITSTRING_template& RTP__AMR__BWE__Hdr_template::q() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field q of a non-specific template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
return single_value->field_q;
}

int RTP__AMR__BWE__Hdr_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_BWE_Hdr which has an ifpresent attribute.");
  switch (template_selection)
  {
  case SPECIFIC_VALUE:
    return 4;
  case VALUE_LIST:
   {
     if (value_list.n_values<1)
       TTCN_error("Internal error: Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_BWE_Hdr containing an empty list.");
      int item_size = value_list.list_value[0].size_of();
      for (unsigned int l_idx = 1; l_idx < value_list.n_values; l_idx++)
      {
        if (value_list.list_value[l_idx].size_of()!=item_size)
          TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_BWE_Hdr containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_BWE_Hdr containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_BWE_Hdr containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_BWE_Hdr containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_BWE_Hdr containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_BWE_Hdr containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @AMR_Types.RTP_AMR_BWE_Hdr containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
  }
  return 0;
}

void RTP__AMR__BWE__Hdr_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ cmr := ");
single_value->field_cmr.log();
TTCN_Logger::log_event_str(", f := ");
single_value->field_f.log();
TTCN_Logger::log_event_str(", ft := ");
single_value->field_ft.log();
TTCN_Logger::log_event_str(", q := ");
single_value->field_q.log();
TTCN_Logger::log_event_str(" }");
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case CONJUNCTION_MATCH:
if (template_selection == CONJUNCTION_MATCH) {
TTCN_Logger::log_event_str("conjunct");
}
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) {
if (list_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[list_count].log();
}
TTCN_Logger::log_char(')');
break;
case IMPLICATION_MATCH:
implication_.precondition->log();
TTCN_Logger::log_event_str(" implies ");
implication_.implied_template->log();
break;
case DYNAMIC_MATCH:
TTCN_Logger::log_event_str("@dynamic template");
break;
default:
log_generic();
}
log_ifpresent();
}

void RTP__AMR__BWE__Hdr_template::log_match(const RTP__AMR__BWE__Hdr& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
if(match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
} else{
if (template_selection == SPECIFIC_VALUE) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
if(!single_value->field_cmr.match(match_value.cmr(), legacy)){
TTCN_Logger::log_logmatch_info(".cmr");
single_value->field_cmr.log_match(match_value.cmr(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_f.match(match_value.f(), legacy)){
TTCN_Logger::log_logmatch_info(".f");
single_value->field_f.log_match(match_value.f(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_ft.match(match_value.ft(), legacy)){
TTCN_Logger::log_logmatch_info(".ft");
single_value->field_ft.log_match(match_value.ft(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_q.match(match_value.q(), legacy)){
TTCN_Logger::log_logmatch_info(".q");
single_value->field_q.log_match(match_value.q(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
}else {
TTCN_Logger::print_logmatch_buffer();
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
TTCN_Logger::log_event_str(" unmatched");
}
}
return;
}
if (template_selection == SPECIFIC_VALUE) {
TTCN_Logger::log_event_str("{ cmr := ");
single_value->field_cmr.log_match(match_value.cmr(), legacy);
TTCN_Logger::log_event_str(", f := ");
single_value->field_f.log_match(match_value.f(), legacy);
TTCN_Logger::log_event_str(", ft := ");
single_value->field_ft.log_match(match_value.ft(), legacy);
TTCN_Logger::log_event_str(", q := ");
single_value->field_q.log_match(match_value.q(), legacy);
TTCN_Logger::log_event_str(" }");
} else {
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value, legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
}

void RTP__AMR__BWE__Hdr_template::set_implicit_omit()
{
if (template_selection != SPECIFIC_VALUE) return;
if (cmr().is_bound()) cmr().set_implicit_omit();
if (f().is_bound()) f().set_implicit_omit();
if (ft().is_bound()) ft().set_implicit_omit();
if (q().is_bound()) q().set_implicit_omit();
}

void RTP__AMR__BWE__Hdr_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_cmr.encode_text(text_buf);
single_value->field_f.encode_text(text_buf);
single_value->field_ft.encode_text(text_buf);
single_value->field_q.encode_text(text_buf);
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
text_buf.push_int(value_list.n_values);
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
}
}

void RTP__AMR__BWE__Hdr_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
single_value->field_cmr.decode_text(text_buf);
single_value->field_f.decode_text(text_buf);
single_value->field_ft.decode_text(text_buf);
single_value->field_q.decode_text(text_buf);
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = text_buf.pull_int().get_val();
value_list.list_value = new RTP__AMR__BWE__Hdr_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type @AMR_Types.RTP_AMR_BWE_Hdr.");
}
}

void RTP__AMR__BWE__Hdr_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "record template");
  switch (param.get_type()) {
  case Module_Param::MP_Omit:
    *this = OMIT_VALUE;
    break;
  case Module_Param::MP_Any:
    *this = ANY_VALUE;
    break;
  case Module_Param::MP_AnyOrNone:
    *this = ANY_OR_OMIT;
    break;
  case Module_Param::MP_List_Template:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    RTP__AMR__BWE__Hdr_template new_temp;
    new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size());
    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (4<param.get_size()) {
      param.error("record template of type @AMR_Types.RTP_AMR_BWE_Hdr has 4 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) cmr().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) f().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) ft().set_param(*param.get_elem(2));
    if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) q().set_param(*param.get_elem(3));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "cmr")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          cmr().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "f")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          f().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "ft")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          ft().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "q")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          q().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @AMR_Types.RTP_AMR_BWE_Hdr: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    RTP__AMR__BWE__Hdr_template* precondition = new RTP__AMR__BWE__Hdr_template;
    precondition->set_param(*param.get_elem(0));
    RTP__AMR__BWE__Hdr_template* implied_template = new RTP__AMR__BWE__Hdr_template;
    implied_template->set_param(*param.get_elem(1));
    *this = RTP__AMR__BWE__Hdr_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@AMR_Types.RTP_AMR_BWE_Hdr");
  }
  is_ifpresent = param.get_ifpresent();
}

void RTP__AMR__BWE__Hdr_template::check_restriction(template_res t_res, const char* t_name, boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return;
switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
case TR_OMIT:
if (template_selection==OMIT_VALUE) return;
case TR_VALUE:
if (template_selection!=SPECIFIC_VALUE || is_ifpresent) break;
single_value->field_cmr.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_BWE_Hdr");
single_value->field_f.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_BWE_Hdr");
single_value->field_ft.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_BWE_Hdr");
single_value->field_q.check_restriction(t_res, t_name ? t_name : "@AMR_Types.RTP_AMR_BWE_Hdr");
return;
case TR_PRESENT:
if (!match_omit(legacy)) return;
break;
default:
return;
}
TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@AMR_Types.RTP_AMR_BWE_Hdr");
}

boolean RTP__AMR__BWE__Hdr_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean RTP__AMR__BWE__Hdr_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case IMPLICATION_MATCH:
return !implication_.precondition->match_omit() || implication_.implied_template->match_omit();
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}


/* Bodies of functions, altsteps and testcases */

void AMRFT_encoder(const AMRFT& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@AMR_Types.AMRFT' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(AMRFT_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER AMRFT_decoder(OCTETSTRING& input_stream, AMRFT& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@AMR_Types.AMRFT' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(AMRFT_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

INTEGER f__amrft__payload__len(const INTEGER& amr__ft)
{
TTCN_Location current_location("AMR_Types.ttcn", 35, TTCN_Location::LOCATION_FUNCTION, "f_amrft_payload_len");
current_location.update_lineno(36);
/* AMR_Types.ttcn, line 36 */
return c__AMRFT__len[amr__ft];
}

INTEGER f__amrft__payload__bits__len(const INTEGER& amr__ft)
{
TTCN_Location current_location("AMR_Types.ttcn", 41, TTCN_Location::LOCATION_FUNCTION, "f_amrft_payload_bits_len");
current_location.update_lineno(42);
/* AMR_Types.ttcn, line 42 */
return c__AMRFT__bits__len[amr__ft];
}

void RTP__AMR__Hdr_cmr_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__Hdr_cmr_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__Hdr_cmr_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__Hdr_cmr_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__Hdr_padding1_encoder(const BITSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__Hdr_padding1_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__Hdr_padding1_decoder(OCTETSTRING& input_stream, BITSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__Hdr_padding1_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__Hdr_f_encoder(const BITSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__Hdr_f_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__Hdr_f_decoder(OCTETSTRING& input_stream, BITSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__Hdr_f_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__Hdr_ft_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__Hdr_ft_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__Hdr_ft_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__Hdr_ft_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__Hdr_q_encoder(const BITSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__Hdr_q_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__Hdr_q_decoder(OCTETSTRING& input_stream, BITSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__Hdr_q_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__Hdr_padding2_encoder(const BITSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__Hdr_padding2_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__Hdr_padding2_decoder(OCTETSTRING& input_stream, BITSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__Hdr_padding2_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__Hdr_encoder(const RTP__AMR__Hdr& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@AMR_Types.RTP_AMR_Hdr' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__Hdr_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__Hdr_decoder(OCTETSTRING& input_stream, RTP__AMR__Hdr& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@AMR_Types.RTP_AMR_Hdr' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__Hdr_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

RTP__AMR__Hdr_template ts__RTP__AMR__Hdr(const INTEGER_template& cmr, const INTEGER_template& ft, const BITSTRING_template& q, const BITSTRING_template& f)
{
TTCN_Location current_location("AMR_Types.ttcn", 54, TTCN_Location::LOCATION_TEMPLATE, "ts_RTP_AMR_Hdr");
RTP__AMR__Hdr_template ret_val;
ret_val.cmr() = cmr;
ret_val.padding1() = bs_0;
ret_val.f() = f;
ret_val.ft() = ft;
ret_val.q() = q;
ret_val.padding2() = bs_1;
return ret_val;
}

OCTETSTRING enc__RTP__AMR__Hdr(const RTP__AMR__Hdr& amr__hdr)
{
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("enc_RTP_AMR_Hdr(): Encoding @AMR_Types.RTP_AMR_Hdr: ");
amr__hdr.log();
TTCN_Logger::end_event();
}
TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
TTCN_Buffer ttcn_buffer;
amr__hdr.encode(RTP__AMR__Hdr_descr_, ttcn_buffer, TTCN_EncDec::CT_RAW, 0);
OCTETSTRING ret_val;
ttcn_buffer.get_string(ret_val);
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("enc_RTP_AMR_Hdr(): Stream after encoding: ");
ret_val.log();
TTCN_Logger::end_event();
}
return ret_val;
}

RTP__AMR__Hdr dec__RTP__AMR__Hdr(const OCTETSTRING& stream)
{
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("dec_RTP_AMR_Hdr(): Stream before decoding: ");
stream.log();
TTCN_Logger::end_event();
}
TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
TTCN_EncDec::clear_error();
TTCN_Buffer ttcn_buffer(stream);
RTP__AMR__Hdr ret_val;
ret_val.decode(RTP__AMR__Hdr_descr_, ttcn_buffer, TTCN_EncDec::CT_RAW);
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("dec_RTP_AMR_Hdr(): Decoded @AMR_Types.RTP_AMR_Hdr: ");
ret_val.log();
TTCN_Logger::end_event();
}
if (TTCN_EncDec::get_last_error_type() == TTCN_EncDec::ET_NONE) {
if (ttcn_buffer.get_pos() < ttcn_buffer.get_len()) {
ttcn_buffer.cut();
OCTETSTRING tmp_os;
ttcn_buffer.get_string(tmp_os);
TTCN_Logger::begin_event_log2str();
tmp_os.log();
CHARSTRING remaining_stream = TTCN_Logger::end_event_log2str();
TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_EXTRA_DATA, "dec_RTP_AMR_Hdr(): Data remained at the end of the stream after successful decoding: %s", (const char*) remaining_stream);
}
}
return ret_val;
}

void RTP__AMR__BWE__Hdr_cmr_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__BWE__Hdr_cmr_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__BWE__Hdr_cmr_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__BWE__Hdr_cmr_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__BWE__Hdr_f_encoder(const BITSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__BWE__Hdr_f_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__BWE__Hdr_f_decoder(OCTETSTRING& input_stream, BITSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__BWE__Hdr_f_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__BWE__Hdr_ft_encoder(const INTEGER& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__BWE__Hdr_ft_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__BWE__Hdr_ft_decoder(OCTETSTRING& input_stream, INTEGER& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `integer' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__BWE__Hdr_ft_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__BWE__Hdr_q_encoder(const BITSTRING& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__BWE__Hdr_q_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__BWE__Hdr_q_decoder(OCTETSTRING& input_stream, BITSTRING& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `bitstring' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__BWE__Hdr_q_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

void RTP__AMR__BWE__Hdr_encoder(const RTP__AMR__BWE__Hdr& input_value, OCTETSTRING& output_stream, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, TRUE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@AMR_Types.RTP_AMR_BWE_Hdr' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf;
input_value.encode(RTP__AMR__BWE__Hdr_descr_, ttcn_buf, coding_type, extra_options);
ttcn_buf.get_string(output_stream);
}

INTEGER RTP__AMR__BWE__Hdr_decoder(OCTETSTRING& input_stream, RTP__AMR__BWE__Hdr& output_value, const UNIVERSAL_CHARSTRING& coding_name)
{
TTCN_EncDec::coding_t coding_type;
unsigned int extra_options = 0;
TTCN_EncDec::get_coding_from_str(coding_name, &coding_type, &extra_options, FALSE);
if (coding_type != TTCN_EncDec::CT_RAW) {
TTCN_Logger::begin_event_log2str();
coding_name.log();
TTCN_error("Type `@AMR_Types.RTP_AMR_BWE_Hdr' does not support %s encoding", (const char*) TTCN_Logger::end_event_log2str());
}
TTCN_Buffer ttcn_buf(input_stream);
output_value.decode(RTP__AMR__BWE__Hdr_descr_, ttcn_buf, coding_type, extra_options);
switch (TTCN_EncDec::get_last_error_type()) {
case TTCN_EncDec::ET_NONE:
ttcn_buf.cut();
ttcn_buf.get_string(input_stream);
return 0;
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
return 2;
default:
return 1;
}
}

RTP__AMR__BWE__Hdr_template ts__RTP__AMR__BWE__Hdr(const INTEGER_template& cmr, const INTEGER_template& ft, const BITSTRING_template& q, const BITSTRING_template& f)
{
TTCN_Location current_location("AMR_Types.ttcn", 77, TTCN_Location::LOCATION_TEMPLATE, "ts_RTP_AMR_BWE_Hdr");
RTP__AMR__BWE__Hdr_template ret_val;
ret_val.cmr() = cmr;
ret_val.f() = f;
ret_val.ft() = ft;
ret_val.q() = q;
return ret_val;
}

OCTETSTRING enc__RTP__AMR__BWE__Hdr(const RTP__AMR__BWE__Hdr& amr__hdr)
{
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("enc_RTP_AMR_BWE_Hdr(): Encoding @AMR_Types.RTP_AMR_BWE_Hdr: ");
amr__hdr.log();
TTCN_Logger::end_event();
}
TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
TTCN_Buffer ttcn_buffer;
amr__hdr.encode(RTP__AMR__BWE__Hdr_descr_, ttcn_buffer, TTCN_EncDec::CT_RAW, 0);
OCTETSTRING ret_val;
ttcn_buffer.get_string(ret_val);
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("enc_RTP_AMR_BWE_Hdr(): Stream after encoding: ");
ret_val.log();
TTCN_Logger::end_event();
}
return ret_val;
}

RTP__AMR__BWE__Hdr dec__RTP__AMR__BWE__Hdr(const OCTETSTRING& stream)
{
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("dec_RTP_AMR_BWE_Hdr(): Stream before decoding: ");
stream.log();
TTCN_Logger::end_event();
}
TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
TTCN_EncDec::clear_error();
TTCN_Buffer ttcn_buffer(stream);
RTP__AMR__BWE__Hdr ret_val;
ret_val.decode(RTP__AMR__BWE__Hdr_descr_, ttcn_buffer, TTCN_EncDec::CT_RAW);
if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {
TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
TTCN_Logger::log_event_str("dec_RTP_AMR_BWE_Hdr(): Decoded @AMR_Types.RTP_AMR_BWE_Hdr: ");
ret_val.log();
TTCN_Logger::end_event();
}
if (TTCN_EncDec::get_last_error_type() == TTCN_EncDec::ET_NONE) {
if (ttcn_buffer.get_pos() < ttcn_buffer.get_len()) {
ttcn_buffer.cut();
OCTETSTRING tmp_os;
ttcn_buffer.get_string(tmp_os);
TTCN_Logger::begin_event_log2str();
tmp_os.log();
CHARSTRING remaining_stream = TTCN_Logger::end_event_log2str();
TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_EXTRA_DATA, "dec_RTP_AMR_BWE_Hdr(): Data remained at the end of the stream after successful decoding: %s", (const char*) remaining_stream);
}
}
return ret_val;
}


/* Bodies of static functions */

void pre_init_module()
{
TTCN_Location current_location("AMR_Types.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "AMR_Types");
Osmocom__Types::module_object.pre_init_module();
current_location.update_lineno(33);
/* AMR_Types.ttcn, line 33 */
const_c__AMRFT__len[0] = 12;
const_c__AMRFT__len[1] = 13;
const_c__AMRFT__len[2] = 15;
const_c__AMRFT__len[3] = 17;
const_c__AMRFT__len[4] = 19;
const_c__AMRFT__len[5] = 20;
const_c__AMRFT__len[6] = 26;
const_c__AMRFT__len[7] = 31;
const_c__AMRFT__len[8] = 5;
module_object.add_function("f_amrft_payload_len", (genericfunc_t)&f__amrft__payload__len, NULL);
current_location.update_lineno(39);
/* AMR_Types.ttcn, line 39 */
const_c__AMRFT__bits__len[0] = 95;
const_c__AMRFT__bits__len[1] = 103;
const_c__AMRFT__bits__len[2] = 118;
const_c__AMRFT__bits__len[3] = 134;
const_c__AMRFT__bits__len[4] = 148;
const_c__AMRFT__bits__len[5] = 159;
const_c__AMRFT__bits__len[6] = 204;
const_c__AMRFT__bits__len[7] = 244;
const_c__AMRFT__bits__len[8] = 39;
module_object.add_function("f_amrft_payload_bits_len", (genericfunc_t)&f__amrft__payload__bits__len, NULL);
module_object.add_function("enc_RTP_AMR_Hdr", (genericfunc_t)&enc__RTP__AMR__Hdr, NULL);
module_object.add_function("dec_RTP_AMR_Hdr", (genericfunc_t)&dec__RTP__AMR__Hdr, NULL);
module_object.add_function("enc_RTP_AMR_BWE_Hdr", (genericfunc_t)&enc__RTP__AMR__BWE__Hdr, NULL);
module_object.add_function("dec_RTP_AMR_BWE_Hdr", (genericfunc_t)&dec__RTP__AMR__BWE__Hdr, NULL);
}

void post_init_module()
{
TTCN_Location current_location("AMR_Types.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "AMR_Types");
Osmocom__Types::module_object.post_init_module();
current_location.update_lineno(56);
/* AMR_Types.ttcn, line 56 */
template_ts__RTP__AMR__Hdr_q_defval = bs_2;
current_location.update_lineno(57);
/* AMR_Types.ttcn, line 57 */
template_ts__RTP__AMR__Hdr_f_defval = bs_3;
current_location.update_lineno(79);
/* AMR_Types.ttcn, line 79 */
template_ts__RTP__AMR__BWE__Hdr_q_defval = bs_2;
current_location.update_lineno(80);
/* AMR_Types.ttcn, line 80 */
template_ts__RTP__AMR__BWE__Hdr_f_defval = bs_3;
}


} /* end of namespace */
