aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/deps/0001-rpclib-replace-fmt-with-boost-format-but-leave-it-in.patch
blob: 0d3bddc20aeef63c5fe6155bef40a4581f97e576 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
From 74505c84e326f8524a374911fcfe5dc29426a274 Mon Sep 17 00:00:00 2001
From: Andrej Rode <andrej.rode@ettus.com>
Date: Thu, 6 Apr 2017 15:53:37 -0700
Subject: [PATCH 1/3] rpclib: replace fmt with boost::format (but leave it in
 logging)

Signed-off-by: Andrej Rode <andrej.rode@ettus.com>
---
 lib/rpc/client.cc              |  6 +++---
 lib/rpc/detail/client_error.cc |  6 +++---
 lib/rpc/dispatcher.cc          | 30 +++++++++++++++---------------
 lib/rpc/rpc_error.cc           |  4 ++--
 4 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/lib/rpc/client.cc b/lib/rpc/client.cc
index 5ab9780..e5d0117 100644
--- a/lib/rpc/client.cc
+++ b/lib/rpc/client.cc
@@ -11,7 +11,7 @@
 #include <unordered_map>
 
 #include "asio.hpp"
-#include "format.h"
+#include <boost/format.hpp>
 
 #include "rpc/detail/async_writer.h"
 #include "rpc/detail/dev_utils.h"
@@ -212,8 +212,8 @@ void client::wait_all_responses() {
 
 RPCLIB_NORETURN void client::throw_timeout(std::string const& func_name) {
     throw rpc::timeout(
-        RPCLIB_FMT::format("Timeout of {}ms while calling RPC function '{}'",
-                           get_timeout(), func_name));
+        str(boost::format("Timeout of %dms while calling RPC function '%s'") %
+                           get_timeout() % func_name));
 }
 
 client::~client() {
diff --git a/lib/rpc/detail/client_error.cc b/lib/rpc/detail/client_error.cc
index 263141f..deea2f6 100644
--- a/lib/rpc/detail/client_error.cc
+++ b/lib/rpc/detail/client_error.cc
@@ -1,4 +1,4 @@
-#include "format.h"
+#include <boost/format.hpp>
 
 #include "rpc/detail/client_error.h"
 
@@ -6,8 +6,8 @@ namespace rpc {
 namespace detail {
 
 client_error::client_error(code c, const std::string &msg)
-    : what_(RPCLIB_FMT::format("client error C{0:04x}: {1}",
-                               static_cast<uint16_t>(c), msg)) {}
+    : what_(str(boost::format("client error C%d: %") %
+                               static_cast<uint16_t>(c) % msg)) {}
 
 const char *client_error::what() const noexcept { return what_.c_str(); }
 }
diff --git a/lib/rpc/dispatcher.cc b/lib/rpc/dispatcher.cc
index e8954b8..c502b80 100644
--- a/lib/rpc/dispatcher.cc
+++ b/lib/rpc/dispatcher.cc
@@ -1,5 +1,5 @@
 #include "rpc/dispatcher.h"
-#include "format.h"
+#include <boost/format.hpp>
 #include "rpc/detail/client_error.h"
 #include "rpc/this_handler.h"
 
@@ -48,18 +48,18 @@ response dispatcher::dispatch_call(RPCLIB_MSGPACK::object const &msg,
             return response::make_result(id, std::move(result));
         } catch (rpc::detail::client_error &e) {
             return response::make_error(
-                id, RPCLIB_FMT::format("rpclib: {}", e.what()));
+                id, str(boost::format("rpclib: %s") % e.what()));
         } catch (std::exception &e) {
             if (!suppress_exceptions) {
                 throw;
             }
             return response::make_error(
                 id,
-                RPCLIB_FMT::format("rpclib: function '{0}' (called with {1} "
+                str(boost::format("rpclib: function '%s' (called with %d "
                                    "arg(s)) "
                                    "threw an exception. The exception "
-                                   "contained this information: {2}.",
-                                   name, args.via.array.size, e.what()));
+                              "contained this information: %s.") %
+                                   name % args.via.array.size % e.what()));
         } catch (rpc::detail::handler_error &) {
             // doing nothing, the exception was only thrown to
             // return immediately
@@ -72,17 +72,17 @@ response dispatcher::dispatch_call(RPCLIB_MSGPACK::object const &msg,
             }
             return response::make_error(
                 id,
-                RPCLIB_FMT::format("rpclib: function '{0}' (called with {1} "
+                str(boost::format("rpclib: function '%s' (called with %d "
                                    "arg(s)) threw an exception. The exception "
                                    "is not derived from std::exception. No "
-                                   "further information available.",
-                                   name, args.via.array.size));
+                              "further information available.") %
+                                   name % args.via.array.size));
         }
     }
     return response::make_error(
-        id, RPCLIB_FMT::format("rpclib: server could not find "
-                               "function '{0}' with argument count {1}.",
-                               name, args.via.array.size));
+        id, str(boost::format("rpclib: server could not find "
+                          "function '%s' with argument count %d.") %
+                               name % args.via.array.size));
 }
 
 response dispatcher::dispatch_notification(RPCLIB_MSGPACK::object const &msg,
@@ -124,10 +124,10 @@ void dispatcher::enforce_arg_count(std::string const &func, std::size_t found,
     if (found != expected) {
         throw client_error(
             client_error::code::wrong_arity,
-            RPCLIB_FMT::format(
-                "Function '{0}' was called with an invalid number of "
-                "arguments. Expected: {1}, got: {2}",
-                func, expected, found));
+            str(boost::format(
+                "Function '%s' was called with an invalid number of "
+                "arguments. Expected: %d, got: %d") %
+                func % expected % found));
     }
 }
 
diff --git a/lib/rpc/rpc_error.cc b/lib/rpc/rpc_error.cc
index 8af7006..dcf3c1c 100644
--- a/lib/rpc/rpc_error.cc
+++ b/lib/rpc/rpc_error.cc
@@ -1,5 +1,5 @@
 #include "rpc/rpc_error.h"
-#include "format.h"
+#include <boost/format.hpp>
 
 namespace rpc {
 
@@ -16,7 +16,7 @@ RPCLIB_MSGPACK::object_handle &rpc_error::get_error() { return ob_h_; }
 
 timeout::timeout(std::string const &what_arg) : std::runtime_error(what_arg) {
     formatted =
-        RPCLIB_FMT::format("rpc::timeout: {}", std::runtime_error::what());
+        str(boost::format("rpc::timeout: %s") % std::runtime_error::what());
 }
 
 const char *timeout::what() const noexcept { return formatted.data(); }
-- 
2.10.2