reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
LazyParser.hxx
Go to the documentation of this file.
1
#if !defined(RESIP_LAZYPARSER_HXX)
2
#define RESIP_LAZYPARSER_HXX
3
4
#ifdef HAVE_CONFIG_H
5
#include "config.h"
6
#endif
7
8
#include <iosfwd>
9
#include "
resip/stack/HeaderFieldValue.hxx
"
10
#include "
rutil/resipfaststreams.hxx
"
11
12
namespace
resip
13
{
14
15
class
ParseBuffer;
16
class
Data;
17
34
class
LazyParser
35
{
36
public
:
40
explicit
LazyParser
(
const
HeaderFieldValue
& headerFieldValue);
41
45
LazyParser
(
const
char
* buf,
int
length);
46
50
LazyParser
(
const
HeaderFieldValue
& headerFieldValue,
51
HeaderFieldValue::CopyPaddingEnum
e);
52
56
LazyParser
(
const
LazyParser
& rhs);
57
61
LazyParser
(
const
LazyParser
& rhs,
HeaderFieldValue::CopyPaddingEnum
e);
62
66
LazyParser
&
operator=
(
const
LazyParser
& rhs);
67
virtual
~LazyParser
();
68
72
virtual
EncodeStream
&
encodeParsed
(
EncodeStream
& str)
const
= 0;
73
77
virtual
void
parse
(
ParseBuffer
& pb) = 0;
78
85
EncodeStream
&
encode
(
EncodeStream
& str)
const
;
86
91
bool
isParsed
()
const
{
return
(mState!=NOT_PARSED);}
92
96
HeaderFieldValue
&
getHeaderField
() {
return
mHeaderField; }
97
98
// call (internally) before every access
102
void
checkParsed
()
const
103
{
104
if
(mState==NOT_PARSED)
105
{
106
doParse
();
107
}
108
}
109
void
checkParsed
()
110
{
111
const
LazyParser
* constThis =
const_cast<
const
LazyParser
*
>
(
this
);
112
constThis->
checkParsed
();
113
mState=DIRTY;
114
}
115
void
doParse
()
const
;
116
inline
void
markDirty
()
const
{mState=DIRTY;}
117
128
bool
isWellFormed
()
const
;
129
protected
:
130
LazyParser
();
131
132
// called in destructor and on assignment
133
void
clear
();
134
135
// context for error messages
136
virtual
const
Data
&
errorContext
()
const
= 0;
137
138
private
:
139
// !dlb! bit of a hack until the dust settles
140
friend
class
Contents
;
141
142
HeaderFieldValue
mHeaderField;
143
144
typedef
enum
145
{
146
NOT_PARSED,
147
WELL_FORMED,
// Parsed, well-formed, but underlying buffer is still valid
148
MALFORMED,
// Parsed, malformed, underlying buffer is still valid
149
DIRTY
// Well-formed, and underlying buffer is invalid
150
} ParseState;
151
mutable
ParseState mState;
152
};
153
154
#ifndef RESIP_USE_STL_STREAMS
155
EncodeStream
&
156
operator<<
(
EncodeStream
&,
const
LazyParser&
lp
);
157
#endif
158
159
//need this for DigestStream
160
std::ostream&
161
operator<<
(std::ostream&,
const
LazyParser&
lp
);
162
163
}
164
165
#endif
166
167
/* ====================================================================
168
* The Vovida Software License, Version 1.0
169
*
170
* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
171
*
172
* Redistribution and use in source and binary forms, with or without
173
* modification, are permitted provided that the following conditions
174
* are met:
175
*
176
* 1. Redistributions of source code must retain the above copyright
177
* notice, this list of conditions and the following disclaimer.
178
*
179
* 2. Redistributions in binary form must reproduce the above copyright
180
* notice, this list of conditions and the following disclaimer in
181
* the documentation and/or other materials provided with the
182
* distribution.
183
*
184
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
185
* and "Vovida Open Communication Application Library (VOCAL)" must
186
* not be used to endorse or promote products derived from this
187
* software without prior written permission. For written
188
* permission, please contact vocal@vovida.org.
189
*
190
* 4. Products derived from this software may not be called "VOCAL", nor
191
* may "VOCAL" appear in their name, without prior written
192
* permission of Vovida Networks, Inc.
193
*
194
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
195
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
196
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
197
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
198
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
199
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
200
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
201
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
202
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
203
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
204
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
205
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
206
* DAMAGE.
207
*
208
* ====================================================================
209
*
210
* This software consists of voluntary contributions made by Vovida
211
* Networks, Inc. and many individuals on behalf of Vovida Networks,
212
* Inc. For more information on Vovida Networks, Inc., please see
213
* <http://www.vovida.org/>.
214
*
215
*/
HeaderFieldValue.hxx
resip::Contents
Base class for all SIP body types.
Definition
Contents.hxx:51
resip::Data
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition
Data.hxx:90
resip::HeaderFieldValue
Definition
HeaderFieldValue.hxx:21
resip::HeaderFieldValue::CopyPaddingEnum
CopyPaddingEnum
Definition
HeaderFieldValue.hxx:26
resip::LazyParser
The base-class for all lazily-parsed SIP grammar elements.
Definition
LazyParser.hxx:35
resip::LazyParser::encode
EncodeStream & encode(EncodeStream &str) const
Encodes this element to a stream, in the fashion it should be represented on the wire.
Definition
LazyParser.cxx:105
resip::LazyParser::checkParsed
void checkParsed()
Definition
LazyParser.hxx:109
resip::LazyParser::checkParsed
void checkParsed() const
Definition
LazyParser.hxx:102
resip::LazyParser::LazyParser
LazyParser()
Definition
LazyParser.cxx:33
resip::LazyParser::doParse
void doParse() const
Definition
LazyParser.cxx:73
resip::LazyParser::operator=
LazyParser & operator=(const LazyParser &rhs)
Definition
LazyParser.cxx:56
resip::LazyParser::clear
void clear()
Definition
LazyParser.cxx:99
resip::LazyParser::parse
virtual void parse(ParseBuffer &pb)=0
resip::LazyParser::getHeaderField
HeaderFieldValue & getHeaderField()
Definition
LazyParser.hxx:96
resip::LazyParser::markDirty
void markDirty() const
Definition
LazyParser.hxx:116
resip::LazyParser::errorContext
virtual const Data & errorContext() const =0
resip::LazyParser::encodeParsed
virtual EncodeStream & encodeParsed(EncodeStream &str) const =0
resip::LazyParser::isWellFormed
bool isWellFormed() const
Returns true iff this element was parsed successfully, according to the implementation of parse().
Definition
LazyParser.cxx:85
resip::LazyParser::isParsed
bool isParsed() const
Returns true iff a parse has been attempted.
Definition
LazyParser.hxx:91
resip::LazyParser::~LazyParser
virtual ~LazyParser()
Definition
LazyParser.cxx:50
resip::ParseBuffer
Provides string-parsing functionality with protection from buffer overflow.
Definition
ParseBuffer.hxx:18
resip
dcm! – add UnusedChecking(_enum) below;
Definition
AbstractFifo.hxx:16
resip::operator<<
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
Definition
BaseException.cxx:25
resipfaststreams.hxx
Replaces STL streams for general encoding purposes.
EncodeStream
#define EncodeStream
Definition
resipfaststreams.hxx:461
list
void list()
Definition
userAdmin.cxx:66
resip
stack
LazyParser.hxx
Generated by
1.9.8