reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ReceivedParameter.cxx
Go to the documentation of this file.
4#include "rutil/Logger.hxx"
5
6using namespace resip;
7
8#define RESIPROCATE_SUBSYSTEM resip::Subsystem::SIP
9
11 ParseBuffer& pb,
12 const std::bitset<256>& terminators) :
13 DataParameter(type)
14{
15 pb.skipWhitespace();
16
17 if (!pb.eof() && *pb.position() == Symbols::EQUALS[0])
18 {
19 // Catch the exception gracefully to handle seeing ";received="
20 try
21 {
22 pb.skipChar();
23 pb.skipWhitespace();
24
25 // Handle cases such as ";received="
26 if(terminators[(unsigned char)(*pb.position())])
27 {
28 ErrLog(<< "Empty value in string-type parameter.");
29 return;
30 }
31
32 const char* pos = pb.position();
33 pb.skipToOneOf(terminators);
34 pb.data(mValue, pos);
35 }
36 catch (const BaseException& e)
37 {
38 ErrLog(<< "Caught exception: " << e);
39 }
40 }
41
42 // The value of p_received will be filled if it is not empty.
43 // Otherwise, no exceptions as the empty parameter is allowed here.
44}
45
50
52 ParseBuffer& pb,
53 const std::bitset<256>& terminators,
54 PoolBase* pool)
55{
56 return new (pool) ReceivedParameter(type, pb, terminators);
57}
58
60{
61 return new ReceivedParameter(*this);
62}
63
65ReceivedParameter::encode(EncodeStream& stream) const
66{
67 if (!mValue.empty())
68 {
69 return stream << getName() << Symbols::EQUALS << mValue;
70 }
71 else
72 {
73 return stream << getName();
74 }
75}
#define ErrLog(args_)
Definition Logger.hxx:137
The abstract base-class for all exceptions thrown by resip code.
Generically represents miscellaneous parameter data.
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
virtual const Data & getName() const
Definition Parameter.cxx:23
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipWhitespace()
CurrentPosition position() const
CurrentPosition skipToOneOf(const char *cs)
CurrentPosition skipChar()
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
Represents the "via-received" element in the RFC 3261 grammar.
static Parameter * decode(ParameterTypes::Type type, ParseBuffer &pb, const std::bitset< 256 > &terminators, PoolBase *pool)
ReceivedParameter(ParameterTypes::Type type, ParseBuffer &pb, const std::bitset< 256 > &terminators)
EncodeStream & encode(EncodeStream &stream) const override
Parameter * clone() const override
static const char * EQUALS
Definition Symbols.hxx:29
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream