MXS-1275: Inherit TrxBoundaryParser from CustomParser
This commit is contained in:
parent
9386143437
commit
1c6c19d6ae
@ -125,6 +125,25 @@ protected:
|
||||
((*(m_pI + offset) == uc) || (*(m_pI + offset) == lc));
|
||||
}
|
||||
|
||||
/**
|
||||
* Peek current character.
|
||||
*
|
||||
* @param pC Upon successful return will be the current character.
|
||||
*
|
||||
* @return True, if the current character was returned, false otherwise.
|
||||
* False will only be returned if the current position is at
|
||||
* the end.
|
||||
*/
|
||||
bool peek_current_char(char* pC) const
|
||||
{
|
||||
if (m_pI != m_pEnd)
|
||||
{
|
||||
*pC = *m_pI;
|
||||
}
|
||||
|
||||
return m_pI != m_pEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Peek next character.
|
||||
*
|
||||
@ -134,16 +153,16 @@ protected:
|
||||
* False will only be returned if the current position is at
|
||||
* the end.
|
||||
*/
|
||||
bool peek_next_char(char* pC)
|
||||
bool peek_next_char(char* pC) const
|
||||
{
|
||||
bypass_whitespace();
|
||||
bool rc = (m_pI + 1 < m_pEnd);
|
||||
|
||||
if (m_pI != m_pEnd)
|
||||
if (rc)
|
||||
{
|
||||
*pC = *m_pI;
|
||||
*pC = *(m_pI + 1);
|
||||
}
|
||||
|
||||
return m_pI != m_pEnd;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include <maxscale/cppdefs.hh>
|
||||
#include <ctype.h>
|
||||
#include <maxscale/modutil.h>
|
||||
#include <maxscale/customparser.hh>
|
||||
#include <maxscale/query_classifier.h>
|
||||
|
||||
namespace maxscale
|
||||
@ -37,8 +37,11 @@ namespace maxscale
|
||||
* of utmost importance; consequently it is defined in its entirety
|
||||
* in the header to allow for aggressive inlining.
|
||||
*/
|
||||
class TrxBoundaryParser
|
||||
class TrxBoundaryParser : public maxscale::CustomParser
|
||||
{
|
||||
TrxBoundaryParser(const TrxBoundaryParser&);
|
||||
TrxBoundaryParser& operator = (const TrxBoundaryParser&);
|
||||
|
||||
public:
|
||||
enum token_t
|
||||
{
|
||||
@ -88,10 +91,6 @@ public:
|
||||
* @endcode
|
||||
*/
|
||||
TrxBoundaryParser()
|
||||
: m_pSql(NULL)
|
||||
, m_len(0)
|
||||
, m_pI(NULL)
|
||||
, m_pEnd(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -546,29 +545,6 @@ private:
|
||||
return type_mask;
|
||||
}
|
||||
|
||||
inline bool is_next_alpha(char uc, int offset = 1) const
|
||||
{
|
||||
ss_dassert(uc >= 'A' && uc <= 'Z');
|
||||
|
||||
char lc = uc + ('a' - 'A');
|
||||
|
||||
return
|
||||
((m_pI + offset) < m_pEnd) &&
|
||||
((*(m_pI + offset) == uc) || (*(m_pI + offset) == lc));
|
||||
}
|
||||
|
||||
bool peek_next_char(char* pC) const
|
||||
{
|
||||
bool rc = (m_pI + 1 < m_pEnd);
|
||||
|
||||
if (rc)
|
||||
{
|
||||
*pC = *(m_pI + 1);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Significantly faster than library version.
|
||||
static char toupper(char c)
|
||||
{
|
||||
@ -825,16 +801,6 @@ private:
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
private:
|
||||
TrxBoundaryParser(const TrxBoundaryParser&);
|
||||
TrxBoundaryParser& operator = (const TrxBoundaryParser&);
|
||||
|
||||
private:
|
||||
const char* m_pSql;
|
||||
int m_len;
|
||||
const char* m_pI;
|
||||
const char* m_pEnd;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -374,9 +374,15 @@ private:
|
||||
// the identifier and if it is followed by a "=" we consume the value.
|
||||
{
|
||||
char c;
|
||||
if (consume_id() && peek_next_char(&c) && (c == '='))
|
||||
if (consume_id())
|
||||
{
|
||||
consume_value();
|
||||
bypass_whitespace();
|
||||
|
||||
if (peek_current_char(&c) && (c == '='))
|
||||
{
|
||||
++m_pI;
|
||||
consume_value();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -396,7 +402,9 @@ private:
|
||||
|
||||
if (rv != ERROR)
|
||||
{
|
||||
if (peek_next_char(&c))
|
||||
bypass_whitespace();
|
||||
|
||||
if (peek_current_char(&c))
|
||||
{
|
||||
if (c == ',')
|
||||
{
|
||||
@ -470,7 +478,9 @@ private:
|
||||
|
||||
if (!is_error(rv))
|
||||
{
|
||||
if (peek_next_char(&c) && (c == ','))
|
||||
bypass_whitespace();
|
||||
|
||||
if (peek_current_char(&c) && (c == ','))
|
||||
{
|
||||
++m_pI;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user