1#if !defined(RESIP_PARSEBUFFER_HXX)
2#define RESIP_PARSEBUFFER_HXX
51 inline explicit CurrentPosition(
const ParseBuffer& pb) :
55 operator const char*()
const
60 const char& operator*()
const
63 return *mPb.mPosition;
80 Pointer(
const CurrentPosition& pos);
82 operator const char*()
const
87 const char& operator*()
const;
90 const char* mPosition;
92 static const Data msg;
110 bool eof()
const {
return mPosition >= mEnd;}
111 bool bof()
const {
return mPosition <= mBuff;}
113 Pointer
start()
const {
return Pointer(*
this, mBuff,
eof()); }
114 CurrentPosition
position()
const {
return CurrentPosition(*
this); }
115 Pointer
end()
const {
return Pointer(*
this, mEnd,
true); }
122 fail(__FILE__, __LINE__,
"skipped over eof");
125 return CurrentPosition(*
this);
129 CurrentPosition
skipChars(
const char* cs);
137 mPosition = (
const char*)memchr(mPosition, c, mEnd-mPosition);
142 return CurrentPosition(*
this);
147 CurrentPosition
skipToOneOf(
const char* cs1,
const char* cs2);
154 while (mPosition < mEnd)
156 if (cs.test((
unsigned char)(*mPosition)))
162 return CurrentPosition(*
this);
165 return CurrentPosition(*
this);
170 while (mPosition < mEnd)
172 if (cs.test((
unsigned char)(*mPosition)))
174 return CurrentPosition(*
this);
181 return CurrentPosition(*
this);
188 if (mPosition > mEnd)
190 fail(__FILE__, __LINE__,
"skipped eof");
192 return CurrentPosition(*
this);
198 return CurrentPosition(*
this);
209 fail(__FILE__, __LINE__,
"backed over beginning of buffer");
222 fail(__FILE__, __LINE__,
"expected eof");
230 fail(__FILE__, __LINE__,
"unexpected eof");
234 void fail(
const char* file,
unsigned int line,
254#ifndef RESIP_FIXED_POINT
259 static bool oneOf(
char c,
const char* cs);
260 static bool oneOf(
char c,
const Data& cs);
266 const char* mPosition;
268 const Data& mErrorContext;
#define resip_assert(x)
This file needs to work for both C and C++ code.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipLWS()
CurrentPosition skipNonWhitespace()
void dataUnescaped(Data &data, const char *start) const
const char * skipBackToChar(char c)
uint32_t uInt32()
dcm! – merge these, ask about length checks
CurrentPosition skipToEnd()
ParseBuffer & operator=(const ParseBuffer &other)
static const char * ParamTerm
const char * skipBackChar()
CurrentPosition skipWhitespace()
CurrentPosition skipToOneOf(const std::bitset< 256 > &cs)
CurrentPosition skipToChars(const char *cs)
unsigned long unsignedInteger()
CurrentPosition skipToChar(char c)
CurrentPosition position() const
static bool oneOf(char c, const char *cs)
void reset(const char *pos)
CurrentPosition skipChars(const char *cs)
const Data & getContext() const
void assertNotEof() const
const char * skipBackN(int count)
CurrentPosition skipToOneOf(const char *cs)
CurrentPosition skipN(size_t count)
CurrentPosition skipChar()
CurrentPosition skipToTermCRLF()
void fail(const char *file, unsigned int line, const Data &errmsg=Data::Empty) const
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
CurrentPosition skipChars(const std::bitset< 256 > &cs)
friend class ParseBuffer::CurrentPosition
const char * skipToEndQuote(char quote='"')
uint64_t unsignedLongLong()
const char * skipBackWhitespace()
const char * skipBackToOneOf(const char *cs)
static const char * Whitespace
BaseException used to indicate parse failures.
#define RESIP_DEPRECATED(x)
dcm! – add UnusedChecking(_enum) below;
unsigned long long uint64_t