|
reSIProcate/stack
9694
|
00001 #if defined(HAVE_CONFIG_H) 00002 #include "config.h" 00003 #endif 00004 00005 #include "resip/stack/RportParameter.hxx" 00006 #include "resip/stack/Symbols.hxx" 00007 #include "rutil/ParseBuffer.hxx" 00008 #include "rutil/Logger.hxx" 00009 #include "rutil/BaseException.hxx" 00010 #include "rutil/WinLeakCheck.hxx" 00011 00012 using namespace resip; 00013 using namespace std; 00014 00015 #define RESIPROCATE_SUBSYSTEM resip::Subsystem::SIP 00016 00017 RportParameter::RportParameter(ParameterTypes::Type type, 00018 ParseBuffer& pb, 00019 const std::bitset<256>& terminators) 00020 : Parameter(type), 00021 mValue(0), 00022 mHasValue(false) 00023 { 00024 pb.skipWhitespace(); 00025 if (!pb.eof() && *pb.position() == Symbols::EQUALS[0]) 00026 { 00027 mHasValue = true; 00028 00029 pb.skipChar(); 00030 pb.skipWhitespace(); 00031 00032 // Catch the exception gracefully to handle seeing ;rport= 00033 try 00034 { 00035 mValue = pb.integer(); 00036 } 00037 catch(BaseException& e ) 00038 { 00039 ErrLog(<<"Caught exception: "<< e); 00040 mHasValue = false; 00041 } 00042 } 00043 } 00044 00045 RportParameter::RportParameter(ParameterTypes::Type type, int value) 00046 : Parameter(type), 00047 mValue(value), 00048 mHasValue(true) 00049 { 00050 } 00051 00052 RportParameter::RportParameter(ParameterTypes::Type type) 00053 : Parameter(type), 00054 mValue(-1), 00055 mHasValue(false) 00056 { 00057 } 00058 00059 Parameter* 00060 RportParameter::clone() const 00061 { 00062 return new RportParameter(*this); 00063 } 00064 00065 EncodeStream& 00066 RportParameter::encode(EncodeStream& stream) const 00067 { 00068 if (mHasValue || mValue > 0) 00069 { 00070 return stream << getName() << Symbols::EQUALS << mValue; 00071 } 00072 else 00073 { 00074 return stream << getName(); 00075 } 00076 } 00077 00078 00079 /* ==================================================================== 00080 * The Vovida Software License, Version 1.0 00081 * 00082 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00083 * 00084 * Redistribution and use in source and binary forms, with or without 00085 * modification, are permitted provided that the following conditions 00086 * are met: 00087 * 00088 * 1. Redistributions of source code must retain the above copyright 00089 * notice, this list of conditions and the following disclaimer. 00090 * 00091 * 2. Redistributions in binary form must reproduce the above copyright 00092 * notice, this list of conditions and the following disclaimer in 00093 * the documentation and/or other materials provided with the 00094 * distribution. 00095 * 00096 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00097 * and "Vovida Open Communication Application Library (VOCAL)" must 00098 * not be used to endorse or promote products derived from this 00099 * software without prior written permission. For written 00100 * permission, please contact vocal@vovida.org. 00101 * 00102 * 4. Products derived from this software may not be called "VOCAL", nor 00103 * may "VOCAL" appear in their name, without prior written 00104 * permission of Vovida Networks, Inc. 00105 * 00106 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00107 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00108 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00109 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00110 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00111 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00112 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00113 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00114 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00115 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00116 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00117 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00118 * DAMAGE. 00119 * 00120 * ==================================================================== 00121 * 00122 * This software consists of voluntary contributions made by Vovida 00123 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00124 * Inc. For more information on Vovida Networks, Inc., please see 00125 * <http://www.vovida.org/>. 00126 * 00127 */
1.7.5.1