58 lines
878 B
C++
58 lines
878 B
C++
#ifndef MYX_REDIS_PARSER_HPP_
|
|
#define MYX_REDIS_PARSER_HPP_
|
|
|
|
#include <QList>
|
|
#include <QObject>
|
|
#include <QPair>
|
|
#include <QVariant>
|
|
|
|
#include <reply.hpp>
|
|
#include <lexer.hpp>
|
|
|
|
namespace myx {
|
|
|
|
namespace redis {
|
|
|
|
class Parser : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
Parser( Lexer*, QObject* = nullptr );
|
|
virtual ~Parser() = default;
|
|
|
|
Q_SIGNAL void reply( const myx::redis::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 redis
|
|
|
|
} // namespace myx
|
|
|
|
#endif // MYX_REDIS_PARSER_HPP_
|