| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1fadf88 commit c097dfb
30 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,8 +22,8 @@ main(void) { | |||
| 22 | 22 | client.connect(); | |
| 23 | 23 | ||
| 24 | 24 | 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; | ||
| 27 | 27 | }); | |
| 28 | 28 | ||
| 29 | 29 | signal(SIGINT, &sigint_handler); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ class array_builder : public builder_iface { | |||
| 22 | 22 | //! builder_iface impl | |
| 23 | 23 | builder_iface& operator<<(std::string&); | |
| 24 | 24 | bool reply_ready(void) const; | |
| 25 | - std::shared_ptr<replies::reply> get_reply(void) const; | ||
| 25 | + reply get_reply(void) const; | ||
| 26 | 26 | ||
| 27 | 27 | private: | |
| 28 | 28 | bool fetch_array_size(std::string& buffer); | |
@@ -35,7 +35,7 @@ class array_builder : public builder_iface { | |||
| 35 | 35 | std::unique_ptr<builder_iface> m_current_builder; | |
| 36 | 36 | ||
| 37 | 37 | bool m_reply_ready; | |
| 38 | - std::shared_ptr<replies::array_reply> m_reply; | ||
| 38 | + replies::array_reply m_reply; | ||
| 39 | 39 | }; | |
| 40 | 40 | ||
| 41 | 41 | } //! builders | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | #include <string> | |
| 4 | 4 | #include <memory> | |
| 5 | 5 | ||
| 6 | - #include "cpp_redis/replies/reply.hpp" | ||
| 6 | + #include "cpp_redis/reply.hpp" | ||
| 7 | 7 | ||
| 8 | 8 | namespace cpp_redis { | |
| 9 | 9 | ||
@@ -21,8 +21,8 @@ class builder_iface { | |||
| 21 | 21 | //! return whether the reply could be built | |
| 22 | 22 | virtual bool reply_ready(void) const = 0; | |
| 23 | 23 | ||
| 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; | ||
| 26 | 26 | }; | |
| 27 | 27 | ||
| 28 | 28 | } //! builders | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ class bulk_string_builder : public builder_iface { | |||
| 22 | 22 | //! builder_iface impl | |
| 23 | 23 | builder_iface& operator<<(std::string&); | |
| 24 | 24 | bool reply_ready(void) const; | |
| 25 | - std::shared_ptr<replies::reply> get_reply(void) const; | ||
| 25 | + reply get_reply(void) const; | ||
| 26 | 26 | ||
| 27 | 27 | //! getter | |
| 28 | 28 | const std::string& get_bulk_string(void) const; | |
@@ -42,8 +42,7 @@ class bulk_string_builder : public builder_iface { | |||
| 42 | 42 | bool m_is_null; | |
| 43 | 43 | ||
| 44 | 44 | bool m_reply_ready; | |
| 45 | - | ||
| 46 | - std::shared_ptr<replies::bulk_string_reply> m_reply; | ||
| 45 | + replies::bulk_string_reply m_reply; | ||
| 47 | 46 | }; | |
| 48 | 47 | ||
| 49 | 48 | } //! builders | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ namespace builders { | |||
| 11 | 11 | class error_builder : public builder_iface { | |
| 12 | 12 | public: | |
| 13 | 13 | //! ctor & dtor | |
| 14 | - error_builder(void); | ||
| 14 | + error_builder(void) = default; | ||
| 15 | 15 | ~error_builder(void) = default; | |
| 16 | 16 | ||
| 17 | 17 | //! copy ctor & assignment operator | |
@@ -22,17 +22,14 @@ class error_builder : public builder_iface { | |||
| 22 | 22 | //! builder_iface impl | |
| 23 | 23 | builder_iface& operator<<(std::string&); | |
| 24 | 24 | bool reply_ready(void) const; | |
| 25 | - std::shared_ptr<replies::reply> get_reply(void) const; | ||
| 25 | + reply get_reply(void) const; | ||
| 26 | 26 | ||
| 27 | 27 | //! getter | |
| 28 | 28 | const std::string& get_error(void) const; | |
| 29 | 29 | ||
| 30 | - private: | ||
| 31 | - void build_reply(void); | ||
| 32 | - | ||
| 33 | 30 | private: | |
| 34 | 31 | simple_string_builder m_string_builder; | |
| 35 | - std::shared_ptr<replies::error_reply> m_reply; | ||
| 32 | + replies::error_reply m_reply; | ||
| 36 | 33 | }; | |
| 37 | 34 | ||
| 38 | 35 | } //! builders | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,7 @@ class integer_builder : public builder_iface { | |||
| 21 | 21 | //! builder_iface impl | |
| 22 | 22 | builder_iface& operator<<(std::string&); | |
| 23 | 23 | bool reply_ready(void) const; | |
| 24 | - std::shared_ptr<replies::reply> get_reply(void) const; | ||
| 24 | + reply get_reply(void) const; | ||
| 25 | 25 | ||
| 26 | 26 | //! getter | |
| 27 | 27 | int get_integer(void) const; | |
@@ -31,7 +31,7 @@ class integer_builder : public builder_iface { | |||
| 31 | 31 | char m_negative_multiplicator; | |
| 32 | 32 | bool m_reply_ready; | |
| 33 | 33 | ||
| 34 | - std::shared_ptr<replies::integer_reply> m_reply; | ||
| 34 | + replies::integer_reply m_reply; | ||
| 35 | 35 | }; | |
| 36 | 36 | ||
| 37 | 37 | } //! builders | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ | |||
| 5 | 5 | #include <memory> | |
| 6 | 6 | #include <deque> | |
| 7 | 7 | ||
| 8 | - #include "cpp_redis/replies/reply.hpp" | ||
| 8 | + #include "cpp_redis/reply.hpp" | ||
| 9 | 9 | #include "cpp_redis/builders/builder_iface.hpp" | |
| 10 | 10 | ||
| 11 | 11 | namespace cpp_redis { | |
@@ -27,11 +27,12 @@ class reply_builder { | |||
| 27 | 27 | reply_builder& operator<<(const std::string& data); | |
| 28 | 28 | ||
| 29 | 29 | //! 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); | ||
| 32 | 33 | ||
| 33 | 34 | //! returns whether a reply is available | |
| 34 | - bool reply_available(void); | ||
| 35 | + bool reply_available(void) const; | ||
| 35 | 36 | ||
| 36 | 37 | private: | |
| 37 | 38 | //! build reply. Return whether the reply has been fully built or not | |
@@ -40,7 +41,7 @@ class reply_builder { | |||
| 40 | 41 | private: | |
| 41 | 42 | std::string m_buffer; | |
| 42 | 43 | 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; | ||
| 44 | 45 | }; | |
| 45 | 46 | ||
| 46 | 47 | } //! builders | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,7 @@ class simple_string_builder : public builder_iface { | |||
| 23 | 23 | //! builder_iface impl | |
| 24 | 24 | builder_iface& operator<<(std::string&); | |
| 25 | 25 | bool reply_ready(void) const; | |
| 26 | - std::shared_ptr<replies::reply> get_reply(void) const; | ||
| 26 | + reply get_reply(void) const; | ||
| 27 | 27 | ||
| 28 | 28 | //! getter | |
| 29 | 29 | const std::string& get_simple_string(void) const; | |
@@ -32,7 +32,7 @@ class simple_string_builder : public builder_iface { | |||
| 32 | 32 | std::string m_str; | |
| 33 | 33 | bool m_reply_ready; | |
| 34 | 34 | ||
| 35 | - std::shared_ptr<replies::simple_string_reply> m_reply; | ||
| 35 | + replies::simple_string_reply m_reply; | ||
| 36 | 36 | }; | |
| 37 | 37 | ||
| 38 | 38 | } //! builders | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ class redis_connection { | |||
| 36 | 36 | void send(const std::vector<std::string>& redis_cmd); | |
| 37 | 37 | ||
| 38 | 38 | //! receive handler | |
| 39 | - typedef std::function<void(redis_connection&, replies::reply&)> reply_callback; | ||
| 39 | + typedef std::function<void(redis_connection&, reply&)> reply_callback; | ||
| 40 | 40 | void set_reply_callback(const reply_callback& handler); | |
| 41 | 41 | ||
| 42 | 42 | private: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,12 +31,12 @@ class redis_client { | |||
| 31 | 31 | void set_disconnection_handler(const disconnection_handler& handler); | |
| 32 | 32 | ||
| 33 | 33 | //! send cmd | |
| 34 | - typedef std::function<void(replies::reply&)> reply_callback; | ||
| 34 | + typedef std::function<void(reply&)> reply_callback; | ||
| 35 | 35 | void send(const std::vector<std::string>& redis_cmd, const reply_callback& callback = nullptr); | |
| 36 | 36 | ||
| 37 | 37 | private: | |
| 38 | 38 | //! receive & disconnection handlers | |
| 39 | - void connection_receive_handler(network::redis_connection&, replies::reply& reply); | ||
| 39 | + void connection_receive_handler(network::redis_connection&, reply& reply); | ||
| 40 | 40 | void connection_disconnection_handler(network::redis_connection&); | |
| 41 | 41 | ||
| 42 | 42 | void clear_callbacks(void); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments