FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

use new reply object · cpp-redis/cpp_redis@c097dfb · GitHub

Repository navigation

Commit c097dfb

Browse files
Simon Ninon
committed
use new reply object
1 parent 1fadf88 commit c097dfb

30 files changed

Lines changed: 242 additions & 249 deletions

‎examples/redis_client.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ main(void) {
2222
client.connect();
2323

2424
client.send({"SET", "hello", "world"});
25-
client.send({"GET", "hello"}, [] (cpp_redis::replies::reply& reply) {
26-
std::cout << reply.as_bulk_string().str() << std::endl;
25+
client.send({"GET", "hello"}, [] (cpp_redis::reply& reply) {
26+
std::cout << reply.as_string() << std::endl;
2727
});
2828

2929
signal(SIGINT, &sigint_handler);

‎includes/cpp_redis/builders/array_builder.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class array_builder : public builder_iface {
2222
//! builder_iface impl
2323
builder_iface& operator<<(std::string&);
2424
bool reply_ready(void) const;
25-
std::shared_ptr<replies::reply> get_reply(void) const;
25+
reply get_reply(void) const;
2626

2727
private:
2828
bool fetch_array_size(std::string& buffer);
@@ -35,7 +35,7 @@ class array_builder : public builder_iface {
3535
std::unique_ptr<builder_iface> m_current_builder;
3636

3737
bool m_reply_ready;
38-
std::shared_ptr<replies::array_reply> m_reply;
38+
replies::array_reply m_reply;
3939
};
4040

4141
} //! builders

‎includes/cpp_redis/builders/builder_iface.hpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <string>
44
#include <memory>
55

6-
#include "cpp_redis/replies/reply.hpp"
6+
#include "cpp_redis/reply.hpp"
77

88
namespace cpp_redis {
99

@@ -21,8 +21,8 @@ class builder_iface {
2121
//! return whether the reply could be built
2222
virtual bool reply_ready(void) const = 0;
2323

24-
//! return reply object (valid pointer if it is ready, null otherwise)
25-
virtual std::shared_ptr<replies::reply> get_reply(void) const = 0;
24+
//! return reply object
25+
virtual reply get_reply(void) const = 0;
2626
};
2727

2828
} //! builders

‎includes/cpp_redis/builders/bulk_string_builder.hpp‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class bulk_string_builder : public builder_iface {
2222
//! builder_iface impl
2323
builder_iface& operator<<(std::string&);
2424
bool reply_ready(void) const;
25-
std::shared_ptr<replies::reply> get_reply(void) const;
25+
reply get_reply(void) const;
2626

2727
//! getter
2828
const std::string& get_bulk_string(void) const;
@@ -42,8 +42,7 @@ class bulk_string_builder : public builder_iface {
4242
bool m_is_null;
4343

4444
bool m_reply_ready;
45-
46-
std::shared_ptr<replies::bulk_string_reply> m_reply;
45+
replies::bulk_string_reply m_reply;
4746
};
4847

4948
} //! builders

‎includes/cpp_redis/builders/error_builder.hpp‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace builders {
1111
class error_builder : public builder_iface {
1212
public:
1313
//! ctor & dtor
14-
error_builder(void);
14+
error_builder(void) = default;
1515
~error_builder(void) = default;
1616

1717
//! copy ctor & assignment operator
@@ -22,17 +22,14 @@ class error_builder : public builder_iface {
2222
//! builder_iface impl
2323
builder_iface& operator<<(std::string&);
2424
bool reply_ready(void) const;
25-
std::shared_ptr<replies::reply> get_reply(void) const;
25+
reply get_reply(void) const;
2626

2727
//! getter
2828
const std::string& get_error(void) const;
2929

30-
private:
31-
void build_reply(void);
32-
3330
private:
3431
simple_string_builder m_string_builder;
35-
std::shared_ptr<replies::error_reply> m_reply;
32+
replies::error_reply m_reply;
3633
};
3734

3835
} //! builders

‎includes/cpp_redis/builders/integer_builder.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class integer_builder : public builder_iface {
2121
//! builder_iface impl
2222
builder_iface& operator<<(std::string&);
2323
bool reply_ready(void) const;
24-
std::shared_ptr<replies::reply> get_reply(void) const;
24+
reply get_reply(void) const;
2525

2626
//! getter
2727
int get_integer(void) const;
@@ -31,7 +31,7 @@ class integer_builder : public builder_iface {
3131
char m_negative_multiplicator;
3232
bool m_reply_ready;
3333

34-
std::shared_ptr<replies::integer_reply> m_reply;
34+
replies::integer_reply m_reply;
3535
};
3636

3737
} //! builders

‎includes/cpp_redis/builders/reply_builder.hpp‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <memory>
66
#include <deque>
77

8-
#include "cpp_redis/replies/reply.hpp"
8+
#include "cpp_redis/reply.hpp"
99
#include "cpp_redis/builders/builder_iface.hpp"
1010

1111
namespace cpp_redis {
@@ -27,11 +27,12 @@ class reply_builder {
2727
reply_builder& operator<<(const std::string& data);
2828

2929
//! get reply
30-
void operator>>(std::shared_ptr<replies::reply>& reply);
31-
std::shared_ptr<replies::reply> get_reply(void);
30+
void operator>>(reply& reply);
31+
const reply& get_front(void) const;
32+
void pop_front(void);
3233

3334
//! returns whether a reply is available
34-
bool reply_available(void);
35+
bool reply_available(void) const;
3536

3637
private:
3738
//! build reply. Return whether the reply has been fully built or not
@@ -40,7 +41,7 @@ class reply_builder {
4041
private:
4142
std::string m_buffer;
4243
std::unique_ptr<builder_iface> m_builder;
43-
std::deque<std::shared_ptr<replies::reply>> m_available_replies;
44+
std::deque<reply> m_available_replies;
4445
};
4546

4647
} //! builders

‎includes/cpp_redis/builders/simple_string_builder.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class simple_string_builder : public builder_iface {
2323
//! builder_iface impl
2424
builder_iface& operator<<(std::string&);
2525
bool reply_ready(void) const;
26-
std::shared_ptr<replies::reply> get_reply(void) const;
26+
reply get_reply(void) const;
2727

2828
//! getter
2929
const std::string& get_simple_string(void) const;
@@ -32,7 +32,7 @@ class simple_string_builder : public builder_iface {
3232
std::string m_str;
3333
bool m_reply_ready;
3434

35-
std::shared_ptr<replies::simple_string_reply> m_reply;
35+
replies::simple_string_reply m_reply;
3636
};
3737

3838
} //! builders

‎includes/cpp_redis/network/redis_connection.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class redis_connection {
3636
void send(const std::vector<std::string>& redis_cmd);
3737

3838
//! receive handler
39-
typedef std::function<void(redis_connection&, replies::reply&)> reply_callback;
39+
typedef std::function<void(redis_connection&, reply&)> reply_callback;
4040
void set_reply_callback(const reply_callback& handler);
4141

4242
private:

‎includes/cpp_redis/redis_client.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ class redis_client {
3131
void set_disconnection_handler(const disconnection_handler& handler);
3232

3333
//! send cmd
34-
typedef std::function<void(replies::reply&)> reply_callback;
34+
typedef std::function<void(reply&)> reply_callback;
3535
void send(const std::vector<std::string>& redis_cmd, const reply_callback& callback = nullptr);
3636

3737
private:
3838
//! receive & disconnection handlers
39-
void connection_receive_handler(network::redis_connection&, replies::reply& reply);
39+
void connection_receive_handler(network::redis_connection&, reply& reply);
4040
void connection_disconnection_handler(network::redis_connection&);
4141

4242
void clear_callbacks(void);

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL