/[resiprocate]/main/sip/resiprocate/LazyParser.cxx
ViewVC logotype

Annotation of /main/sip/resiprocate/LazyParser.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 718 - (hide annotations) (download)
Mon Nov 25 19:26:41 2002 UTC (17 years, 2 months ago) by davidb
File size: 1792 byte(s)
lazy parser as base for ParserCategory and Contents.
added MessageWaitingContents, SdpContents.

1 davidb 718 #include "sip2/sipstack/HeaderFieldValue.hxx"
2     #include "sip2/sipstack/LazyParser.hxx"
3     #include "sip2/util/ParseBuffer.hxx"
4    
5     using namespace Vocal2;
6    
7     LazyParser::LazyParser(HeaderFieldValue* headerFieldValue)
8     : mHeaderField(headerFieldValue),
9     mIsMine(false),
10     mIsParsed(mHeaderField->mField == 0) //although this has a hfv it is
11     //parsed, as the hfv has no content
12     {
13     }
14    
15     LazyParser::LazyParser()
16     : mHeaderField(0),
17     mIsMine(true),
18     mIsParsed(true)
19     {
20     }
21    
22     LazyParser::LazyParser(const LazyParser& rhs)
23     : mHeaderField(0),
24     mIsMine(true),
25     mIsParsed(rhs.mIsParsed)
26     {
27     if (!mIsParsed && rhs.mHeaderField)
28     {
29     mHeaderField = new HeaderFieldValue(*rhs.mHeaderField);
30     }
31     }
32    
33     LazyParser::~LazyParser()
34     {
35     clear();
36     }
37    
38     LazyParser&
39     LazyParser::operator=(const LazyParser& rhs)
40     {
41     if (this != &rhs)
42     {
43     clear();
44     mIsParsed = rhs.mIsParsed;
45     if (rhs.mIsParsed)
46     {
47     mHeaderField = 0;
48     mIsMine = false;
49     }
50     else
51     {
52     mHeaderField = new HeaderFieldValue(*rhs.mHeaderField);
53     mIsMine = true;
54     }
55     }
56     return *this;
57     }
58    
59     void
60     LazyParser::checkParsed() const
61     {
62     if (!mIsParsed)
63     {
64     LazyParser* ncThis = const_cast<LazyParser*>(this);
65     ncThis->mIsParsed = true;
66     ParseBuffer pb(mHeaderField->mField, mHeaderField->mFieldLength);
67     ncThis->parse(pb);
68     }
69     }
70    
71     void
72     LazyParser::clear()
73     {
74     if (mIsMine)
75     {
76     delete mHeaderField;
77     mHeaderField = 0;
78     }
79     }
80    
81     std::ostream&
82     LazyParser::encodeFromHeaderFieldValue(std::ostream& str) const
83     {
84     assert(mHeaderField);
85     mHeaderField->encode(str);
86     return str;
87     }
88    
89     std::ostream&
90     Vocal2::operator<<(std::ostream& s, const LazyParser& lp)
91     {
92     lp.encode(s);
93     return s;
94     }

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27