|
reSIProcate/stack
9694
|
00001 #if defined(HAVE_CONFIG_H) 00002 #include "config.h" 00003 #endif 00004 00005 #include "resip/stack/WarningCategory.hxx" 00006 #include "rutil/Logger.hxx" 00007 #include "rutil/ParseBuffer.hxx" 00008 //#include "rutil/WinLeakCheck.hxx" // not compatible with placement new used below 00009 00010 using namespace resip; 00011 using namespace std; 00012 00013 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP 00014 00015 //==================== 00016 // WarningCategory 00017 //==================== 00018 WarningCategory::WarningCategory() 00019 : ParserCategory() 00020 {} 00021 00022 WarningCategory::WarningCategory(const HeaderFieldValue& hfv, 00023 Headers::Type type, 00024 PoolBase* pool) 00025 : ParserCategory(hfv, type, pool) 00026 {} 00027 00028 WarningCategory::WarningCategory(const WarningCategory& rhs, 00029 PoolBase* pool) 00030 : ParserCategory(rhs, pool), 00031 mCode(rhs.mCode), 00032 mHostname(rhs.mHostname), 00033 mText(rhs.mText) 00034 {} 00035 00036 WarningCategory& 00037 WarningCategory::operator=(const WarningCategory& rhs) 00038 { 00039 if (this != &rhs) 00040 { 00041 ParserCategory::operator=(rhs); 00042 mCode = rhs.mCode; 00043 mHostname = rhs.mHostname; 00044 mText = rhs.mText; 00045 } 00046 return *this; 00047 } 00048 void 00049 WarningCategory::parse(ParseBuffer& pb) 00050 { 00051 pb.skipWhitespace(); 00052 mCode = pb.uInt32(); 00053 00054 if(mCode >= 1000 || mCode < 100) 00055 { 00056 pb.fail(__FILE__,__LINE__,"Warning code does not have exactly three digits."); 00057 } 00058 00059 const char* anchor = pb.skipWhitespace(); 00060 pb.skipNonWhitespace(); 00061 pb.data(mHostname, anchor); 00062 00063 pb.skipWhitespace(); 00064 anchor = pb.skipChar(Symbols::DOUBLE_QUOTE[0]); 00065 pb.skipToEndQuote(Symbols::DOUBLE_QUOTE[0]); 00066 pb.data(mText, anchor); 00067 anchor = pb.skipChar(Symbols::DOUBLE_QUOTE[0]); 00068 pb.skipWhitespace(); 00069 pb.assertEof(); 00070 } 00071 00072 ParserCategory* 00073 WarningCategory::clone() const 00074 { 00075 return new WarningCategory(*this); 00076 } 00077 00078 ParserCategory* 00079 WarningCategory::clone(void* location) const 00080 { 00081 return new (location) WarningCategory(*this); 00082 } 00083 00084 ParserCategory* 00085 WarningCategory::clone(PoolBase* pool) const 00086 { 00087 return new (pool) WarningCategory(*this, pool); 00088 } 00089 00090 int& 00091 WarningCategory::code() 00092 { 00093 checkParsed(); 00094 return mCode; 00095 } 00096 00097 int 00098 WarningCategory::code() const 00099 { 00100 checkParsed(); 00101 return mCode; 00102 } 00103 00104 Data& 00105 WarningCategory::hostname() 00106 { 00107 checkParsed(); 00108 return mHostname; 00109 } 00110 00111 const Data& 00112 WarningCategory::hostname() const 00113 { 00114 checkParsed(); 00115 return mHostname; 00116 } 00117 00118 Data& 00119 WarningCategory::text() 00120 { 00121 checkParsed(); 00122 return mText; 00123 } 00124 00125 const Data& 00126 WarningCategory::text() const 00127 { 00128 checkParsed(); 00129 return mText; 00130 } 00131 00132 EncodeStream& 00133 WarningCategory::encodeParsed(EncodeStream& str) const 00134 { 00135 str << mCode << Symbols::SPACE[0]; 00136 str << mHostname << Symbols::SPACE[0]; 00137 str << Symbols::DOUBLE_QUOTE[0] << mText << Symbols::DOUBLE_QUOTE[0]; 00138 00139 return str; 00140 } 00141 00142 00143 /* ==================================================================== 00144 * The Vovida Software License, Version 1.0 00145 * 00146 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00147 * 00148 * Redistribution and use in source and binary forms, with or without 00149 * modification, are permitted provided that the following conditions 00150 * are met: 00151 * 00152 * 1. Redistributions of source code must retain the above copyright 00153 * notice, this list of conditions and the following disclaimer. 00154 * 00155 * 2. Redistributions in binary form must reproduce the above copyright 00156 * notice, this list of conditions and the following disclaimer in 00157 * the documentation and/or other materials provided with the 00158 * distribution. 00159 * 00160 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00161 * and "Vovida Open Communication Application Library (VOCAL)" must 00162 * not be used to endorse or promote products derived from this 00163 * software without prior written permission. For written 00164 * permission, please contact vocal@vovida.org. 00165 * 00166 * 4. Products derived from this software may not be called "VOCAL", nor 00167 * may "VOCAL" appear in their name, without prior written 00168 * permission of Vovida Networks, Inc. 00169 * 00170 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00171 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00172 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00173 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00174 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00175 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00176 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00177 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00178 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00179 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00180 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00181 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00182 * DAMAGE. 00183 * 00184 * ==================================================================== 00185 * 00186 * This software consists of voluntary contributions made by Vovida 00187 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00188 * Inc. For more information on Vovida Networks, Inc., please see 00189 * <http://www.vovida.org/>. 00190 * 00191 */
1.7.5.1