<commit_before>// 
// Copyright (C) 2007 SIPez LLC.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// Copyright (C) 2007 Plantronics
// Licensed to SIPfoundry under a Contributor Agreement.
// 
// Copyright (C) 2007 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// $$
///////////////////////////////////////////////////////////////////////////////
// Author: <NAME> (sgodin AT SipSpectrum DOT com)

// SYSTEM INCLUDES

// APPLICATION INCLUDES
#include <sdp/Sdp.h>
#include <sdp/SdpMediaLine.h>
#include <utl/UtlHashMapIterator.h>

// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STATIC VARIABLE INITIALIZATIONS
const char* Sdp::SdpNetTypeString[] = 
{
   "NONE",
   "IN"
};

const char* Sdp::SdpAddressTypeString[] =
{
   "NONE",
   "IP4",
   "IP6"
};

const char* Sdp::SdpBandwidthTypeString[] =
{
   "NONE",
   "CT",
   "AS",
   "TIAS",
   "RS",
   "RR"
};

const char* Sdp::SdpConferenceTypeString[] = 
{
   "NONE",
   "BROADCAST",
   "MODERATED",
   "TEST",
   "H332"
};

const char* Sdp::SdpGroupSemanticsString[] =
{
   "NONE",
   "LS",
   "FID",
   "SRF",
   "ANAT"
};


/* //////////////////////////// PUBLIC //////////////////////////////////// */

/* ============================ CREATORS ================================== */

// Constructor
Sdp::Sdp()
{
   mSdpVersion = 1;
   mOriginatorSessionId = 0;
   mOriginatorSessionVersion = 0;
   mOriginatorNetType = NET_TYPE_NONE;
   mOriginatorAddressType = ADDRESS_TYPE_NONE;
   mConferenceType = CONFERENCE_TYPE_NONE;
   mIcePassiveOnlyMode = false;
   mMaximumPacketRate = 0;
}

// Copy constructor
Sdp::Sdp(const Sdp& rhs)
{
   operator=(rhs); 
}

// Destructor
Sdp::~Sdp()
{
   mFoundationIds.destroyAll();
}

// Assignment operator
Sdp& Sdp::operator=(const Sdp& rhs)
{
   if (this == &rhs)            // handle the assignment to self case
      return *this;

   // Assign values
   mSdpVersion = rhs.mSdpVersion;
   mOriginatorUserName = rhs.mOriginatorUserName;
   mOriginatorSessionId = rhs.mOriginatorSessionId;
   mOriginatorSessionVersion = rhs.mOriginatorSessionVersion;
   mOriginatorNetType = rhs.mOriginatorNetType;
   mOriginatorAddressType = rhs.mOriginatorAddressType;
   mOriginatorUnicastAddress = rhs.mOriginatorUnicastAddress;
   mSessionName = rhs.mSessionName;
   mSessionInformation = rhs.mSessionInformation;
   mSessionUri = rhs.mSessionUri;
   mEmailAddresses = rhs.mEmailAddresses;
   mPhoneNumbers = rhs.mPhoneNumbers;
   mBandwidths = rhs.mBandwidths;
   mTimes = rhs.mTimes;
   mTimeZones = rhs.mTimeZones;
   mCategory = rhs.mCategory;
   mKeywords = rhs.mKeywords;
   mToolNameAndVersion = rhs.mToolNameAndVersion;
   mConferenceType = rhs.mConferenceType;
   mCharSet = rhs.mCharSet;
   mIcePassiveOnlyMode = rhs.mIcePassiveOnlyMode;
   mGroups = rhs.mGroups;
   mSessionLanguage = rhs.mSessionLanguage;
   mDescriptionLanguage = rhs.mDescriptionLanguage;
   mMaximumPacketRate = rhs.mMaximumPacketRate;
   mMediaLines = rhs.mMediaLines;

   // Copy FoundationIds over
   mFoundationIds.destroyAll();
   UtlHashMapIterator it(rhs.mFoundationIds);
   SdpFoundation* item;
   UtlString* value;
   while((item = static_cast<SdpFoundation*>(it())) && (value = dynamic_cast<UtlString*>(it.value())))
   {
      mFoundationIds.insertKeyAndValue(item->clone(), value->clone() );
   }

   return *this;
}

Sdp::SdpAddressType Sdp::getAddressTypeFromString(const char * type)
{
   UtlString stringType(type);

   if(stringType.compareTo("IP4", UtlString::ignoreCase) == 0)
   {
      return ADDRESS_TYPE_IP4;
   }
   else if(stringType.compareTo("IP6", UtlString::ignoreCase) == 0)
   {
      return ADDRESS_TYPE_IP6;
   }
   else
   {
      return ADDRESS_TYPE_NONE;
   }
}

Sdp::SdpBandwidthType Sdp::SdpBandwidth::getTypeFromString(const char * type)
{
   UtlString stringType(type);

   if(stringType.compareTo("CT", UtlString::ignoreCase) == 0)<commit_msg>Missed a dynamic cast in sdpLib<commit_after>// 
// Copyright (C) 2007 SIPez LLC.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// Copyright (C) 2007 Plantronics
// Licensed to SIPfoundry under a Contributor Agreement.
// 
// Copyright (C) 2007 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// $$
///////////////////////////////////////////////////////////////////////////////
// Author: <NAME> (sgodin AT SipSpectrum DOT com)

// SYSTEM INCLUDES

// APPLICATION INCLUDES
#include <sdp/Sdp.h>
#include <sdp/SdpMediaLine.h>
#include <utl/UtlHashMapIterator.h>

// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STATIC VARIABLE INITIALIZATIONS
const char* Sdp::SdpNetTypeString[] = 
{
   "NONE",
   "IN"
};

const char* Sdp::SdpAddressTypeString[] =
{
   "NONE",
   "IP4",
   "IP6"
};

const char* Sdp::SdpBandwidthTypeString[] =
{
   "NONE",
   "CT",
   "AS",
   "TIAS",
   "RS",
   "RR"
};

const char* Sdp::SdpConferenceTypeString[] = 
{
   "NONE",
   "BROADCAST",
   "MODERATED",
   "TEST",
   "H332"
};

const char* Sdp::SdpGroupSemanticsString[] =
{
   "NONE",
   "LS",
   "FID",
   "SRF",
   "ANAT"
};


/* //////////////////////////// PUBLIC //////////////////////////////////// */

/* ============================ CREATORS ================================== */

// Constructor
Sdp::Sdp()
{
   mSdpVersion = 1;
   mOriginatorSessionId = 0;
   mOriginatorSessionVersion = 0;
   mOriginatorNetType = NET_TYPE_NONE;
   mOriginatorAddressType = ADDRESS_TYPE_NONE;
   mConferenceType = CONFERENCE_TYPE_NONE;
   mIcePassiveOnlyMode = false;
   mMaximumPacketRate = 0;
}

// Copy constructor
Sdp::Sdp(const Sdp& rhs)
{
   operator=(rhs); 
}

// Destructor
Sdp::~Sdp()
{
   mFoundationIds.destroyAll();
}

// Assignment operator
Sdp& Sdp::operator=(const Sdp& rhs)
{
   if (this == &rhs)            // handle the assignment to self case
      return *this;

   // Assign values
   mSdpVersion = rhs.mSdpVersion;
   mOriginatorUserName = rhs.mOriginatorUserName;
   mOriginatorSessionId = rhs.mOriginatorSessionId;
   mOriginatorSessionVersion = rhs.mOriginatorSessionVersion;
   mOriginatorNetType = rhs.mOriginatorNetType;
   mOriginatorAddressType = rhs.mOriginatorAddressType;
   mOriginatorUnicastAddress = rhs.mOriginatorUnicastAddress;
   mSessionName = rhs.mSessionName;
   mSessionInformation = rhs.mSessionInformation;
   mSessionUri = rhs.mSessionUri;
   mEmailAddresses = rhs.mEmailAddresses;
   mPhoneNumbers = rhs.mPhoneNumbers;
   mBandwidths = rhs.mBandwidths;
   mTimes = rhs.mTimes;
   mTimeZones = rhs.mTimeZones;
   mCategory = rhs.mCategory;
   mKeywords = rhs.mKeywords;
   mToolNameAndVersion = rhs.mToolNameAndVersion;
   mConferenceType = rhs.mConferenceType;
   mCharSet = rhs.mCharSet;
   mIcePassiveOnlyMode = rhs.mIcePassiveOnlyMode;
   mGroups = rhs.mGroups;
   mSessionLanguage = rhs.mSessionLanguage;
   mDescriptionLanguage = rhs.mDescriptionLanguage;
   mMaximumPacketRate = rhs.mMaximumPacketRate;
   mMediaLines = rhs.mMediaLines;

   // Copy FoundationIds over
   mFoundationIds.destroyAll();
   UtlHashMapIterator it(rhs.mFoundationIds);
   SdpFoundation* item;
   UtlString* value;
   while((item = static_cast<SdpFoundation*>(it())) && (value = static_cast<UtlString*>(it.value())))
   {
      mFoundationIds.insertKeyAndValue(item->clone(), value->clone() );
   }

   return *this;
}

Sdp::SdpAddressType Sdp::getAddressTypeFromString(const char * type)
{
   UtlString stringType(type);

   if(stringType.compareTo("IP4", UtlString::ignoreCase) == 0)
   {
      return ADDRESS_TYPE_IP4;
   }
   else if(stringType.compareTo("IP6", UtlString::ignoreCase) == 0)
   {
      return ADDRESS_TYPE_IP6;
   }
   else
   {
      return ADDRESS_TYPE_NONE;
   }
}

Sdp::SdpBandwidthType Sdp::SdpBandwidth::getTypeFromString(const char * type)
{
   UtlString stringType(type);

   if(stringType.compareTo("CT", UtlString::ignoreCase) == 0)
{'fraction_non_alphanumeric': 0.17010375304214168, 'fraction_numerical': 0.0071730498270782634, 'mean_word_length': 3.2948294829482947, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2614286', 'n_tokens_mistral': 2763, 'n_tokens_neox': 2709, 'n_words': 492}