64 lines
984 B
C++
64 lines
984 B
C++
#ifndef MYX_REDIS_PARSER_HPP_
|
|
#define MYX_REDIS_PARSER_HPP_
|
|
|
|
#pragma once
|
|
|
|
#include <myx/base/config.hpp>
|
|
#include <myx/redis/reply.hpp>
|
|
#include <myx/redis/lexer.hpp>
|
|
|
|
#include <QList>
|
|
#include <QPair>
|
|
#include <QVariant>
|
|
|
|
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
|
|
|
|
#ifdef MYXLIB_HEADER_ONLY
|
|
#include "parser-inl.hpp"
|
|
#endif
|
|
|
|
#endif // MYX_REDIS_PARSER_HPP_
|