Поддержка Redis
This commit is contained in:
54
src/myx/redis/parser.hpp
Normal file
54
src/myx/redis/parser.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
#ifndef QREDIS_PARSER_H
|
||||
#define QREDIS_PARSER_H
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QVariant>
|
||||
|
||||
#include <reply.hpp>
|
||||
#include <lexer.hpp>
|
||||
|
||||
namespace qxredis
|
||||
{
|
||||
|
||||
class Parser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Parser( Lexer*, QObject* = nullptr );
|
||||
virtual ~Parser() = default;
|
||||
|
||||
Q_SIGNAL void reply( const qxredis::Reply& );
|
||||
|
||||
private:
|
||||
Q_SLOT void readCharacter( const char );
|
||||
Q_SLOT void readUnsafeString( const QString& );
|
||||
Q_SLOT void readSafeString( const QByteArray& );
|
||||
|
||||
private:
|
||||
void descend();
|
||||
|
||||
class Task
|
||||
{
|
||||
public:
|
||||
|
||||
enum { Unknown = -2 };
|
||||
|
||||
Task( Reply::Type type ) :
|
||||
reply( type ),
|
||||
count( Unknown ) {}
|
||||
|
||||
Reply reply;
|
||||
int count;
|
||||
};
|
||||
|
||||
QList< Task > stack;
|
||||
|
||||
Task& tos() { return( stack.last() ); }
|
||||
}; // class Parser
|
||||
|
||||
} // namespace QRedis
|
||||
|
||||
#endif // QREDIS_PARSER_H
|
Reference in New Issue
Block a user