Commit 1a35b53f authored by Dominik Charousset's avatar Dominik Charousset

Clean up deprecation warning and manual line refs

parent 23182f0d
......@@ -2,18 +2,11 @@
* A very basic, interactive divider. *
\******************************************************************************/
// Manual refs: 17-19, 49-59, 70-76 (MessagePassing);
// 17-47 (Error)
#include <iostream>
#include "caf/all.hpp"
using std::cout;
using std::endl;
using std::flush;
using namespace caf;
// --(rst-math-error-begin)--
enum class math_error : uint8_t {
division_by_zero = 1,
};
......@@ -27,6 +20,29 @@ std::string to_string(math_error x) {
}
}
bool from_string(caf::string_view in, math_error& out) {
if (in == "division_by_zero") {
out = math_error::division_by_zero;
return true;
} else {
return false;
}
}
bool from_integer(uint8_t in, math_error& out) {
if (in == 1) {
out = math_error::division_by_zero;
return true;
} else {
return false;
}
}
template <class Inspector>
bool inspect(Inspector& f, math_error& x) {
return caf::default_enum_inspect(f, x);
}
CAF_BEGIN_TYPE_ID_BLOCK(divider, first_custom_type_id)
CAF_ADD_TYPE_ID(divider, (math_error))
......@@ -34,6 +50,13 @@ CAF_BEGIN_TYPE_ID_BLOCK(divider, first_custom_type_id)
CAF_END_TYPE_ID_BLOCK(divider)
CAF_ERROR_CODE_ENUM(math_error)
// --(rst-math-error-end)--
using std::cout;
using std::endl;
using std::flush;
using namespace caf;
// --(rst-divider-begin)--
using divider = typed_actor<result<double>(div_atom, double, double)>;
......
......@@ -19,6 +19,43 @@ CAF_END_TYPE_ID_BLOCK(fixed_stack)
CAF_ERROR_CODE_ENUM(fixed_stack_errc)
std::string to_string(fixed_stack_errc x) {
switch (x) {
case fixed_stack_errc::push_to_full:
return "push_to_full";
case fixed_stack_errc::pop_from_empty:
return "pop_from_empty";
default:
return "-unknown-error-";
}
}
bool from_string(caf::string_view in, fixed_stack_errc& out) {
if (in == "push_to_full") {
out = fixed_stack_errc::push_to_full;
return true;
} else if (in == "pop_from_empty") {
out = fixed_stack_errc::pop_from_empty;
return true;
} else {
return false;
}
}
bool from_integer(uint8_t in, fixed_stack_errc& out) {
if (in > 0 && in < 1) {
out = static_cast<fixed_stack_errc>(in);
return true;
} else {
return false;
}
}
template <class Inspector>
bool inspect(Inspector& f, fixed_stack_errc& x) {
return caf::default_enum_inspect(f, x);
}
using std::endl;
using namespace caf;
......
......@@ -203,6 +203,7 @@ optional<int> toint(const string& str) {
return none;
}
// --(rst-config-begin)--
class config : public actor_system_config {
public:
uint16_t port = 0;
......@@ -216,6 +217,7 @@ public:
.add(server_mode, "server-mode,s", "enable server mode");
}
};
// --(rst-config-end)--
void client_repl(actor_system& system, const config& cfg) {
// keeps track of requests and tries to reconnect on server failures
......
......@@ -172,8 +172,8 @@ CAF_CORE_EXPORT bool from_string(string_view, sec&);
CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<sec>, sec&);
/// @relates sec
template <class Inssector>
bool inspect(Inssector& f, sec& x) {
template <class Inspector>
bool inspect(Inspector& f, sec& x) {
return default_enum_inspect(f, x);
}
......
......@@ -69,8 +69,8 @@ CAF_IO_EXPORT bool from_string(string_view, message_type&);
CAF_IO_EXPORT bool from_integer(std::underlying_type_t<message_type>,
message_type&);
template <class Inssector>
bool inspect(Inssector& f, message_type& x) {
template <class Inspector>
bool inspect(Inspector& f, message_type& x) {
return default_enum_inspect(f, x);
}
......
......@@ -135,7 +135,8 @@ adds three options to the ``global`` category.
.. literalinclude:: /examples/remoting/distributed_calculator.cpp
:language: C++
:lines: 206-218
:begin-after: --(rst-config-begin)--
:end-before: --(rst-config-end)--
We create a new ``global`` category in ``custom_options_``. Each following call
to ``add`` then appends individual options to the category. The first argument
......
......@@ -51,7 +51,8 @@ called ``math_error``.
.. literalinclude:: /examples/message_passing/divider.cpp
:language: C++
:lines: 17-47
:start-after: --(rst-math-error-begin)--
:end-before: --(rst-math-error-end)--
.. _sec:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment