reSIProcate/stack  9694
ExistsOrDataParameter.cxx
Go to the documentation of this file.
00001 #if defined(HAVE_CONFIG_H)
00002 #include "config.h"
00003 #endif
00004 
00005 #include <cassert>
00006 #include "rutil/ParseException.hxx"
00007 #include "resip/stack/ExistsOrDataParameter.hxx"
00008 #include "resip/stack/Symbols.hxx"
00009 #include "rutil/Logger.hxx"
00010 #include "rutil/ParseBuffer.hxx"
00011 //#include "rutil/WinLeakCheck.hxx"  // not compatible with placement new used below
00012 
00013 namespace resip
00014 {
00015 
00016 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP
00017 
00018 
00019 ExistsOrDataParameter::ExistsOrDataParameter(ParameterTypes::Type type, bool) : 
00020    DataParameter(type)
00021 {
00022 }
00023 
00024 ExistsOrDataParameter::ExistsOrDataParameter(ParameterTypes::Type type,
00025                                               ParseBuffer& pb, 
00026                                               const std::bitset<256>& terminators)
00027    : DataParameter(type, pb, terminators)
00028 {
00029 }
00030 
00031 ExistsOrDataParameter::ExistsOrDataParameter(ParameterTypes::Type type)
00032    : DataParameter(type)
00033 {
00034 }
00035 
00036 Parameter* 
00037 ExistsOrDataParameter::decode(ParameterTypes::Type type, 
00038                               ParseBuffer& pb, 
00039                               const std::bitset<256>& terminators,
00040                               PoolBase* pool)
00041 {
00042    pb.skipWhitespace();
00043    if (pb.eof() || terminators[*pb.position()])
00044    {
00045       return new (pool) ExistsOrDataParameter(type);
00046    }
00047    else
00048    {
00049       return new (pool) ExistsOrDataParameter(type, pb, terminators);
00050    }
00051 }
00052 
00053 Parameter* 
00054 ExistsOrDataParameter::clone() const
00055 {
00056    return new ExistsOrDataParameter(*this);
00057 }
00058 
00059 EncodeStream& 
00060 ExistsOrDataParameter::encode(EncodeStream& stream) const
00061 {
00062    if (mValue.empty())
00063    {
00064       return stream << getName();
00065    }
00066    else
00067    {
00068       return DataParameter::encode(stream);
00069    }
00070 }
00071 
00072 } // namespace resip