diff --git a/src/myx/redis/CMakeLists.txt b/src/myx/redis/CMakeLists.txt index 4e8527d..34825af 100644 --- a/src/myx/redis/CMakeLists.txt +++ b/src/myx/redis/CMakeLists.txt @@ -18,6 +18,9 @@ set(TRGT_moc_hpp ${CMAKE_CURRENT_SOURCE_DIR}/request.hpp) set(TRGT_hpp + ${CMAKE_CURRENT_SOURCE_DIR}/client_p.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/request_p.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/parser_p.hpp ${CMAKE_CURRENT_SOURCE_DIR}/client-inl.hpp ${CMAKE_CURRENT_SOURCE_DIR}/lexer-inl.hpp ${CMAKE_CURRENT_SOURCE_DIR}/parser-inl.hpp diff --git a/src/myx/redis/client_p.hpp b/src/myx/redis/client_p.hpp index a09adfc..56192bc 100644 --- a/src/myx/redis/client_p.hpp +++ b/src/myx/redis/client_p.hpp @@ -29,10 +29,11 @@ public: Parser parser; private: - Q_SLOT void sendReply(const myx::redis::Reply & ); + Q_SLOT void sendReply( const myx::redis::Reply& ); }; // class ClientPrivate -} -} +} // namespace redis + +} // namespace myx #endif // MYX_REDIS_CLIENT_P_HPP_ diff --git a/src/myx/redis/lexer.hpp b/src/myx/redis/lexer.hpp index 4109feb..a3cf1cc 100644 --- a/src/myx/redis/lexer.hpp +++ b/src/myx/redis/lexer.hpp @@ -28,8 +28,6 @@ private: Q_SLOT void readData(); -private: - bool readCharacter(); bool readLength(); bool readUnsafeString(); diff --git a/src/myx/redis/parser-inl.hpp b/src/myx/redis/parser-inl.hpp index 804db59..8c08a60 100644 --- a/src/myx/redis/parser-inl.hpp +++ b/src/myx/redis/parser-inl.hpp @@ -25,15 +25,15 @@ void Parser::readCharacter( const char c ) switch ( c ) { case '+': - stack.append( Task( Reply::Status ) ); break; + m_stack.append( ParserTaskPrivate( Reply::Status ) ); break; case '-': - stack.append( Task( Reply::Error ) ); break; + m_stack.append( ParserTaskPrivate( Reply::Error ) ); break; case ':': - stack.append( Task( Reply::Integer ) ); break; + m_stack.append( ParserTaskPrivate( Reply::Integer ) ); break; case '$': - stack.append( Task( Reply::Bulk ) ); break; + m_stack.append( ParserTaskPrivate( Reply::Bulk ) ); break; case '*': - stack.append( Task( Reply::MultiBulk ) ); break; + m_stack.append( ParserTaskPrivate( Reply::MultiBulk ) ); break; default: break; } @@ -72,14 +72,14 @@ void Parser::descend() return; } - if ( stack.count() == 1 ) + if ( m_stack.count() == 1 ) { - auto r = stack.takeLast().reply; + auto r = m_stack.takeLast().reply; Q_EMIT reply( r ); return; } - auto r = stack.takeLast().reply; + auto r = m_stack.takeLast().reply; tos().reply.value().toList().append( QVariant::fromValue( r ) ); } } diff --git a/src/myx/redis/parser.hpp b/src/myx/redis/parser.hpp index a1156fc..7379171 100644 --- a/src/myx/redis/parser.hpp +++ b/src/myx/redis/parser.hpp @@ -4,8 +4,9 @@ #pragma once #include -#include #include +#include +#include #include #include @@ -33,23 +34,9 @@ private: private: void descend(); - class Task - { -public: + QList< ParserTaskPrivate > m_stack; - enum { Unknown = -2 }; - - Task( Reply::Type type ) : - reply( type ), - count( Unknown ) {} - - Reply reply; - int count; - }; - - QList< Task > stack; - - Task& tos() { return( stack.last() ); } + ParserTaskPrivate& tos() { return( m_stack.last() ); } }; // class Parser } // namespace redis diff --git a/src/myx/redis/parser_p.hpp b/src/myx/redis/parser_p.hpp new file mode 100644 index 0000000..124c21c --- /dev/null +++ b/src/myx/redis/parser_p.hpp @@ -0,0 +1,30 @@ +#ifndef MYX_REDIS_PARSER_P_HPP_ +#define MYX_REDIS_PARSER_P_HPP_ + +#pragma once + +#include + +namespace myx { + +namespace redis { + +class ParserTaskPrivate +{ + friend class Parser; + + enum { Unknown = -2 }; + + ParserTaskPrivate( Reply::Type type ) : + reply( type ), + count( Unknown ) {} + + Reply reply; + int count; +}; + +} // namespace redis + +} // namespace myx + +#endif // MYX_REDIS_PARSER_P_HPP_ diff --git a/src/myx/redis/reply.hpp b/src/myx/redis/reply.hpp index a62e59a..a92d008 100644 --- a/src/myx/redis/reply.hpp +++ b/src/myx/redis/reply.hpp @@ -76,32 +76,32 @@ public: * @brief Creates an empty reply */ Reply() : - _type( Invalid ) {} + m_type( Invalid ) {} /** * @brief Initializes the reply * @param type the type of the reply */ Reply( Type type ) : - _type( type ) {} + m_type( type ) {} /** * @brief Returns the type of the reply * @return the reply type */ - Type type() const { return( _type ); } + Type type() const { return( m_type ); } /** * @brief Returns a reference to the value of the reply * @return the reply value */ - QVariant& value() { return( _value ); } + QVariant& value() { return( m_value ); } private: - Type _type; - QVariant _value; -}; // class MYX_REDIS_EXPORT Reply + Type m_type; + QVariant m_value; +}; // class Reply } // namespace redis diff --git a/src/myx/redis/request_p.hpp b/src/myx/redis/request_p.hpp index ff54df9..90e4042 100644 --- a/src/myx/redis/request_p.hpp +++ b/src/myx/redis/request_p.hpp @@ -19,7 +19,7 @@ public: Q_SLOT void quitEventLoop(); }; -} +} // namespace redis -} +} // namespace myx #endif // MYX_REDIS_REQUEST_P_HPP_