Added Lexer class to QRedis namespace.
This commit is contained in:
parent
1374064c0b
commit
744781a03d
|
|
@ -1,5 +1,7 @@
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
|
using namespace QRedis;
|
||||||
|
|
||||||
Lexer::Lexer(QIODevice * device, QObject * parent)
|
Lexer::Lexer(QIODevice * device, QObject * parent)
|
||||||
: QObject(parent), device(device), state(DoingNothing), crlf(0)
|
: QObject(parent), device(device), state(DoingNothing), crlf(0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
63
src/lexer.h
63
src/lexer.h
|
|
@ -1,47 +1,50 @@
|
||||||
#ifndef LEXER_H
|
#ifndef QREDIS_LEXER_H
|
||||||
#define LEXER_H
|
#define QREDIS_LEXER_H
|
||||||
|
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class Lexer : public QObject
|
namespace QRedis
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class Lexer : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Lexer(QIODevice *, QObject * = 0);
|
Lexer(QIODevice *, QObject * = 0);
|
||||||
virtual ~Lexer();
|
virtual ~Lexer();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
||||||
void character(char);
|
void character(char);
|
||||||
void unsafeString(const QString &);
|
void unsafeString(const QString &);
|
||||||
void safeString(const QByteArray &);
|
void safeString(const QByteArray &);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
|
||||||
void readData();
|
void readData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool readCharacter();
|
bool readCharacter();
|
||||||
bool readLength();
|
bool readLength();
|
||||||
bool readUnsafeString();
|
bool readUnsafeString();
|
||||||
bool readSafeString();
|
bool readSafeString();
|
||||||
|
|
||||||
QIODevice * device;
|
QIODevice * device;
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
DoingNothing,
|
DoingNothing,
|
||||||
ReadingLength,
|
ReadingLength,
|
||||||
ReadingUnsafeString,
|
ReadingUnsafeString,
|
||||||
ReadingSafeString
|
ReadingSafeString
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
int crlf;
|
int crlf;
|
||||||
int length;
|
int length;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif // LEXER_H
|
#endif // QREDIS_LEXER_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue