Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changed comment style
  • Loading branch information
nairis committed Dec 5, 2018
commit 43d116cf4b94418532f46eeb243a1613340ca189
121 changes: 72 additions & 49 deletions includes/cpp_redis/builders/array_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,86 +31,109 @@ namespace cpp_redis {

namespace builders {

//!
//! builder to build redis array replies
//!
/**
* builder to build redis array replies
*
*/
class array_builder : public builder_iface {
public:
//! ctor
/**
* ctor
*
*/
array_builder();

//! dtor
/**
* dtor
*
*/
~array_builder() override = default;

//! copy ctor
/**
* copy ctor
*
*/
array_builder(const array_builder &) = delete;

//! assignment operator
/**
* assignment operator
*
*/
array_builder &operator=(const array_builder &) = delete;

public:
//!
//! take data as parameter which is consumed to build the reply
//! every bytes used to build the reply must be removed from the buffer passed as parameter
//!
//! @param data data to be consumed
//! @return current instance
//!
/**
* take data as parameter which is consumed to build the reply
* every bytes used to build the reply must be removed from the buffer passed as parameter
*
* @param data data to be consumed
* @return current instance
*
*/
builder_iface &operator<<(std::string &data) override;

//!
//! @return whether the reply could be built
//!
/**
* @return whether the reply could be built
*
*/
bool reply_ready() const override;

//!
//! @return reply object
//!
/**
* @return reply object
*
*/
reply get_reply() const override;

private:
//!
//! take data as parameter which is consumed to determine array size
//! every bytes used to build size is removed from the buffer passed as parameter
//!
//! @param buffer data to be consumer
//! @return true if the size could be found
//!
/**
* take data as parameter which is consumed to determine array size
* every bytes used to build size is removed from the buffer passed as parameter
*
* @param buffer data to be consumer
* @return true if the size could be found
*
*/
bool fetch_array_size(std::string &buffer);

//!
//! take data as parameter which is consumed to build an array row
//! every bytes used to build row is removed from the buffer passed as parameter
//!
//! @param buffer data to be consumer
//! @return true if the row could be built
//!
/**
* take data as parameter which is consumed to build an array row
* every bytes used to build row is removed from the buffer passed as parameter
*
* @param buffer data to be consumer
* @return true if the row could be built
*
*/
bool build_row(std::string &buffer);

private:
//!
//! builder used to fetch the array size
//!
/**
* builder used to fetch the array size
*
*/
integer_builder m_int_builder;

//!
//! built array size
//!
/**
* built array size
*
*/
uint64_t m_array_size;

//!
//! current builder used to build current row
//!
/**
* current builder used to build current row
*
*/
std::unique_ptr<builder_iface> m_current_builder;

//!
//! whether the reply is ready or not
//!
/**
* whether the reply is ready or not
*
*/
bool m_reply_ready;

//!
//! reply to be built (or built)
//!
/**
* reply to be built (or built)
*
*/
reply m_reply;
};

Expand Down
29 changes: 16 additions & 13 deletions includes/cpp_redis/builders/builder_iface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,26 @@ namespace cpp_redis {
public:
virtual ~builder_iface() = default;

//!
//! take data as parameter which is consumed to build the reply
//! every bytes used to build the reply must be removed from the buffer passed as parameter
//!
//! @param data data to be consumed
//! @return current instance
//!
/**
* take data as parameter which is consumed to build the reply
* every bytes used to build the reply must be removed from the buffer passed as parameter
*
* @param data data to be consumed
* @return current instance
*
*/
virtual builder_iface &operator<<(std::string &data) = 0;

//!
//! @return whether the reply could be built
//!
/**
* @return whether the reply could be built
*
*/
virtual bool reply_ready() const = 0;

//!
//! @return reply object
//!
/**
* @return reply object
*
*/
virtual reply get_reply() const = 0;
};

Expand Down
21 changes: 11 additions & 10 deletions includes/cpp_redis/builders/builders_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ namespace cpp_redis {

namespace builders {

//!
//! create a builder corresponding to the given id
//! * + for simple strings
//! * - for errors
//! * : for integers
//! * $ for bulk strings
//! * * for arrays
//!
//! @param id char that determines which builder to return
//! @return new builder instance depending on id value
/**
* create a builder corresponding to the given id
* * + for simple strings
* * - for errors
* * : for integers
* * $ for bulk strings
* * * for arrays
*
* @param id char that determines which builder to return
* @return new builder instance depending on id value
*/
//!
std::unique_ptr<builder_iface> create_builder(char id);

Expand Down
82 changes: 41 additions & 41 deletions includes/cpp_redis/builders/bulk_string_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,44 +35,44 @@ namespace builders {
//!
class bulk_string_builder : public builder_iface {
public:
//! ctor
//! ctor
bulk_string_builder(void);
//! dtor
//! dtor
~bulk_string_builder(void) = default;

//! copy ctor
//! copy ctor
bulk_string_builder(const bulk_string_builder&) = delete;
//! assignment operator
//! assignment operator
bulk_string_builder& operator=(const bulk_string_builder&) = delete;

public:
//!
//! take data as parameter which is consumed to build the reply
//! every bytes used to build the reply must be removed from the buffer passed as parameter
//!
//! @param data data to be consumed
//! @return current instance
//!
//!
//! take data as parameter which is consumed to build the reply
//! every bytes used to build the reply must be removed from the buffer passed as parameter
//!
//! @param data data to be consumed
//! @return current instance
//!
builder_iface& operator<<(std::string& data);

//!
//! @return whether the reply could be built
//!
//!
//! @return whether the reply could be built
//!
bool reply_ready(void) const;

//!
//! @return reply object
//!
//!
//! @return reply object
//!
reply get_reply(void) const;

//!
//! @return the parsed bulk string
//!
//!
//! @return the parsed bulk string
//!
const std::string& get_bulk_string(void) const;

//!
//! @return whether the bulk string is null
//!
//!
//! @return whether the bulk string is null
//!
bool is_null(void) const;

private:
Expand All @@ -81,34 +81,34 @@ class bulk_string_builder : public builder_iface {
void fetch_str(std::string& str);

private:
//!
//! builder used to get bulk string size
//!
//!
//! builder used to get bulk string size
//!
integer_builder m_int_builder;

//!
//! bulk string size
//!
//!
//! bulk string size
//!
int m_str_size;

//!
//! bulk string
//!
//!
//! bulk string
//!
std::string m_str;

//!
//! whether the bulk string is null
//!
//!
//! whether the bulk string is null
//!
bool m_is_null;

//!
//! whether the reply is ready or not
//!
//!
//! whether the reply is ready or not
//!
bool m_reply_ready;

//!
//! reply to be built
//!
//!
//! reply to be built
//!
reply m_reply;
};

Expand Down
Loading