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