Unverified Commit cfeb9105 authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #1326

CAF 0.19 API cleanup
parents 11a1b0f9 c04cd0b6
...@@ -12,6 +12,27 @@ is based on [Keep a Changelog](https://keepachangelog.com). ...@@ -12,6 +12,27 @@ is based on [Keep a Changelog](https://keepachangelog.com).
destructor of the promise now checks for this case. destructor of the promise now checks for this case.
- Accessing URI fields now always returns the normalized string. - Accessing URI fields now always returns the normalized string.
### Changed
- Remote spawning of actors is no longer considered experimental.
### Deprecated
- The obsolete meta-programming utilities `replies_to` and `reacts_to` no longer
serve any purpose and are thus deprecated.
- The types `caf::byte`, `caf::optional` and `caf::string_view` became obsolete
after switching to C++17. Consequently, these types are now deprecated in
favor of their standard library counterpart.
### Removed
- The template type `caf::variant` also became obsolete when switching to C++17.
Unfortunately, the implementation was not as standalone as its deprecated
companions and some of the free functions like `holds_alternative` were too
greedy and did not play nicely with ADL when using `std::variant` in the same
code base. Since fixing `caf::variant` does not seem to be worth the time
investment, we remove this type without a deprecation cycle.
## [0.18.6] ## [0.18.6]
### Added ### Added
......
...@@ -37,13 +37,13 @@ macro(write_enum_file) ...@@ -37,13 +37,13 @@ macro(write_enum_file)
# File header and includes. # File header and includes.
list(APPEND out list(APPEND out
"#include \"caf/config.hpp\"\n" "#include \"caf/config.hpp\"\n"
"#include \"caf/string_view.hpp\"\n"
"\n" "\n"
"CAF_PUSH_DEPRECATED_WARNING\n" "CAF_PUSH_DEPRECATED_WARNING\n"
"\n" "\n"
"#include \"${namespace_path}/${enum_name}.hpp\"\n" "#include \"${namespace_path}/${enum_name}.hpp\"\n"
"\n" "\n"
"#include <string>\n" "#include <string>\n"
"#include <string_view>\n"
"\n" "\n"
"namespace ${namespace_str} {\n" "namespace ${namespace_str} {\n"
"\n") "\n")
...@@ -64,7 +64,7 @@ macro(write_enum_file) ...@@ -64,7 +64,7 @@ macro(write_enum_file)
"\n") "\n")
# Generate from_string implementation. # Generate from_string implementation.
list(APPEND out list(APPEND out
"bool from_string(string_view in, ${enum_name}& out) {\n") "bool from_string(std::string_view in, ${enum_name}& out) {\n")
foreach(label IN LISTS enum_values) foreach(label IN LISTS enum_values)
list(APPEND out list(APPEND out
" if (in == \"${namespace_str}::${enum_name}::${label}\") {\n" " if (in == \"${namespace_str}::${enum_name}::${label}\") {\n"
......
...@@ -20,7 +20,7 @@ std::string to_string(math_error x) { ...@@ -20,7 +20,7 @@ std::string to_string(math_error x) {
} }
} }
bool from_string(caf::string_view in, math_error& out) { bool from_string(std::string_view in, math_error& out) {
if (in == "division_by_zero") { if (in == "division_by_zero") {
out = math_error::division_by_zero; out = math_error::division_by_zero;
return true; return true;
......
...@@ -30,7 +30,7 @@ std::string to_string(fixed_stack_errc x) { ...@@ -30,7 +30,7 @@ std::string to_string(fixed_stack_errc x) {
} }
} }
bool from_string(caf::string_view in, fixed_stack_errc& out) { bool from_string(std::string_view in, fixed_stack_errc& out) {
if (in == "push_to_full") { if (in == "push_to_full") {
out = fixed_stack_errc::push_to_full; out = fixed_stack_errc::push_to_full;
return true; return true;
......
#include <string> #include <string>
#include <string_view>
#include <utility> #include <utility>
#include "caf/all.hpp" #include "caf/all.hpp"
...@@ -74,7 +75,7 @@ void ChatWidget::sendChatMessage() { ...@@ -74,7 +75,7 @@ void ChatWidget::sendChatMessage() {
} else if (line.startsWith('/')) { } else if (line.startsWith('/')) {
vector<string> words; vector<string> words;
auto utf8 = QStringView{line}.mid(1).toUtf8(); auto utf8 = QStringView{line}.mid(1).toUtf8();
auto sv = caf::string_view{utf8.constData(), auto sv = std::string_view{utf8.constData(),
static_cast<size_t>(utf8.size())}; static_cast<size_t>(utf8.size())};
split(words, sv, is_any_of(" ")); split(words, sv, is_any_of(" "));
if (words.size() == 3 && words[0] == "join") { if (words.size() == 3 && words[0] == "join") {
......
...@@ -70,7 +70,7 @@ namespace client { ...@@ -70,7 +70,7 @@ namespace client {
// a simple calculator task: operation + operands // a simple calculator task: operation + operands
struct task { struct task {
caf::variant<add_atom, sub_atom> op; std::variant<add_atom, sub_atom> op;
int lhs; int lhs;
int rhs; int rhs;
}; };
...@@ -170,7 +170,7 @@ behavior running(stateful_actor<state>* self, const actor& calculator) { ...@@ -170,7 +170,7 @@ behavior running(stateful_actor<state>* self, const actor& calculator) {
}; };
for (auto& x : self->state.tasks) { for (auto& x : self->state.tasks) {
auto f = [&](auto op) { send_task(op, x.lhs, x.rhs); }; auto f = [&](auto op) { send_task(op, x.lhs, x.rhs); };
caf::visit(f, x.op); std::visit(f, x.op);
} }
self->state.tasks.clear(); self->state.tasks.clear();
return { return {
...@@ -195,12 +195,12 @@ string trim(std::string s) { ...@@ -195,12 +195,12 @@ string trim(std::string s) {
} }
// tries to convert `str` to an int // tries to convert `str` to an int
optional<int> toint(const string& str) { std::optional<int> toint(const string& str) {
char* end; char* end;
auto result = static_cast<int>(strtol(str.c_str(), &end, 10)); auto result = static_cast<int>(strtol(str.c_str(), &end, 10));
if (end == str.c_str() + str.size()) if (end == str.c_str() + str.size())
return result; return result;
return none; return std::nullopt;
} }
// --(rst-config-begin)-- // --(rst-config-begin)--
......
...@@ -81,12 +81,12 @@ void client_repl(function_view<calculator> f) { ...@@ -81,12 +81,12 @@ void client_repl(function_view<calculator> f) {
usage(); usage();
continue; continue;
} }
auto to_int32_t = [](const string& str) -> optional<int32_t> { auto to_int32_t = [](const string& str) -> std::optional<int32_t> {
char* end = nullptr; char* end = nullptr;
auto res = strtol(str.c_str(), &end, 10); auto res = strtol(str.c_str(), &end, 10);
if (end == str.c_str() + str.size()) if (end == str.c_str() + str.size())
return static_cast<int32_t>(res); return static_cast<int32_t>(res);
return none; return std::nullopt;
}; };
auto x = to_int32_t(words[0]); auto x = to_int32_t(words[0]);
auto y = to_int32_t(words[2]); auto y = to_int32_t(words[2]);
......
...@@ -228,7 +228,6 @@ caf_add_component( ...@@ -228,7 +228,6 @@ caf_add_component(
binary_deserializer binary_deserializer
binary_serializer binary_serializer
blocking_actor blocking_actor
byte
composition composition
config_option config_option
config_option_set config_option_set
...@@ -344,7 +343,6 @@ caf_add_component( ...@@ -344,7 +343,6 @@ caf_add_component(
stateful_actor stateful_actor
string_algorithms string_algorithms
string_view string_view
sum_type
telemetry.collector.prometheus telemetry.collector.prometheus
telemetry.counter telemetry.counter
telemetry.gauge telemetry.gauge
...@@ -361,8 +359,7 @@ caf_add_component( ...@@ -361,8 +359,7 @@ caf_add_component(
typed_spawn typed_spawn
unit unit
uri uri
uuid uuid)
variant)
if(CAF_ENABLE_TESTING AND CAF_ENABLE_EXCEPTIONS) if(CAF_ENABLE_TESTING AND CAF_ENABLE_EXCEPTIONS)
caf_add_test_suites(caf-core-test custom_exception_handler) caf_add_test_suites(caf-core-test custom_exception_handler)
......
...@@ -64,8 +64,8 @@ struct typed_mpi_access<result<Out...>(In...)> { ...@@ -64,8 +64,8 @@ struct typed_mpi_access<result<Out...>(In...)> {
std::string operator()() const { std::string operator()() const {
static_assert(sizeof...(In) > 0, "typed MPI without inputs"); static_assert(sizeof...(In) > 0, "typed MPI without inputs");
static_assert(sizeof...(Out) > 0, "typed MPI without outputs"); static_assert(sizeof...(Out) > 0, "typed MPI without outputs");
std::vector<std::string> inputs{to_string(type_name_v<In>)...}; std::vector<std::string> inputs{std::string{type_name_v<In>}...};
std::vector<std::string> outputs1{to_string(type_name_v<Out>)...}; std::vector<std::string> outputs1{std::string{type_name_v<Out>}...};
std::string result = "("; std::string result = "(";
result += join(inputs, ","); result += join(inputs, ",");
result += ") -> ("; result += ") -> (";
...@@ -85,8 +85,8 @@ std::string get_rtti_from_mpi() { ...@@ -85,8 +85,8 @@ std::string get_rtti_from_mpi() {
namespace caf { namespace caf {
/// Actor environment including scheduler, registry, and optional components /// Actor environment including scheduler, registry, and optional
/// such as a middleman. /// components such as a middleman.
class CAF_CORE_EXPORT actor_system { class CAF_CORE_EXPORT actor_system {
public: public:
friend class logger; friend class logger;
...@@ -146,7 +146,8 @@ public: ...@@ -146,7 +146,8 @@ public:
using module_array = std::array<module_ptr, module::num_ids>; using module_array = std::array<module_ptr, module::num_ids>;
/// An (optional) component of the actor system with networking capabilities. /// An (optional) component of the actor system with networking
/// capabilities.
class CAF_CORE_EXPORT networking_module : public module { class CAF_CORE_EXPORT networking_module : public module {
public: public:
~networking_module() override; ~networking_module() override;
...@@ -744,7 +745,7 @@ private: ...@@ -744,7 +745,7 @@ private:
expected<strong_actor_ptr> expected<strong_actor_ptr>
dyn_spawn_impl(const std::string& name, message& args, execution_unit* ctx, dyn_spawn_impl(const std::string& name, message& args, execution_unit* ctx,
bool check_interface, optional<const mpi&> expected_ifs); bool check_interface, const mpi* expected_ifs);
/// Sets the internal actor for dynamic spawn operations. /// Sets the internal actor for dynamic spawn operations.
void spawn_serv(strong_actor_ptr x) { void spawn_serv(strong_actor_ptr x) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <string> #include <string>
#include <string_view>
#include <type_traits> #include <type_traits>
#include <typeindex> #include <typeindex>
#include <unordered_map> #include <unordered_map>
...@@ -83,7 +84,7 @@ public: ...@@ -83,7 +84,7 @@ public:
/// Sets a config by using its name `config_name` to `config_value`. /// Sets a config by using its name `config_name` to `config_value`.
template <class T> template <class T>
actor_system_config& set(string_view name, T&& value) { actor_system_config& set(std::string_view name, T&& value) {
return set_impl(name, config_value{std::forward<T>(value)}); return set_impl(name, config_value{std::forward<T>(value)});
} }
...@@ -308,7 +309,7 @@ private: ...@@ -308,7 +309,7 @@ private:
mutable std::vector<char*> c_args_remainder_; mutable std::vector<char*> c_args_remainder_;
std::vector<char> c_args_remainder_buf_; std::vector<char> c_args_remainder_buf_;
actor_system_config& set_impl(string_view name, config_value value); actor_system_config& set_impl(std::string_view name, config_value value);
std::pair<error, std::string> extract_config_file_path(string_list& args); std::pair<error, std::string> extract_config_file_path(string_list& args);
}; };
...@@ -319,28 +320,28 @@ CAF_CORE_EXPORT const settings& content(const actor_system_config& cfg); ...@@ -319,28 +320,28 @@ CAF_CORE_EXPORT const settings& content(const actor_system_config& cfg);
/// Returns whether `xs` associates a value of type `T` to `name`. /// Returns whether `xs` associates a value of type `T` to `name`.
/// @relates actor_system_config /// @relates actor_system_config
template <class T> template <class T>
bool holds_alternative(const actor_system_config& cfg, string_view name) { bool holds_alternative(const actor_system_config& cfg, std::string_view name) {
return holds_alternative<T>(content(cfg), name); return holds_alternative<T>(content(cfg), name);
} }
/// Tries to retrieve the value associated to `name` from `cfg`. /// Tries to retrieve the value associated to `name` from `cfg`.
/// @relates actor_system_config /// @relates actor_system_config
template <class T> template <class T>
auto get_if(const actor_system_config* cfg, string_view name) { auto get_if(const actor_system_config* cfg, std::string_view name) {
return get_if<T>(&content(*cfg), name); return get_if<T>(&content(*cfg), name);
} }
/// Retrieves the value associated to `name` from `cfg`. /// Retrieves the value associated to `name` from `cfg`.
/// @relates actor_system_config /// @relates actor_system_config
template <class T> template <class T>
T get(const actor_system_config& cfg, string_view name) { T get(const actor_system_config& cfg, std::string_view name) {
return get<T>(content(cfg), name); return get<T>(content(cfg), name);
} }
/// Retrieves the value associated to `name` from `cfg` or returns `fallback`. /// Retrieves the value associated to `name` from `cfg` or returns `fallback`.
/// @relates actor_system_config /// @relates actor_system_config
template <class To = get_or_auto_deduce, class Fallback> template <class To = get_or_auto_deduce, class Fallback>
auto get_or(const actor_system_config& cfg, string_view name, auto get_or(const actor_system_config& cfg, std::string_view name,
Fallback&& fallback) { Fallback&& fallback) {
return get_or<To>(content(cfg), name, std::forward<Fallback>(fallback)); return get_or<To>(content(cfg), name, std::forward<Fallback>(fallback));
} }
...@@ -349,7 +350,7 @@ auto get_or(const actor_system_config& cfg, string_view name, ...@@ -349,7 +350,7 @@ auto get_or(const actor_system_config& cfg, string_view name,
/// of type `T`. /// of type `T`.
/// @relates actor_system_config /// @relates actor_system_config
template <class T> template <class T>
expected<T> get_as(const actor_system_config& cfg, string_view name) { expected<T> get_as(const actor_system_config& cfg, std::string_view name) {
return get_as<T>(content(cfg), name); return get_as<T>(content(cfg), name);
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "caf/binary_deserializer.hpp" #include "caf/binary_deserializer.hpp"
#include "caf/binary_serializer.hpp" #include "caf/binary_serializer.hpp"
#include "caf/blocking_actor.hpp" #include "caf/blocking_actor.hpp"
#include "caf/byte.hpp"
#include "caf/byte_buffer.hpp" #include "caf/byte_buffer.hpp"
#include "caf/byte_span.hpp" #include "caf/byte_span.hpp"
#include "caf/caf_main.hpp" #include "caf/caf_main.hpp"
...@@ -59,6 +60,7 @@ ...@@ -59,6 +60,7 @@
#include "caf/message_priority.hpp" #include "caf/message_priority.hpp"
#include "caf/mtl.hpp" #include "caf/mtl.hpp"
#include "caf/node_id.hpp" #include "caf/node_id.hpp"
#include "caf/optional.hpp"
#include "caf/others.hpp" #include "caf/others.hpp"
#include "caf/proxy_registry.hpp" #include "caf/proxy_registry.hpp"
#include "caf/raise_error.hpp" #include "caf/raise_error.hpp"
...@@ -75,6 +77,7 @@ ...@@ -75,6 +77,7 @@
#include "caf/skip.hpp" #include "caf/skip.hpp"
#include "caf/spawn_options.hpp" #include "caf/spawn_options.hpp"
#include "caf/stateful_actor.hpp" #include "caf/stateful_actor.hpp"
#include "caf/string_view.hpp"
#include "caf/system_messages.hpp" #include "caf/system_messages.hpp"
#include "caf/term.hpp" #include "caf/term.hpp"
#include "caf/thread_hook.hpp" #include "caf/thread_hook.hpp"
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <memory> #include <memory>
#include "caf/async/fwd.hpp" #include "caf/async/fwd.hpp"
#include "caf/byte.hpp"
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
...@@ -40,7 +39,7 @@ public: ...@@ -40,7 +39,7 @@ public:
template <class T> template <class T>
friend batch make_batch(span<const T> items); friend batch make_batch(span<const T> items);
using item_destructor = void (*)(type_id_t, uint16_t, size_t, byte*); using item_destructor = void (*)(type_id_t, uint16_t, size_t, std::byte*);
batch() = default; batch() = default;
batch(batch&&) = default; batch(batch&&) = default;
...@@ -143,11 +142,11 @@ private: ...@@ -143,11 +142,11 @@ private:
return size_; return size_;
} }
byte* storage() noexcept { std::byte* storage() noexcept {
return storage_; return storage_;
} }
const byte* storage() const noexcept { const std::byte* storage() const noexcept {
return storage_; return storage_;
} }
...@@ -176,7 +175,7 @@ private: ...@@ -176,7 +175,7 @@ private:
type_id_t item_type_; type_id_t item_type_;
uint16_t item_size_; uint16_t item_size_;
size_t size_; size_t size_;
byte storage_[]; std::byte storage_[];
}; };
explicit batch(intrusive_ptr<data> ptr) : data_(std::move(ptr)) { explicit batch(intrusive_ptr<data> ptr) : data_(std::move(ptr)) {
...@@ -205,7 +204,8 @@ batch make_batch(span<const T> items) { ...@@ -205,7 +204,8 @@ batch make_batch(span<const T> items) {
auto vptr = malloc(total_size); auto vptr = malloc(total_size);
if (vptr == nullptr) if (vptr == nullptr)
CAF_RAISE_ERROR(std::bad_alloc, "make_batch"); CAF_RAISE_ERROR(std::bad_alloc, "make_batch");
auto destroy_items = [](type_id_t, uint16_t, size_t size, byte* storage) { auto destroy_items = [](type_id_t, uint16_t, size_t size,
std::byte* storage) {
auto ptr = reinterpret_cast<T*>(storage); auto ptr = reinterpret_cast<T*>(storage);
std::destroy(ptr, ptr + size); std::destroy(ptr, ptr + size);
}; };
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "caf/default_enum_inspect.hpp" #include "caf/default_enum_inspect.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include <string_view>
#include <type_traits> #include <type_traits>
namespace caf::async { namespace caf::async {
...@@ -27,7 +28,7 @@ enum class read_result { ...@@ -27,7 +28,7 @@ enum class read_result {
CAF_CORE_EXPORT std::string to_string(read_result); CAF_CORE_EXPORT std::string to_string(read_result);
/// @relates read_result /// @relates read_result
CAF_CORE_EXPORT bool from_string(string_view, read_result&); CAF_CORE_EXPORT bool from_string(std::string_view, read_result&);
/// @relates read_result /// @relates read_result
CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<read_result>, CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<read_result>,
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "caf/default_enum_inspect.hpp" #include "caf/default_enum_inspect.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include <string_view>
#include <type_traits> #include <type_traits>
namespace caf::async { namespace caf::async {
...@@ -28,7 +29,7 @@ enum class write_result { ...@@ -28,7 +29,7 @@ enum class write_result {
CAF_CORE_EXPORT std::string to_string(write_result); CAF_CORE_EXPORT std::string to_string(write_result);
/// @relates write_result /// @relates write_result
CAF_CORE_EXPORT bool from_string(string_view, write_result&); CAF_CORE_EXPORT bool from_string(std::string_view, write_result&);
/// @relates write_result /// @relates write_result
CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<write_result>, CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<write_result>,
......
// Deprecated include. The next CAF release won't include this header.
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "caf/error.hpp" #include "caf/error.hpp"
#include "caf/execution_unit.hpp" #include "caf/execution_unit.hpp"
#include "caf/exit_reason.hpp" #include "caf/exit_reason.hpp"
#include "caf/optional.hpp"
namespace caf { namespace caf {
......
...@@ -86,8 +86,8 @@ public: ...@@ -86,8 +86,8 @@ public:
} }
/// Runs this handler and returns its (optional) result. /// Runs this handler and returns its (optional) result.
optional<message> operator()(message& xs) { std::optional<message> operator()(message& xs) {
return impl_ ? impl_->invoke(xs) : none; return impl_ ? impl_->invoke(xs) : std::nullopt;
} }
/// Runs this handler with callback. /// Runs this handler with callback.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <cstddef> #include <cstddef>
#include <string> #include <string>
#include <string_view>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
...@@ -17,12 +18,11 @@ ...@@ -17,12 +18,11 @@
#include "caf/load_inspector_base.hpp" #include "caf/load_inspector_base.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/span.hpp" #include "caf/span.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
/// Deserializes C++ objects from sequence of bytes. Does not perform run-time /// Deserializes C++ objects from sequence of bytes. Does not perform
/// type checks. /// run-time type checks.
class CAF_CORE_EXPORT binary_deserializer class CAF_CORE_EXPORT binary_deserializer
: public load_inspector_base<binary_deserializer> { : public load_inspector_base<binary_deserializer> {
public: public:
...@@ -46,14 +46,14 @@ public: ...@@ -46,14 +46,14 @@ public:
binary_deserializer(execution_unit* ctx, const void* buf, binary_deserializer(execution_unit* ctx, const void* buf,
size_t size) noexcept size_t size) noexcept
: binary_deserializer(ctx, : binary_deserializer(
make_span(reinterpret_cast<const byte*>(buf), size)) { ctx, make_span(reinterpret_cast<const std::byte*>(buf), size)) {
// nop // nop
} }
binary_deserializer(actor_system& sys, const void* buf, size_t size) noexcept binary_deserializer(actor_system& sys, const void* buf, size_t size) noexcept
: binary_deserializer(sys, : binary_deserializer(
make_span(reinterpret_cast<const byte*>(buf), size)) { sys, make_span(reinterpret_cast<const std::byte*>(buf), size)) {
// nop // nop
} }
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
} }
/// Returns the remaining bytes. /// Returns the remaining bytes.
span<const byte> remainder() const noexcept { span<const std::byte> remainder() const noexcept {
return make_span(current_, end_); return make_span(current_, end_);
} }
...@@ -79,15 +79,15 @@ public: ...@@ -79,15 +79,15 @@ public:
void skip(size_t num_bytes); void skip(size_t num_bytes);
/// Assigns a new input. /// Assigns a new input.
void reset(span<const byte> bytes) noexcept; void reset(span<const std::byte> bytes) noexcept;
/// Returns the current read position. /// Returns the current read position.
const byte* current() const noexcept { const std::byte* current() const noexcept {
return current_; return current_;
} }
/// Returns the end of the assigned memory block. /// Returns the end of the assigned memory block.
const byte* end() const noexcept { const std::byte* end() const noexcept {
return end_; return end_;
} }
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
bool fetch_next_object_type(type_id_t& type) noexcept; bool fetch_next_object_type(type_id_t& type) noexcept;
constexpr bool begin_object(type_id_t, string_view) noexcept { constexpr bool begin_object(type_id_t, std::string_view) noexcept {
return true; return true;
} }
...@@ -107,16 +107,16 @@ public: ...@@ -107,16 +107,16 @@ public:
return true; return true;
} }
constexpr bool begin_field(string_view) noexcept { constexpr bool begin_field(std::string_view) noexcept {
return true; return true;
} }
bool begin_field(string_view name, bool& is_present) noexcept; bool begin_field(std::string_view name, bool& is_present) noexcept;
bool begin_field(string_view name, span<const type_id_t> types, bool begin_field(std::string_view name, span<const type_id_t> types,
size_t& index) noexcept; size_t& index) noexcept;
bool begin_field(string_view name, bool& is_present, bool begin_field(std::string_view name, bool& is_present,
span<const type_id_t> types, size_t& index) noexcept; span<const type_id_t> types, size_t& index) noexcept;
constexpr bool end_field() { constexpr bool end_field() {
...@@ -155,7 +155,7 @@ public: ...@@ -155,7 +155,7 @@ public:
bool value(bool& x) noexcept; bool value(bool& x) noexcept;
bool value(byte& x) noexcept; bool value(std::byte& x) noexcept;
bool value(uint8_t& x) noexcept; bool value(uint8_t& x) noexcept;
...@@ -196,7 +196,7 @@ public: ...@@ -196,7 +196,7 @@ public:
bool value(std::u32string& x); bool value(std::u32string& x);
bool value(span<byte> x) noexcept; bool value(span<std::byte> x) noexcept;
bool value(std::vector<bool>& x); bool value(std::vector<bool>& x);
...@@ -209,10 +209,10 @@ private: ...@@ -209,10 +209,10 @@ private:
} }
/// Points to the current read position. /// Points to the current read position.
const byte* current_; const std::byte* current_;
/// Points to the end of the assigned memory block. /// Points to the end of the assigned memory block.
const byte* end_; const std::byte* end_;
/// Provides access to the ::proxy_registry and to the ::actor_system. /// Provides access to the ::proxy_registry and to the ::actor_system.
execution_unit* context_; execution_unit* context_;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <type_traits> #include <type_traits>
#include <vector> #include <vector>
#include "caf/byte.hpp"
#include "caf/byte_buffer.hpp" #include "caf/byte_buffer.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/squashed_int.hpp" #include "caf/detail/squashed_int.hpp"
...@@ -32,7 +31,7 @@ public: ...@@ -32,7 +31,7 @@ public:
using container_type = byte_buffer; using container_type = byte_buffer;
using value_type = byte; using value_type = std::byte;
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
...@@ -84,7 +83,7 @@ public: ...@@ -84,7 +83,7 @@ public:
// -- interface functions ---------------------------------------------------- // -- interface functions ----------------------------------------------------
constexpr bool begin_object(type_id_t, string_view) noexcept { constexpr bool begin_object(type_id_t, std::string_view) noexcept {
return true; return true;
} }
...@@ -92,16 +91,16 @@ public: ...@@ -92,16 +91,16 @@ public:
return true; return true;
} }
constexpr bool begin_field(string_view) noexcept { constexpr bool begin_field(std::string_view) noexcept {
return true; return true;
} }
bool begin_field(string_view, bool is_present); bool begin_field(std::string_view, bool is_present);
bool begin_field(string_view, span<const type_id_t> types, size_t index); bool begin_field(std::string_view, span<const type_id_t> types, size_t index);
bool begin_field(string_view, bool is_present, span<const type_id_t> types, bool begin_field(std::string_view, bool is_present,
size_t index); span<const type_id_t> types, size_t index);
constexpr bool end_field() { constexpr bool end_field() {
return true; return true;
...@@ -137,7 +136,7 @@ public: ...@@ -137,7 +136,7 @@ public:
return end_sequence(); return end_sequence();
} }
bool value(byte x); bool value(std::byte x);
bool value(bool x); bool value(bool x);
...@@ -168,13 +167,13 @@ public: ...@@ -168,13 +167,13 @@ public:
bool value(long double x); bool value(long double x);
bool value(string_view x); bool value(std::string_view x);
bool value(const std::u16string& x); bool value(const std::u16string& x);
bool value(const std::u32string& x); bool value(const std::u32string& x);
bool value(span<const byte> x); bool value(span<const std::byte> x);
bool value(const std::vector<bool>& x); bool value(const std::vector<bool>& x);
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in // Deprecated include. The next CAF release won't include this header.
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include <cstdint> #include <cstddef>
#include <type_traits> #include <type_traits>
#pragma once #pragma once
namespace caf { namespace caf {
/// A C++11/14 drop-in replacement for C++17's `std::byte`.
enum class byte : uint8_t {};
template <class IntegerType, template <class IntegerType,
class = std::enable_if_t<std::is_integral<IntegerType>::value>> class = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr IntegerType to_integer(byte x) noexcept { [[deprecated("use std::to_integer instead")]] constexpr IntegerType
to_integer(std::byte x) noexcept {
return static_cast<IntegerType>(x); return static_cast<IntegerType>(x);
} }
template <class IntegerType,
class E = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr byte& operator<<=(byte& x, IntegerType shift) noexcept {
return x = static_cast<byte>(to_integer<uint8_t>(x) << shift);
}
template <class IntegerType,
class E = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr byte operator<<(byte x, IntegerType shift) noexcept {
return static_cast<byte>(to_integer<uint8_t>(x) << shift);
}
template <class IntegerType,
class E = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr byte& operator>>=(byte& x, IntegerType shift) noexcept {
return x = static_cast<byte>(to_integer<uint8_t>(x) >> shift);
}
template <class IntegerType,
class E = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr byte operator>>(byte x, IntegerType shift) noexcept {
return static_cast<byte>(static_cast<unsigned char>(x) >> shift);
}
inline byte& operator|=(byte& x, byte y) noexcept {
return x = static_cast<byte>(to_integer<uint8_t>(x) | to_integer<uint8_t>(y));
}
constexpr byte operator|(byte x, byte y) noexcept {
return static_cast<byte>(to_integer<uint8_t>(x) | to_integer<uint8_t>(y));
}
inline byte& operator&=(byte& x, byte y) noexcept {
return x = static_cast<byte>(to_integer<uint8_t>(x) & to_integer<uint8_t>(y));
}
constexpr byte operator&(byte x, byte y) noexcept {
return static_cast<byte>(to_integer<uint8_t>(x) & to_integer<uint8_t>(y));
}
inline byte& operator^=(byte& x, byte y) noexcept {
return x = static_cast<byte>(to_integer<uint8_t>(x) ^ to_integer<uint8_t>(y));
}
constexpr byte operator^(byte x, byte y) noexcept {
return static_cast<byte>(to_integer<uint8_t>(x) ^ to_integer<uint8_t>(y));
}
constexpr byte operator~(byte x) noexcept {
return static_cast<byte>(~to_integer<uint8_t>(x));
}
} // namespace caf } // namespace caf
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
#pragma once #pragma once
#include <cstddef>
#include <vector> #include <vector>
#include "caf/byte.hpp"
namespace caf { namespace caf {
/// A buffer for storing binary data. /// A buffer for storing binary data.
using byte_buffer = std::vector<byte>; using byte_buffer = std::vector<std::byte>;
} // namespace caf } // namespace caf
...@@ -4,15 +4,16 @@ ...@@ -4,15 +4,16 @@
#pragma once #pragma once
#include "caf/byte.hpp" #include <cstddef>
#include "caf/span.hpp" #include "caf/span.hpp"
namespace caf { namespace caf {
/// Convenience alias for referring to a writable sequence of bytes. /// Convenience alias for referring to a writable sequence of bytes.
using byte_span = span<byte>; using byte_span = span<std::byte>;
/// Convenience alias for referring to a read-only sequence of bytes. /// Convenience alias for referring to a read-only sequence of bytes.
using const_byte_span = span<const byte>; using const_byte_span = span<const std::byte>;
} // namespace caf } // namespace caf
...@@ -4,10 +4,8 @@ ...@@ -4,10 +4,8 @@
#pragma once #pragma once
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp"
namespace caf { namespace caf {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
namespace caf { namespace caf {
......
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <optional>
#include <string> #include <string>
#include <string_view>
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/string_algorithms.hpp" #include "caf/string_algorithms.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
...@@ -34,14 +35,15 @@ public: ...@@ -34,14 +35,15 @@ public:
config_value (*get)(const void*); config_value (*get)(const void*);
/// Human-readable name of the option's type. /// Human-readable name of the option's type.
string_view type_name; std::string_view type_name;
}; };
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
/// Constructs a config option. /// Constructs a config option.
config_option(string_view category, string_view name, string_view description, config_option(std::string_view category, std::string_view name,
const meta_state* meta, void* value = nullptr); std::string_view description, const meta_state* meta,
void* value = nullptr);
config_option(const config_option&); config_option(const config_option&);
...@@ -58,19 +60,19 @@ public: ...@@ -58,19 +60,19 @@ public:
// -- properties ------------------------------------------------------------- // -- properties -------------------------------------------------------------
/// Returns the category of the option. /// Returns the category of the option.
string_view category() const noexcept; std::string_view category() const noexcept;
/// Returns the name of the option. /// Returns the name of the option.
string_view long_name() const noexcept; std::string_view long_name() const noexcept;
/// Returns (optional) one-letter short names of the option. /// Returns (optional) one-letter short names of the option.
string_view short_names() const noexcept; std::string_view short_names() const noexcept;
/// Returns a human-readable description of the option. /// Returns a human-readable description of the option.
string_view description() const noexcept; std::string_view description() const noexcept;
/// Returns the full name for this config option as "<category>.<long name>". /// Returns the full name for this config option as "<category>.<long name>".
string_view full_name() const noexcept; std::string_view full_name() const noexcept;
/// Synchronizes the value of this config option with `x` and vice versa. /// Synchronizes the value of this config option with `x` and vice versa.
/// ///
...@@ -82,7 +84,7 @@ public: ...@@ -82,7 +84,7 @@ public:
error sync(config_value& x) const; error sync(config_value& x) const;
/// Returns a human-readable representation of this option's expected type. /// Returns a human-readable representation of this option's expected type.
string_view type_name() const noexcept; std::string_view type_name() const noexcept;
/// Returns whether this config option stores a boolean flag. /// Returns whether this config option stores a boolean flag.
bool is_flag() const noexcept; bool is_flag() const noexcept;
...@@ -91,7 +93,7 @@ public: ...@@ -91,7 +93,7 @@ public:
bool has_flat_cli_name() const noexcept; bool has_flat_cli_name() const noexcept;
private: private:
string_view buf_slice(size_t from, size_t to) const noexcept; std::string_view buf_slice(size_t from, size_t to) const noexcept;
std::unique_ptr<char[]> buf_; std::unique_ptr<char[]> buf_;
uint16_t category_separator_; uint16_t category_separator_;
...@@ -104,15 +106,16 @@ private: ...@@ -104,15 +106,16 @@ private:
/// Finds `config_option` string with a matching long name in (`first`, `last`], /// Finds `config_option` string with a matching long name in (`first`, `last`],
/// where each entry is a pointer to a string. Returns a `ForwardIterator` to /// where each entry is a pointer to a string. Returns a `ForwardIterator` to
/// the match and a `caf::string_view` of the option value if the entry is found /// the match and a `string_view` of the option value if the entry is
/// and a `ForwardIterator` to `last` with an empty `string_view` otherwise. /// found and a `ForwardIterator` to `last` with an empty `string_view`
/// otherwise.
template <class ForwardIterator, class Sentinel> template <class ForwardIterator, class Sentinel>
std::pair<ForwardIterator, string_view> std::pair<ForwardIterator, std::string_view>
find_by_long_name(const config_option& x, ForwardIterator first, find_by_long_name(const config_option& x, ForwardIterator first,
Sentinel last) { Sentinel last) {
auto long_name = x.long_name(); auto long_name = x.long_name();
for (; first != last; ++first) { for (; first != last; ++first) {
string_view str{*first}; std::string_view str{*first};
// Make sure this is a long option starting with "--". // Make sure this is a long option starting with "--".
if (!starts_with(str, "--")) if (!starts_with(str, "--"))
continue; continue;
...@@ -131,7 +134,7 @@ find_by_long_name(const config_option& x, ForwardIterator first, ...@@ -131,7 +134,7 @@ find_by_long_name(const config_option& x, ForwardIterator first,
str.remove_prefix(1); str.remove_prefix(1);
return {first, str}; return {first, str};
} }
return {first, string_view{}}; return {first, std::string_view{}};
} }
} // namespace caf } // namespace caf
...@@ -17,26 +17,28 @@ class CAF_CORE_EXPORT config_option_adder { ...@@ -17,26 +17,28 @@ class CAF_CORE_EXPORT config_option_adder {
public: public:
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
config_option_adder(config_option_set& target, string_view category); config_option_adder(config_option_set& target, std::string_view category);
// -- properties ------------------------------------------------------------- // -- properties -------------------------------------------------------------
/// Adds a config option to the category that synchronizes with `ref`. /// Adds a config option to the category that synchronizes with `ref`.
template <class T> template <class T>
config_option_adder& add(T& ref, string_view name, string_view description) { config_option_adder&
add(T& ref, std::string_view name, std::string_view description) {
return add_impl(make_config_option(ref, category_, name, description)); return add_impl(make_config_option(ref, category_, name, description));
} }
/// Adds a config option to the category. /// Adds a config option to the category.
template <class T> template <class T>
config_option_adder& add(string_view name, string_view description) { config_option_adder&
add(std::string_view name, std::string_view description) {
return add_impl(make_config_option<T>(category_, name, description)); return add_impl(make_config_option<T>(category_, name, description));
} }
/// For backward compatibility only. Do not use for new code! /// For backward compatibility only. Do not use for new code!
/// @private /// @private
config_option_adder& config_option_adder& add_neg(bool& ref, std::string_view name,
add_neg(bool& ref, string_view name, string_view description); std::string_view description);
private: private:
// -- properties ------------------------------------------------------------- // -- properties -------------------------------------------------------------
...@@ -49,7 +51,7 @@ private: ...@@ -49,7 +51,7 @@ private:
config_option_set& xs_; config_option_set& xs_;
/// Category for all options generated by this adder. /// Category for all options generated by this adder.
string_view category_; std::string_view category_;
}; };
} // namespace caf } // namespace caf
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <string> #include <string>
#include <string_view>
#include <utility> #include <utility>
#include <vector> #include <vector>
...@@ -15,7 +16,6 @@ ...@@ -15,7 +16,6 @@
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/make_config_option.hpp" #include "caf/make_config_option.hpp"
#include "caf/pec.hpp" #include "caf/pec.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
...@@ -50,21 +50,21 @@ public: ...@@ -50,21 +50,21 @@ public:
/// `<prefix>#<category>.<long-name>`. Users can omit `<prefix>` /// `<prefix>#<category>.<long-name>`. Users can omit `<prefix>`
/// for options that have an empty prefix and `<category>` /// for options that have an empty prefix and `<category>`
/// if the category is "global". /// if the category is "global".
option_pointer cli_long_name_lookup(string_view name) const; option_pointer cli_long_name_lookup(std::string_view name) const;
/// Returns the first `config_option` that matches the CLI short option name. /// Returns the first `config_option` that matches the CLI short option name.
option_pointer cli_short_name_lookup(char short_name) const; option_pointer cli_short_name_lookup(char short_name) const;
/// Returns the first `config_option` that matches category and long name. /// Returns the first `config_option` that matches category and long name.
option_pointer option_pointer qualified_name_lookup(std::string_view category,
qualified_name_lookup(string_view category, string_view long_name) const; std::string_view long_name) const;
/// Returns the first `config_option` that matches the qualified name. /// Returns the first `config_option` that matches the qualified name.
/// @param name Config option name formatted as `<category>.<long-name>`. /// @param name Config option name formatted as `<category>.<long-name>`.
option_pointer qualified_name_lookup(string_view name) const; option_pointer qualified_name_lookup(std::string_view name) const;
/// Returns whether a @ref config_option for the given category exists. /// Returns whether a @ref config_option for the given category exists.
bool has_category(string_view category) const noexcept; bool has_category(std::string_view category) const noexcept;
/// Returns the number of stored config options. /// Returns the number of stored config options.
size_t size() const noexcept { size_t size() const noexcept {
...@@ -98,54 +98,59 @@ public: ...@@ -98,54 +98,59 @@ public:
/// Adds a config option to the set. /// Adds a config option to the set.
template <class T> template <class T>
config_option_set& config_option_set& add(std::string_view category, std::string_view name,
add(string_view category, string_view name, string_view description) & { std::string_view description) & {
return add(make_config_option<T>(category, name, description)); return add(make_config_option<T>(category, name, description));
} }
/// Adds a config option to the set. /// Adds a config option to the set.
template <class T> template <class T>
config_option_set& add(string_view name, string_view description) & { config_option_set&
add(std::string_view name, std::string_view description) & {
return add(make_config_option<T>("global", name, description)); return add(make_config_option<T>("global", name, description));
} }
/// Adds a config option to the set. /// Adds a config option to the set.
template <class T> template <class T>
config_option_set&& config_option_set&& add(std::string_view category, std::string_view name,
add(string_view category, string_view name, string_view description) && { std::string_view description) && {
return std::move(add<T>(category, name, description)); return std::move(add<T>(category, name, description));
} }
/// Adds a config option to the set. /// Adds a config option to the set.
template <class T> template <class T>
config_option_set&& add(string_view name, string_view description) && { config_option_set&&
add(std::string_view name, std::string_view description) && {
return std::move(add<T>("global", name, description)); return std::move(add<T>("global", name, description));
} }
/// Adds a config option to the set that synchronizes its value with `ref`. /// Adds a config option to the set that synchronizes its value with `ref`.
template <class T> template <class T>
config_option_set& add(T& ref, string_view category, string_view name, config_option_set& add(T& ref, std::string_view category,
string_view description) & { std::string_view name,
std::string_view description) & {
return add(make_config_option<T>(ref, category, name, description)); return add(make_config_option<T>(ref, category, name, description));
} }
/// Adds a config option to the set that synchronizes its value with `ref`. /// Adds a config option to the set that synchronizes its value with `ref`.
template <class T> template <class T>
config_option_set& add(T& ref, string_view name, string_view description) & { config_option_set&
add(T& ref, std::string_view name, std::string_view description) & {
return add(ref, "global", name, description); return add(ref, "global", name, description);
} }
/// Adds a config option to the set that synchronizes its value with `ref`. /// Adds a config option to the set that synchronizes its value with `ref`.
template <class T> template <class T>
config_option_set&& add(T& ref, string_view category, string_view name, config_option_set&& add(T& ref, std::string_view category,
string_view description) && { std::string_view name,
std::string_view description) && {
return std::move(add(ref, category, name, description)); return std::move(add(ref, category, name, description));
} }
/// Adds a config option to the set that synchronizes its value with `ref`. /// Adds a config option to the set that synchronizes its value with `ref`.
template <class T> template <class T>
config_option_set&& config_option_set&&
add(T& ref, string_view name, string_view description) && { add(T& ref, std::string_view name, std::string_view description) && {
return std::move(add(ref, "global", name, description)); return std::move(add(ref, "global", name, description));
} }
...@@ -163,12 +168,12 @@ public: ...@@ -163,12 +168,12 @@ public:
// -- parsing ---------------------------------------------------------------- // -- parsing ----------------------------------------------------------------
/// Parses a given range as CLI arguments into `config`. /// Parses a given range as CLI arguments into `config`.
parse_result parse_result parse(settings& config, argument_iterator begin,
parse(settings& config, argument_iterator begin, argument_iterator end) const; argument_iterator end) const;
/// Parses a given range as CLI arguments into `config`. /// Parses a given range as CLI arguments into `config`.
parse_result parse_result parse(settings& config,
parse(settings& config, const std::vector<std::string>& args) const; const std::vector<std::string>& args) const;
private: private:
// -- member variables ------------------------------------------------------- // -- member variables -------------------------------------------------------
......
...@@ -11,9 +11,12 @@ ...@@ -11,9 +11,12 @@
#include <iosfwd> #include <iosfwd>
#include <iterator> #include <iterator>
#include <map> #include <map>
#include <optional>
#include <string> #include <string>
#include <string_view>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include <variant>
#include <vector> #include <vector>
#include "caf/config_value_reader.hpp" #include "caf/config_value_reader.hpp"
...@@ -28,17 +31,12 @@ ...@@ -28,17 +31,12 @@
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/inspector_access.hpp" #include "caf/inspector_access.hpp"
#include "caf/inspector_access_type.hpp" #include "caf/inspector_access_type.hpp"
#include "caf/optional.hpp"
#include "caf/raise_error.hpp" #include "caf/raise_error.hpp"
#include "caf/string_algorithms.hpp" #include "caf/string_algorithms.hpp"
#include "caf/string_view.hpp"
#include "caf/sum_type.hpp"
#include "caf/sum_type_access.hpp"
#include "caf/sum_type_token.hpp"
#include "caf/timespan.hpp" #include "caf/timespan.hpp"
#include "caf/timestamp.hpp" #include "caf/timestamp.hpp"
#include "caf/uri.hpp" #include "caf/uri.hpp"
#include "caf/variant.hpp" #include "caf/variant_wrapper.hpp"
namespace caf::detail { namespace caf::detail {
...@@ -90,7 +88,7 @@ public: ...@@ -90,7 +88,7 @@ public:
using types = detail::type_list<none_t, integer, boolean, real, timespan, uri, using types = detail::type_list<none_t, integer, boolean, real, timespan, uri,
string, list, dictionary>; string, list, dictionary>;
using variant_type = detail::tl_apply_t<types, variant>; using variant_type = detail::tl_apply_t<types, std::variant>;
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
...@@ -122,16 +120,16 @@ public: ...@@ -122,16 +120,16 @@ public:
// -- parsing ---------------------------------------------------------------- // -- parsing ----------------------------------------------------------------
/// Tries to parse a value from given characters. /// Tries to parse a value from given characters.
static expected<config_value> parse(string_view::iterator first, static expected<config_value> parse(std::string_view::iterator first,
string_view::iterator last); std::string_view::iterator last);
/// Tries to parse a value from `str`. /// Tries to parse a value from `str`.
static expected<config_value> parse(string_view str); static expected<config_value> parse(std::string_view str);
/// Tries to parse a config value (list) from `str` and to convert it to an /// Tries to parse a config value (list) from `str` and to convert it to an
/// allowed input message type for `Handle`. /// allowed input message type for `Handle`.
template <class Handle> template <class Handle>
static optional<message> parse_msg(string_view str, const Handle&) { static std::optional<message> parse_msg(std::string_view str, const Handle&) {
auto allowed = Handle::allowed_inputs(); auto allowed = Handle::allowed_inputs();
return parse_msg_impl(str, allowed); return parse_msg_impl(str, allowed);
} }
...@@ -158,24 +156,19 @@ public: ...@@ -158,24 +156,19 @@ public:
/// Returns a human-readable type name of the current value. /// Returns a human-readable type name of the current value.
const char* type_name() const noexcept; const char* type_name() const noexcept;
/// Returns the underlying variant. /// @private
variant_type& get_data() { variant_type& get_data() & {
return data_; return data_;
} }
/// Returns the underlying variant. /// @private
const variant_type& get_data() const { const variant_type& get_data() const& {
return data_; return data_;
} }
/// Returns a pointer to the underlying variant. /// @private
variant_type* get_data_ptr() { variant_type&& get_data() && {
return &data_; return std::move(data_);
}
/// Returns a pointer to the underlying variant.
const variant_type* get_data_ptr() const {
return &data_;
} }
/// Checks whether this config value is not null. /// Checks whether this config value is not null.
...@@ -249,7 +242,7 @@ public: ...@@ -249,7 +242,7 @@ public:
} }
template <class T> template <class T>
static constexpr string_view mapped_type_name() { static constexpr std::string_view mapped_type_name() {
if constexpr (detail::is_complete<caf::type_name<T>>) { if constexpr (detail::is_complete<caf::type_name<T>>) {
return caf::type_name<T>::value; return caf::type_name<T>::value;
} else if constexpr (detail::is_list_like_v<T>) { } else if constexpr (detail::is_list_like_v<T>) {
...@@ -264,8 +257,8 @@ private: ...@@ -264,8 +257,8 @@ private:
static const char* type_name_at_index(size_t index) noexcept; static const char* type_name_at_index(size_t index) noexcept;
static optional<message> static std::optional<message>
parse_msg_impl(string_view str, span<const type_id_list> allowed_types); parse_msg_impl(std::string_view str, span<const type_id_list> allowed_types);
// -- auto conversion of related types --------------------------------------- // -- auto conversion of related types ---------------------------------------
...@@ -309,7 +302,7 @@ private: ...@@ -309,7 +302,7 @@ private:
data_ = std::string{x}; data_ = std::string{x};
} }
void set(string_view x) { void set(std::string_view x) {
data_ = std::string{x.begin(), x.end()}; data_ = std::string{x.begin(), x.end()};
} }
...@@ -321,6 +314,11 @@ private: ...@@ -321,6 +314,11 @@ private:
/// @relates config_value /// @relates config_value
CAF_CORE_EXPORT std::string to_string(const config_value& x); CAF_CORE_EXPORT std::string to_string(const config_value& x);
// -- std::variant-like access -------------------------------------------------
template <>
struct is_variant_wrapper<config_value> : std::true_type {};
// -- conversion via get_as ---------------------------------------------------- // -- conversion via get_as ----------------------------------------------------
template <class T> template <class T>
...@@ -500,8 +498,9 @@ expected<T> get_as(const config_value& value) { ...@@ -500,8 +498,9 @@ expected<T> get_as(const config_value& value) {
/// Customization point for configuring automatic mappings from default value /// Customization point for configuring automatic mappings from default value
/// types to deduced types. For example, `get_or(value, "foo"sv)` must return a /// types to deduced types. For example, `get_or(value, "foo"sv)` must return a
/// `string` rather than a `string_view`. However, user-defined overloads *must /// `string` rather than a `string_view`. However, user-defined overloads
/// not* specialize this class for any type from the namespaces `std` or `caf`. /// *must not* specialize this class for any type from the namespaces `std` or
/// `caf`.
template <class T> template <class T>
struct get_or_deduction_guide { struct get_or_deduction_guide {
using value_type = T; using value_type = T;
...@@ -512,9 +511,9 @@ struct get_or_deduction_guide { ...@@ -512,9 +511,9 @@ struct get_or_deduction_guide {
}; };
template <> template <>
struct get_or_deduction_guide<string_view> { struct get_or_deduction_guide<std::string_view> {
using value_type = std::string; using value_type = std::string;
static value_type convert(string_view str) { static value_type convert(std::string_view str) {
return {str.begin(), str.end()}; return {str.begin(), str.end()};
} }
}; };
...@@ -558,33 +557,6 @@ auto get_or(const config_value& x, Fallback&& fallback) { ...@@ -558,33 +557,6 @@ auto get_or(const config_value& x, Fallback&& fallback) {
} }
} }
// -- SumType-like access ------------------------------------------------------
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
auto get_if(const config_value* x) {
return get_if<T>(x->get_data_ptr());
}
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
auto get_if(config_value* x) {
return get_if<T>(x->get_data_ptr());
}
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
decltype(auto) get(const config_value& x) {
return get<T>(x.get_data());
}
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
decltype(auto) get(config_value& x) {
return get<T>(x.get_data());
}
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
auto holds_alternative(const config_value& x) {
return holds_alternative<T>(x.get_data());
}
// -- comparison operator overloads -------------------------------------------- // -- comparison operator overloads --------------------------------------------
/// @relates config_value /// @relates config_value
...@@ -643,7 +615,7 @@ struct variant_inspector_traits<config_value> { ...@@ -643,7 +615,7 @@ struct variant_inspector_traits<config_value> {
template <class F, class Value> template <class F, class Value>
static auto visit(F&& f, Value&& x) { static auto visit(F&& f, Value&& x) {
return caf::visit(std::forward<F>(f), x.get_data()); return std::visit(std::forward<F>(f), x.get_data());
} }
template <class U> template <class U>
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <memory> #include <memory>
#include <stack> #include <stack>
#include <variant>
#include <vector> #include <vector>
namespace caf { namespace caf {
...@@ -47,8 +48,8 @@ public: ...@@ -47,8 +48,8 @@ public:
const std::pair<const std::string, config_value>& current(); const std::pair<const std::string, config_value>& current();
}; };
using value_type = variant<const settings*, const config_value*, key_ptr, using value_type = std::variant<const settings*, const config_value*, key_ptr,
absent_field, sequence, associative_array>; absent_field, sequence, associative_array>;
using stack_type = std::stack<value_type, std::vector<value_type>>; using stack_type = std::stack<value_type, std::vector<value_type>>;
...@@ -90,18 +91,18 @@ public: ...@@ -90,18 +91,18 @@ public:
bool fetch_next_object_type(type_id_t& type) override; bool fetch_next_object_type(type_id_t& type) override;
bool begin_object(type_id_t type, string_view name) override; bool begin_object(type_id_t type, std::string_view name) override;
bool end_object() override; bool end_object() override;
bool begin_field(string_view) override; bool begin_field(std::string_view) override;
bool begin_field(string_view name, bool& is_present) override; bool begin_field(std::string_view name, bool& is_present) override;
bool begin_field(string_view name, span<const type_id_t> types, bool begin_field(std::string_view name, span<const type_id_t> types,
size_t& index) override; size_t& index) override;
bool begin_field(string_view name, bool& is_present, bool begin_field(std::string_view name, bool& is_present,
span<const type_id_t> types, size_t& index) override; span<const type_id_t> types, size_t& index) override;
bool end_field() override; bool end_field() override;
...@@ -122,7 +123,7 @@ public: ...@@ -122,7 +123,7 @@ public:
bool end_associative_array() override; bool end_associative_array() override;
bool value(byte& x) override; bool value(std::byte& x) override;
bool value(bool& x) override; bool value(bool& x) override;
...@@ -154,7 +155,7 @@ public: ...@@ -154,7 +155,7 @@ public:
bool value(std::u32string& x) override; bool value(std::u32string& x) override;
bool value(span<byte> x) override; bool value(span<std::byte> x) override;
private: private:
// Sets `type` according to the `@type` field in `obj` or to the type ID of // Sets `type` according to the `@type` field in `obj` or to the type ID of
......
...@@ -22,14 +22,14 @@ public: ...@@ -22,14 +22,14 @@ public:
struct present_field { struct present_field {
settings* parent; settings* parent;
string_view name; std::string_view name;
string_view type; std::string_view type;
}; };
struct absent_field {}; struct absent_field {};
using value_type = variant<config_value*, settings*, absent_field, using value_type = std::variant<config_value*, settings*, absent_field,
present_field, std::vector<config_value>*>; present_field, std::vector<config_value>*>;
using stack_type = std::stack<value_type, std::vector<value_type>>; using stack_type = std::stack<value_type, std::vector<value_type>>;
...@@ -54,18 +54,18 @@ public: ...@@ -54,18 +54,18 @@ public:
// -- interface functions ---------------------------------------------------- // -- interface functions ----------------------------------------------------
bool begin_object(type_id_t type, string_view name) override; bool begin_object(type_id_t type, std::string_view name) override;
bool end_object() override; bool end_object() override;
bool begin_field(string_view) override; bool begin_field(std::string_view) override;
bool begin_field(string_view name, bool is_present) override; bool begin_field(std::string_view name, bool is_present) override;
bool begin_field(string_view name, span<const type_id_t> types, bool begin_field(std::string_view name, span<const type_id_t> types,
size_t index) override; size_t index) override;
bool begin_field(string_view name, bool is_present, bool begin_field(std::string_view name, bool is_present,
span<const type_id_t> types, size_t index) override; span<const type_id_t> types, size_t index) override;
bool end_field() override; bool end_field() override;
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
bool end_associative_array() override; bool end_associative_array() override;
bool value(byte x) override; bool value(std::byte x) override;
bool value(bool x) override; bool value(bool x) override;
...@@ -112,13 +112,13 @@ public: ...@@ -112,13 +112,13 @@ public:
bool value(long double x) override; bool value(long double x) override;
bool value(string_view x) override; bool value(std::string_view x) override;
bool value(const std::u16string& x) override; bool value(const std::u16string& x) override;
bool value(const std::u32string& x) override; bool value(const std::u32string& x) override;
bool value(span<const byte> x) override; bool value(span<const std::byte> x) override;
private: private:
bool push(config_value&& x); bool push(config_value&& x);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <optional>
#include <utility> #include <utility>
#include "caf/detail/message_data.hpp" #include "caf/detail/message_data.hpp"
...@@ -27,8 +28,8 @@ public: ...@@ -27,8 +28,8 @@ public:
const_typed_message_view(const const_typed_message_view&) noexcept = default; const_typed_message_view(const const_typed_message_view&) noexcept = default;
const_typed_message_view& operator=(const const_typed_message_view&) noexcept const_typed_message_view&
= default; operator=(const const_typed_message_view&) noexcept = default;
const detail::message_data* operator->() const noexcept { const detail::message_data* operator->() const noexcept {
return ptr_; return ptr_;
...@@ -67,10 +68,10 @@ auto make_const_typed_message_view(const message& msg) { ...@@ -67,10 +68,10 @@ auto make_const_typed_message_view(const message& msg) {
} }
template <class... Ts> template <class... Ts>
optional<std::tuple<Ts...>> to_tuple(const message& msg) { std::optional<std::tuple<Ts...>> to_tuple(const message& msg) {
if (auto view = make_const_typed_message_view<Ts...>(msg)) if (auto view = make_const_typed_message_view<Ts...>(msg))
return to_tuple(view); return to_tuple(view);
return none; return std::nullopt;
} }
} // namespace caf } // namespace caf
...@@ -130,12 +130,13 @@ struct inspector_access<cow_tuple<Ts...>> { ...@@ -130,12 +130,13 @@ struct inspector_access<cow_tuple<Ts...>> {
} }
template <class Inspector> template <class Inspector>
static bool save_field(Inspector& f, string_view field_name, value_type& x) { static bool
save_field(Inspector& f, std::string_view field_name, value_type& x) {
return detail::save_field(f, field_name, detail::as_mutable_ref(x.data())); return detail::save_field(f, field_name, detail::as_mutable_ref(x.data()));
} }
template <class Inspector, class IsPresent, class Get> template <class Inspector, class IsPresent, class Get>
static bool save_field(Inspector& f, string_view field_name, static bool save_field(Inspector& f, std::string_view field_name,
IsPresent& is_present, Get& get) { IsPresent& is_present, Get& get) {
if constexpr (std::is_lvalue_reference<decltype(get())>::value) { if constexpr (std::is_lvalue_reference<decltype(get())>::value) {
auto get_data = [&get]() -> decltype(auto) { auto get_data = [&get]() -> decltype(auto) {
...@@ -152,16 +153,17 @@ struct inspector_access<cow_tuple<Ts...>> { ...@@ -152,16 +153,17 @@ struct inspector_access<cow_tuple<Ts...>> {
} }
template <class Inspector, class IsValid, class SyncValue> template <class Inspector, class IsValid, class SyncValue>
static bool load_field(Inspector& f, string_view field_name, value_type& x, static bool load_field(Inspector& f, std::string_view field_name,
IsValid& is_valid, SyncValue& sync_value) { value_type& x, IsValid& is_valid,
SyncValue& sync_value) {
return detail::load_field(f, field_name, x.unshared(), is_valid, return detail::load_field(f, field_name, x.unshared(), is_valid,
sync_value); sync_value);
} }
template <class Inspector, class IsValid, class SyncValue, class SetFallback> template <class Inspector, class IsValid, class SyncValue, class SetFallback>
static bool load_field(Inspector& f, string_view field_name, value_type& x, static bool load_field(Inspector& f, std::string_view field_name,
IsValid& is_valid, SyncValue& sync_value, value_type& x, IsValid& is_valid,
SetFallback& set_fallback) { SyncValue& sync_value, SetFallback& set_fallback) {
return detail::load_field(f, field_name, x.unshared(), is_valid, sync_value, return detail::load_field(f, field_name, x.unshared(), is_valid, sync_value,
set_fallback); set_fallback);
} }
......
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#include "caf/detail/implicit_conversions.hpp" #include "caf/detail/implicit_conversions.hpp"
#include "caf/expected.hpp" #include "caf/expected.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/optional.hpp"
#include "caf/replies_to.hpp"
namespace caf::detail { namespace caf::detail {
......
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
#pragma once #pragma once
#include <string> #include <string>
#include <string_view>
#include <type_traits> #include <type_traits>
#include "caf/string_view.hpp"
namespace caf { namespace caf {
/// Convenience function for providing a default inspection scaffold for custom /// Convenience function for providing a default inspection scaffold for custom
...@@ -28,7 +27,7 @@ bool default_enum_inspect(Inspector& f, Enumeration& x) { ...@@ -28,7 +27,7 @@ bool default_enum_inspect(Inspector& f, Enumeration& x) {
using integer_type = std::underlying_type_t<Enumeration>; using integer_type = std::underlying_type_t<Enumeration>;
if (f.has_human_readable_format()) { if (f.has_human_readable_format()) {
auto get = [&x] { return to_string(x); }; auto get = [&x] { return to_string(x); };
auto set = [&x](string_view str) { return from_string(str, x); }; auto set = [&x](std::string_view str) { return from_string(str, x); };
return f.apply(get, set); return f.apply(get, set);
} else { } else {
auto get = [&x] { return static_cast<integer_type>(x); }; auto get = [&x] { return static_cast<integer_type>(x); };
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <cstddef>
#include <type_traits>
#include <utility>
#include "caf/detail/type_list.hpp"
#include "caf/sum_type_token.hpp"
namespace caf {
/// Allows specializing the `sum_type_access` trait for any type that simply
/// wraps a `variant` and exposes it with a `get_data()` member function.
template <class T>
struct default_sum_type_access {
using types = typename T::types;
using type0 = typename detail::tl_head<types>::type;
static constexpr bool specialized = true;
template <class U, int Pos>
static bool is(const T& x, sum_type_token<U, Pos> token) {
return x.get_data().is(pos(token));
}
template <class U, int Pos>
static U& get(T& x, sum_type_token<U, Pos> token) {
return x.get_data().get(pos(token));
}
template <class U, int Pos>
static const U& get(const T& x, sum_type_token<U, Pos> token) {
return x.get_data().get(pos(token));
}
template <class U, int Pos>
static U* get_if(T* x, sum_type_token<U, Pos> token) {
return is(*x, token) ? &get(*x, token) : nullptr;
}
template <class U, int Pos>
static const U* get_if(const T* x, sum_type_token<U, Pos> token) {
return is(*x, token) ? &get(*x, token) : nullptr;
}
template <class Result, class Visitor, class... Ts>
static Result apply(T& x, Visitor&& visitor, Ts&&... xs) {
return x.get_data().template apply<Result>(std::forward<Visitor>(visitor),
std::forward<Ts>(xs)...);
}
template <class Result, class Visitor, class... Ts>
static Result apply(const T& x, Visitor&& visitor, Ts&&... xs) {
return x.get_data().template apply<Result>(std::forward<Visitor>(visitor),
std::forward<Ts>(xs)...);
}
};
} // namespace caf
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#include <cstddef> #include <cstddef>
#include <limits> #include <limits>
#include <string> #include <string>
#include <string_view>
#include <vector> #include <vector>
#include "caf/detail/build_config.hpp" #include "caf/detail/build_config.hpp"
#include "caf/detail/log_level.hpp" #include "caf/detail/log_level.hpp"
#include "caf/string_view.hpp"
#include "caf/timestamp.hpp" #include "caf/timestamp.hpp"
// -- hard-coded default values for various CAF options ------------------------ // -- hard-coded default values for various CAF options ------------------------
...@@ -29,7 +29,7 @@ constexpr auto max_batch_delay = timespan{1'000'000}; ...@@ -29,7 +29,7 @@ constexpr auto max_batch_delay = timespan{1'000'000};
/// The `token-based` controller associates each stream element with one token. /// The `token-based` controller associates each stream element with one token.
/// Input buffer and batch sizes are then statically defined in terms of tokens. /// Input buffer and batch sizes are then statically defined in terms of tokens.
/// This strategy makes no dynamic adjustment or sampling. /// This strategy makes no dynamic adjustment or sampling.
constexpr auto credit_policy = string_view{"size-based"}; constexpr auto credit_policy = std::string_view{"size-based"};
} // namespace caf::defaults::stream } // namespace caf::defaults::stream
...@@ -71,8 +71,8 @@ constexpr auto buffer_size = int32_t{4096}; // // 32 KB for elements of size 8. ...@@ -71,8 +71,8 @@ constexpr auto buffer_size = int32_t{4096}; // // 32 KB for elements of size 8.
namespace caf::defaults::scheduler { namespace caf::defaults::scheduler {
constexpr auto policy = string_view{"stealing"}; constexpr auto policy = std::string_view{"stealing"};
constexpr auto profiling_output_file = string_view{""}; constexpr auto profiling_output_file = std::string_view{""};
constexpr auto max_throughput = std::numeric_limits<size_t>::max(); constexpr auto max_throughput = std::numeric_limits<size_t>::max();
constexpr auto profiling_resolution = timespan(100'000'000); constexpr auto profiling_resolution = timespan(100'000'000);
...@@ -92,22 +92,23 @@ constexpr auto relaxed_sleep_duration = timespan{10'000'000}; ...@@ -92,22 +92,23 @@ constexpr auto relaxed_sleep_duration = timespan{10'000'000};
namespace caf::defaults::logger::file { namespace caf::defaults::logger::file {
constexpr auto format = string_view{"%r %c %p %a %t %C %M %F:%L %m%n"}; constexpr auto format = std::string_view{"%r %c %p %a %t %C %M %F:%L %m%n"};
constexpr auto path = string_view{"actor_log_[PID]_[TIMESTAMP]_[NODE].log"}; constexpr auto path
= std::string_view{"actor_log_[PID]_[TIMESTAMP]_[NODE].log"};
} // namespace caf::defaults::logger::file } // namespace caf::defaults::logger::file
namespace caf::defaults::logger::console { namespace caf::defaults::logger::console {
constexpr auto colored = true; constexpr auto colored = true;
constexpr auto format = string_view{"[%c:%p] %d %m"}; constexpr auto format = std::string_view{"[%c:%p] %d %m"};
} // namespace caf::defaults::logger::console } // namespace caf::defaults::logger::console
namespace caf::defaults::middleman { namespace caf::defaults::middleman {
constexpr auto app_identifier = string_view{"generic-caf-app"}; constexpr auto app_identifier = std::string_view{"generic-caf-app"};
constexpr auto network_backend = string_view{"default"}; constexpr auto network_backend = std::string_view{"default"};
constexpr auto max_consecutive_reads = size_t{50}; constexpr auto max_consecutive_reads = size_t{50};
constexpr auto heartbeat_interval = timespan{10'000'000'000}; constexpr auto heartbeat_interval = timespan{10'000'000'000};
constexpr auto connection_timeout = timespan{30'000'000'000}; constexpr auto connection_timeout = timespan{30'000'000'000};
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "caf/byte.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/squashed_int.hpp" #include "caf/detail/squashed_int.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
...@@ -61,35 +60,36 @@ public: ...@@ -61,35 +60,36 @@ public:
/// that becomes invalid as soon as calling *any* other member /// that becomes invalid as soon as calling *any* other member
/// function on the deserializer. Convert the `type_name` to a string /// function on the deserializer. Convert the `type_name` to a string
/// before storing it. /// before storing it.
virtual bool fetch_next_object_name(string_view& type_name); virtual bool fetch_next_object_name(std::string_view& type_name);
/// Convenience function for querying `fetch_next_object_name` comparing the /// Convenience function for querying `fetch_next_object_name` comparing the
/// result to `type_name` in one shot. /// result to `type_name` in one shot.
bool next_object_name_matches(string_view type_name); bool next_object_name_matches(std::string_view type_name);
/// Like `next_object_name_matches`, but sets an error on the deserializer /// Like `next_object_name_matches`, but sets an error on the deserializer
/// on a mismatch. /// on a mismatch.
bool assert_next_object_name(string_view type_name); bool assert_next_object_name(std::string_view type_name);
/// Begins processing of an object, may perform a type check depending on the /// Begins processing of an object, may perform a type check depending on the
/// data format. /// data format.
/// @param type 16-bit ID for known types, @ref invalid_type_id otherwise. /// @param type 16-bit ID for known types, @ref invalid_type_id otherwise.
/// @param pretty_class_name Either the output of @ref type_name_or_anonymous /// @param pretty_class_name Either the output of @ref type_name_or_anonymous
/// or the optionally defined pretty name. /// or the optionally defined pretty name.
virtual bool begin_object(type_id_t type, string_view pretty_class_name) = 0; virtual bool begin_object(type_id_t type, std::string_view pretty_class_name)
= 0;
/// Ends processing of an object. /// Ends processing of an object.
virtual bool end_object() = 0; virtual bool end_object() = 0;
virtual bool begin_field(string_view name) = 0; virtual bool begin_field(std::string_view name) = 0;
virtual bool begin_field(string_view, bool& is_present) = 0; virtual bool begin_field(std::string_view, bool& is_present) = 0;
virtual bool virtual bool
begin_field(string_view name, span<const type_id_t> types, size_t& index) begin_field(std::string_view name, span<const type_id_t> types, size_t& index)
= 0; = 0;
virtual bool begin_field(string_view name, bool& is_present, virtual bool begin_field(std::string_view name, bool& is_present,
span<const type_id_t> types, size_t& index) span<const type_id_t> types, size_t& index)
= 0; = 0;
...@@ -127,7 +127,7 @@ public: ...@@ -127,7 +127,7 @@ public:
/// Reads `x` from the input. /// Reads `x` from the input.
/// @param x A reference to a builtin type. /// @param x A reference to a builtin type.
/// @returns `true` on success, `false` otherwise. /// @returns `true` on success, `false` otherwise.
virtual bool value(byte& x) = 0; virtual bool value(std::byte& x) = 0;
/// @copydoc value /// @copydoc value
virtual bool value(bool& x) = 0; virtual bool value(bool& x) = 0;
...@@ -188,13 +188,13 @@ public: ...@@ -188,13 +188,13 @@ public:
/// Reads a byte sequence from the input. /// Reads a byte sequence from the input.
/// @param x The byte sequence. /// @param x The byte sequence.
/// @returns A non-zero error code on failure, `sec::success` otherwise. /// @returns A non-zero error code on failure, `sec::success` otherwise.
virtual bool value(span<byte> x) = 0; virtual bool value(span<std::byte> x) = 0;
using super::list; using super::list;
/// Adds each boolean in `xs` to the output. Derived classes can override this /// Adds each boolean in `xs` to the output. Derived classes can override this
/// member function to pack the booleans, for example to avoid using one byte /// member function to pack the booleans, for example to avoid using one
/// for each value in a binary output format. /// byte for each value in a binary output format.
virtual bool list(std::vector<bool>& xs); virtual bool list(std::vector<bool>& xs);
protected: protected:
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
#pragma once #pragma once
#include <cstddef>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include "caf/byte.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/type_traits.hpp" #include "caf/detail/type_traits.hpp"
......
...@@ -7,25 +7,25 @@ ...@@ -7,25 +7,25 @@
#include "caf/byte_buffer.hpp" #include "caf/byte_buffer.hpp"
#include "caf/byte_span.hpp" #include "caf/byte_span.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/optional.hpp"
#include "caf/span.hpp" #include "caf/span.hpp"
#include "caf/string_view.hpp"
#include <optional>
#include <string> #include <string>
#include <string_view>
namespace caf::detail { namespace caf::detail {
class CAF_CORE_EXPORT base64 { class CAF_CORE_EXPORT base64 {
public: public:
static void encode(string_view str, std::string& out); static void encode(std::string_view str, std::string& out);
static void encode(string_view str, byte_buffer& out); static void encode(std::string_view str, byte_buffer& out);
static void encode(const_byte_span bytes, std::string& out); static void encode(const_byte_span bytes, std::string& out);
static void encode(const_byte_span bytes, byte_buffer& out); static void encode(const_byte_span bytes, byte_buffer& out);
static std::string encode(string_view str) { static std::string encode(std::string_view str) {
std::string result; std::string result;
encode(str, result); encode(str, result);
return result; return result;
...@@ -37,15 +37,15 @@ public: ...@@ -37,15 +37,15 @@ public:
return result; return result;
} }
static bool decode(string_view in, std::string& out); static bool decode(std::string_view in, std::string& out);
static bool decode(string_view in, byte_buffer& out); static bool decode(std::string_view in, byte_buffer& out);
static bool decode(const_byte_span bytes, std::string& out); static bool decode(const_byte_span bytes, std::string& out);
static bool decode(const_byte_span bytes, byte_buffer& out); static bool decode(const_byte_span bytes, byte_buffer& out);
static optional<std::string> decode(string_view in) { static std::optional<std::string> decode(std::string_view in) {
std::string result; std::string result;
if (decode(in, result)) if (decode(in, result))
return {std::move(result)}; return {std::move(result)};
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
return {}; return {};
} }
static optional<std::string> decode(const_byte_span in) { static std::optional<std::string> decode(const_byte_span in) {
std::string result; std::string result;
if (decode(in, result)) if (decode(in, result))
return {std::move(result)}; return {std::move(result)};
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <optional>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
...@@ -19,7 +20,6 @@ ...@@ -19,7 +20,6 @@
#include "caf/make_counted.hpp" #include "caf/make_counted.hpp"
#include "caf/message.hpp" #include "caf/message.hpp"
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/optional.hpp"
#include "caf/ref_counted.hpp" #include "caf/ref_counted.hpp"
#include "caf/response_promise.hpp" #include "caf/response_promise.hpp"
#include "caf/skip.hpp" #include "caf/skip.hpp"
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "caf/timespan.hpp" #include "caf/timespan.hpp"
#include "caf/typed_message_view.hpp" #include "caf/typed_message_view.hpp"
#include "caf/typed_response_promise.hpp" #include "caf/typed_response_promise.hpp"
#include "caf/variant.hpp"
namespace caf { namespace caf {
...@@ -51,7 +50,7 @@ public: ...@@ -51,7 +50,7 @@ public:
virtual bool invoke(detail::invoke_result_visitor& f, message& xs) = 0; virtual bool invoke(detail::invoke_result_visitor& f, message& xs) = 0;
optional<message> invoke(message&); std::optional<message> invoke(message&);
virtual void handle_timeout(); virtual void handle_timeout();
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/mailbox_element.hpp" #include "caf/mailbox_element.hpp"
#include "caf/message_id.hpp" #include "caf/message_id.hpp"
#include "caf/optional.hpp"
namespace caf::detail { namespace caf::detail {
......
...@@ -59,8 +59,8 @@ private: ...@@ -59,8 +59,8 @@ private:
// -- member variables ------------------------------------------------------- // -- member variables -------------------------------------------------------
const config_option_set* options_ = nullptr; const config_option_set* options_ = nullptr;
variant<none_t, config_consumer*, config_list_consumer*, std::variant<none_t, config_consumer*, config_list_consumer*,
config_value_consumer*> config_value_consumer*>
parent_; parent_;
}; };
...@@ -119,7 +119,7 @@ private: ...@@ -119,7 +119,7 @@ private:
// -- member variables ------------------------------------------------------- // -- member variables -------------------------------------------------------
const config_option_set* options_ = nullptr; const config_option_set* options_ = nullptr;
variant<none_t, config_consumer*, config_list_consumer*> parent_; std::variant<none_t, config_consumer*, config_list_consumer*> parent_;
settings* cfg_ = nullptr; settings* cfg_ = nullptr;
std::string current_key_; std::string current_key_;
std::string category_; std::string category_;
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
#include "caf/detail/type_traits.hpp" #include "caf/detail/type_traits.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/message.hpp" #include "caf/message.hpp"
#include "caf/none.hpp"
#include "caf/optional.hpp"
#include "caf/result.hpp" #include "caf/result.hpp"
#include "caf/skip.hpp" #include "caf/skip.hpp"
#include "caf/unit.hpp" #include "caf/unit.hpp"
...@@ -62,7 +60,7 @@ public: ...@@ -62,7 +60,7 @@ public:
/// Dispatches on the runtime-type of `x`. /// Dispatches on the runtime-type of `x`.
template <class... Ts> template <class... Ts>
void operator()(result<Ts...>& res) { void operator()(result<Ts...>& res) {
caf::visit([this](auto& x) { (*this)(x); }, res); std::visit([this](auto& x) { (*this)(x); }, res.get_data());
} }
// -- special-purpose handlers that don't produce results -------------------- // -- special-purpose handlers that don't produce results --------------------
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <string_view>
#include <variant> #include <variant>
#include <vector> #include <vector>
#include "caf/detail/monotonic_buffer_resource.hpp" #include "caf/detail/monotonic_buffer_resource.hpp"
#include "caf/parser_state.hpp" #include "caf/parser_state.hpp"
#include "caf/string_view.hpp"
// This JSON abstraction is designed to allocate its entire state in a monotonic // This JSON abstraction is designed to allocate its entire state in a monotonic
// buffer resource. This minimizes memory allocations and also enables us to // buffer resource. This minimizes memory allocations and also enables us to
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
using array = std::vector<value, array_allocator>; using array = std::vector<value, array_allocator>;
struct member { struct member {
string_view key; std::string_view key;
value* val = nullptr; value* val = nullptr;
}; };
...@@ -37,8 +37,8 @@ public: ...@@ -37,8 +37,8 @@ public:
using object = std::vector<member, member_allocator>; using object = std::vector<member, member_allocator>;
using data_type using data_type = std::variant<null_t, int64_t, double, bool,
= std::variant<null_t, int64_t, double, bool, string_view, array, object>; std::string_view, array, object>;
static constexpr size_t null_index = 0; static constexpr size_t null_index = 0;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "caf/allowed_unsafe_message_type.hpp" #include "caf/allowed_unsafe_message_type.hpp"
#include "caf/binary_deserializer.hpp" #include "caf/binary_deserializer.hpp"
#include "caf/binary_serializer.hpp" #include "caf/binary_serializer.hpp"
#include "caf/byte.hpp"
#include "caf/deserializer.hpp" #include "caf/deserializer.hpp"
#include "caf/detail/meta_object.hpp" #include "caf/detail/meta_object.hpp"
#include "caf/detail/padded_size.hpp" #include "caf/detail/padded_size.hpp"
...@@ -73,7 +72,7 @@ void stringify(std::string& buf, const void* ptr) { ...@@ -73,7 +72,7 @@ void stringify(std::string& buf, const void* ptr) {
namespace caf::detail { namespace caf::detail {
template <class T> template <class T>
meta_object make_meta_object(string_view type_name) { meta_object make_meta_object(std::string_view type_name) {
return { return {
type_name, type_name,
padded_size_v<T>, padded_size_v<T>,
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
#pragma once #pragma once
#include <cstddef>
#include <memory> #include <memory>
#include <new> #include <new>
#include "caf/byte.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/padded_size.hpp" #include "caf/detail/padded_size.hpp"
...@@ -25,14 +25,16 @@ public: ...@@ -25,14 +25,16 @@ public:
/// Uses placement new to create a copy of the wrapped value at given memory /// Uses placement new to create a copy of the wrapped value at given memory
/// region. /// region.
/// @returns the past-the-end pointer of the object, i.e., the first byte for /// @returns the past-the-end pointer of the object, i.e., the first byte
/// for
/// the *next* object. /// the *next* object.
virtual byte* copy_init(byte* storage) const = 0; virtual std::byte* copy_init(std::byte* storage) const = 0;
/// Uses placement new to move the wrapped value to given memory region. /// Uses placement new to move the wrapped value to given memory region.
/// @returns the past-the-end pointer of the object, i.e., the first byte for /// @returns the past-the-end pointer of the object, i.e., the first byte
/// for
/// the *next* object. /// the *next* object.
virtual byte* move_init(byte* storage) = 0; virtual std::byte* move_init(std::byte* storage) = 0;
}; };
template <class T> template <class T>
...@@ -56,12 +58,12 @@ public: ...@@ -56,12 +58,12 @@ public:
message_builder_element_impl& operator=(const message_builder_element_impl&) message_builder_element_impl& operator=(const message_builder_element_impl&)
= delete; = delete;
byte* copy_init(byte* storage) const override { std::byte* copy_init(std::byte* storage) const override {
new (storage) T(value_); new (storage) T(value_);
return storage + padded_size_v<T>; return storage + padded_size_v<T>;
} }
byte* move_init(byte* storage) override { std::byte* move_init(std::byte* storage) override {
new (storage) T(std::move(value_)); new (storage) T(std::move(value_));
return storage + padded_size_v<T>; return storage + padded_size_v<T>;
} }
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
#pragma once #pragma once
#include <atomic> #include <atomic>
#include <cstddef>
#include <cstdlib> #include <cstdlib>
#include <new> #include <new>
#include "caf/byte.hpp"
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/implicit_conversions.hpp" #include "caf/detail/implicit_conversions.hpp"
...@@ -78,12 +78,12 @@ public: ...@@ -78,12 +78,12 @@ public:
} }
/// Returns the memory region for storing the message elements. /// Returns the memory region for storing the message elements.
byte* storage() noexcept { std::byte* storage() noexcept {
return storage_; return storage_;
} }
/// @copydoc storage /// @copydoc storage
const byte* storage() const noexcept { const std::byte* storage() const noexcept {
return storage_; return storage_;
} }
...@@ -99,10 +99,10 @@ public: ...@@ -99,10 +99,10 @@ public:
/// Returns the memory location for the object at given index. /// Returns the memory location for the object at given index.
/// @pre `index < size()` /// @pre `index < size()`
byte* at(size_t index) noexcept; std::byte* at(size_t index) noexcept;
/// @copydoc at /// @copydoc at
const byte* at(size_t index) const noexcept; const std::byte* at(size_t index) const noexcept;
void inc_constructed_elements() { void inc_constructed_elements() {
++constructed_elements_; ++constructed_elements_;
...@@ -113,41 +113,42 @@ public: ...@@ -113,41 +113,42 @@ public:
init_impl(storage(), std::forward<Ts>(xs)...); init_impl(storage(), std::forward<Ts>(xs)...);
} }
byte* stepwise_init(byte* pos) { std::byte* stepwise_init(std::byte* pos) {
return pos; return pos;
} }
template <class T, class... Ts> template <class T, class... Ts>
byte* stepwise_init(byte* pos, T&& x, Ts&&... xs) { std::byte* stepwise_init(std::byte* pos, T&& x, Ts&&... xs) {
using type = strip_and_convert_t<T>; using type = strip_and_convert_t<T>;
new (pos) type(std::forward<T>(x)); new (pos) type(std::forward<T>(x));
++constructed_elements_; ++constructed_elements_;
return stepwise_init(pos + padded_size_v<type>, std::forward<Ts>(xs)...); return stepwise_init(pos + padded_size_v<type>, std::forward<Ts>(xs)...);
} }
byte* stepwise_init_from(byte* pos, const message& msg); std::byte* stepwise_init_from(std::byte* pos, const message& msg);
byte* stepwise_init_from(byte* pos, const message_data* other); std::byte* stepwise_init_from(std::byte* pos, const message_data* other);
template <class Tuple, size_t... Is> template <class Tuple, size_t... Is>
byte* stepwise_init_from(byte* pos, Tuple&& tup, std::index_sequence<Is...>) { std::byte*
stepwise_init_from(std::byte* pos, Tuple&& tup, std::index_sequence<Is...>) {
return stepwise_init(pos, std::get<Is>(std::forward<Tuple>(tup))...); return stepwise_init(pos, std::get<Is>(std::forward<Tuple>(tup))...);
} }
template <class... Ts> template <class... Ts>
byte* stepwise_init_from(byte* pos, std::tuple<Ts...>&& tup) { std::byte* stepwise_init_from(std::byte* pos, std::tuple<Ts...>&& tup) {
return stepwise_init_from(pos, std::move(tup), return stepwise_init_from(pos, std::move(tup),
std::make_index_sequence<sizeof...(Ts)>{}); std::make_index_sequence<sizeof...(Ts)>{});
} }
template <class... Ts> template <class... Ts>
byte* stepwise_init_from(byte* pos, std::tuple<Ts...>& tup) { std::byte* stepwise_init_from(std::byte* pos, std::tuple<Ts...>& tup) {
return stepwise_init_from(pos, tup, return stepwise_init_from(pos, tup,
std::make_index_sequence<sizeof...(Ts)>{}); std::make_index_sequence<sizeof...(Ts)>{});
} }
template <class... Ts> template <class... Ts>
byte* stepwise_init_from(byte* pos, const std::tuple<Ts...>& tup) { std::byte* stepwise_init_from(std::byte* pos, const std::tuple<Ts...>& tup) {
return stepwise_init_from(pos, tup, return stepwise_init_from(pos, tup,
std::make_index_sequence<sizeof...(Ts)>{}); std::make_index_sequence<sizeof...(Ts)>{});
} }
...@@ -158,24 +159,24 @@ public: ...@@ -158,24 +159,24 @@ public:
} }
private: private:
void init_impl(byte*) { void init_impl(std::byte*) {
// End of recursion. // End of recursion.
} }
template <class T, class... Ts> template <class T, class... Ts>
void init_impl(byte* storage, T&& x, Ts&&... xs) { void init_impl(std::byte* storage, T&& x, Ts&&... xs) {
using type = strip_and_convert_t<T>; using type = strip_and_convert_t<T>;
new (storage) type(std::forward<T>(x)); new (storage) type(std::forward<T>(x));
++constructed_elements_; ++constructed_elements_;
init_impl(storage + padded_size_v<type>, std::forward<Ts>(xs)...); init_impl(storage + padded_size_v<type>, std::forward<Ts>(xs)...);
} }
void init_from_impl(byte*) { void init_from_impl(std::byte*) {
// End of recursion. // End of recursion.
} }
template <class T, class... Ts> template <class T, class... Ts>
void init_from_impl(byte* pos, T&& x, Ts&&... xs) { void init_from_impl(std::byte* pos, T&& x, Ts&&... xs) {
init_from_impl(stepwise_init_from(pos, std::forward<T>(x)), init_from_impl(stepwise_init_from(pos, std::forward<T>(x)),
std::forward<Ts>(xs)...); std::forward<Ts>(xs)...);
} }
...@@ -183,7 +184,7 @@ private: ...@@ -183,7 +184,7 @@ private:
mutable std::atomic<size_t> rc_; mutable std::atomic<size_t> rc_;
type_id_list types_; type_id_list types_;
size_t constructed_elements_; size_t constructed_elements_;
byte storage_[]; std::byte storage_[];
}; };
// -- related non-members ------------------------------------------------------ // -- related non-members ------------------------------------------------------
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <string_view>
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/span.hpp" #include "caf/span.hpp"
#include "caf/string_view.hpp"
namespace caf::detail { namespace caf::detail {
...@@ -18,7 +18,7 @@ namespace caf::detail { ...@@ -18,7 +18,7 @@ namespace caf::detail {
/// pointers. /// pointers.
struct meta_object { struct meta_object {
/// Stores a human-readable representation of the type's name. /// Stores a human-readable representation of the type's name.
string_view type_name; std::string_view type_name;
/// Stores how many Bytes objects of this type require, including padding for /// Stores how many Bytes objects of this type require, including padding for
/// aligning to `max_align_t`. /// aligning to `max_align_t`.
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/type_traits.hpp" #include "caf/detail/type_traits.hpp"
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/optional.hpp"
#include "caf/response_promise.hpp" #include "caf/response_promise.hpp"
#include "caf/skip.hpp" #include "caf/skip.hpp"
#include "caf/static_visitor.hpp" #include "caf/static_visitor.hpp"
...@@ -42,16 +41,16 @@ template <class T> ...@@ -42,16 +41,16 @@ template <class T>
struct optional_message_visitor_enable_tpl { struct optional_message_visitor_enable_tpl {
static constexpr bool value static constexpr bool value
= !is_one_of<typename std::remove_const<T>::type, none_t, unit_t, skip_t, = !is_one_of<typename std::remove_const<T>::type, none_t, unit_t, skip_t,
optional<skip_t>>::value std::optional<skip_t>>::value
&& !is_message_id_wrapper<T>::value && !is_response_promise<T>::value; && !is_message_id_wrapper<T>::value && !is_response_promise<T>::value;
}; };
class CAF_CORE_EXPORT optional_message_visitor class CAF_CORE_EXPORT optional_message_visitor
: public static_visitor<optional<message>> { : public static_visitor<std::optional<message>> {
public: public:
optional_message_visitor() = default; optional_message_visitor() = default;
using opt_msg = optional<message>; using opt_msg = std::optional<message>;
opt_msg operator()(const none_t&) const { opt_msg operator()(const none_t&) const {
return none; return none;
...@@ -65,7 +64,7 @@ public: ...@@ -65,7 +64,7 @@ public:
return message{}; return message{};
} }
opt_msg operator()(optional<skip_t>& val) const { opt_msg operator()(std::optional<skip_t>& val) const {
if (val) if (val)
return none; return none;
return message{}; return message{};
...@@ -101,7 +100,7 @@ public: ...@@ -101,7 +100,7 @@ public:
} }
template <class T> template <class T>
opt_msg operator()(optional<T>& value) const { opt_msg operator()(std::optional<T>& value) const {
if (value) if (value)
return (*this)(*value); return (*this)(*value);
if (value.empty()) if (value.empty())
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <iterator> #include <iterator>
#include <string_view>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include <vector> #include <vector>
...@@ -19,7 +20,6 @@ ...@@ -19,7 +20,6 @@
#include "caf/message.hpp" #include "caf/message.hpp"
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/parser_state.hpp" #include "caf/parser_state.hpp"
#include "caf/string_view.hpp"
#include "caf/unit.hpp" #include "caf/unit.hpp"
namespace caf::detail { namespace caf::detail {
...@@ -39,7 +39,7 @@ enum class time_unit { ...@@ -39,7 +39,7 @@ enum class time_unit {
CAF_CORE_EXPORT void parse(string_parser_state& ps, time_unit& x); CAF_CORE_EXPORT void parse(string_parser_state& ps, time_unit& x);
struct literal { struct literal {
string_view str; std::string_view str;
}; };
CAF_CORE_EXPORT void parse(string_parser_state& ps, literal x); CAF_CORE_EXPORT void parse(string_parser_state& ps, literal x);
...@@ -230,17 +230,17 @@ void parse(string_parser_state& ps, ...@@ -230,17 +230,17 @@ void parse(string_parser_state& ps,
// -- convenience functions ---------------------------------------------------- // -- convenience functions ----------------------------------------------------
CAF_CORE_EXPORT CAF_CORE_EXPORT
error parse_result(const string_parser_state& ps, string_view input); error parse_result(const string_parser_state& ps, std::string_view input);
template <class T> template <class T>
auto parse(string_view str, T& x) { auto parse(std::string_view str, T& x) {
string_parser_state ps{str.begin(), str.end()}; string_parser_state ps{str.begin(), str.end()};
parse(ps, x); parse(ps, x);
return parse_result(ps, str); return parse_result(ps, str);
} }
template <class T, class Policy> template <class T, class Policy>
auto parse(string_view str, T& x, Policy policy) { auto parse(std::string_view str, T& x, Policy policy) {
string_parser_state ps{str.begin(), str.end()}; string_parser_state ps{str.begin(), str.end()};
parse(ps, x, policy); parse(ps, x, policy);
return parse_result(ps, str); return parse_result(ps, str);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <optional>
#include <type_traits> #include <type_traits>
#include "caf/config.hpp" #include "caf/config.hpp"
...@@ -14,7 +15,6 @@ ...@@ -14,7 +15,6 @@
#include "caf/detail/parser/is_digit.hpp" #include "caf/detail/parser/is_digit.hpp"
#include "caf/detail/parser/sub_ascii.hpp" #include "caf/detail/parser/sub_ascii.hpp"
#include "caf/detail/scope_guard.hpp" #include "caf/detail/scope_guard.hpp"
#include "caf/optional.hpp"
#include "caf/pec.hpp" #include "caf/pec.hpp"
CAF_PUSH_UNUSED_LABEL_WARNING CAF_PUSH_UNUSED_LABEL_WARNING
...@@ -30,7 +30,7 @@ namespace caf::detail::parser { ...@@ -30,7 +30,7 @@ namespace caf::detail::parser {
/// the pre-decimal value. /// the pre-decimal value.
template <class State, class Consumer, class ValueType> template <class State, class Consumer, class ValueType>
void read_floating_point(State& ps, Consumer&& consumer, void read_floating_point(State& ps, Consumer&& consumer,
optional<ValueType> start_value, std::optional<ValueType> start_value,
bool negative = false) { bool negative = false) {
// Any exponent larger than 511 always overflows. // Any exponent larger than 511 always overflows.
static constexpr int max_double_exponent = 511; static constexpr int max_double_exponent = 511;
...@@ -38,7 +38,7 @@ void read_floating_point(State& ps, Consumer&& consumer, ...@@ -38,7 +38,7 @@ void read_floating_point(State& ps, Consumer&& consumer,
enum sign_t { plus, minus }; enum sign_t { plus, minus };
sign_t sign; sign_t sign;
ValueType result; ValueType result;
if (start_value == none) { if (!start_value) {
sign = plus; sign = plus;
result = 0; result = 0;
} else if (*start_value < 0) { } else if (*start_value < 0) {
...@@ -72,8 +72,8 @@ void read_floating_point(State& ps, Consumer&& consumer, ...@@ -72,8 +72,8 @@ void read_floating_point(State& ps, Consumer&& consumer,
} }
// 3) Scale result. // 3) Scale result.
// Pre-computed powers of 10 for the scaling loop. // Pre-computed powers of 10 for the scaling loop.
static double powerTable[] static double powerTable[] = {1e1, 1e2, 1e4, 1e8, 1e16,
= {1e1, 1e2, 1e4, 1e8, 1e16, 1e32, 1e64, 1e128, 1e256}; 1e32, 1e64, 1e128, 1e256};
auto i = 0; auto i = 0;
if (exp < 0) { if (exp < 0) {
for (auto n = -exp; n != 0; n >>= 1, ++i) for (auto n = -exp; n != 0; n >>= 1, ++i)
...@@ -97,7 +97,7 @@ void read_floating_point(State& ps, Consumer&& consumer, ...@@ -97,7 +97,7 @@ void read_floating_point(State& ps, Consumer&& consumer,
// Definition of our parser FSM. // Definition of our parser FSM.
start(); start();
unstable_state(init) { unstable_state(init) {
epsilon_if(start_value == none, regular_init) epsilon_if(!start_value, regular_init)
epsilon(after_dec, "eE.") epsilon(after_dec, "eE.")
epsilon(after_dot, any_char) epsilon(after_dot, any_char)
} }
...@@ -173,7 +173,7 @@ template <class State, class Consumer> ...@@ -173,7 +173,7 @@ template <class State, class Consumer>
void read_floating_point(State& ps, Consumer&& consumer) { void read_floating_point(State& ps, Consumer&& consumer) {
using consumer_type = typename std::decay<Consumer>::type; using consumer_type = typename std::decay<Consumer>::type;
using value_type = typename consumer_type::value_type; using value_type = typename consumer_type::value_type;
return read_floating_point(ps, consumer, optional<value_type>{}); return read_floating_point(ps, consumer, std::optional<value_type>{});
} }
} // namespace caf::detail::parser } // namespace caf::detail::parser
......
...@@ -50,7 +50,7 @@ void read_number(State& ps, Consumer& consumer, EnableFloat = {}, ...@@ -50,7 +50,7 @@ void read_number(State& ps, Consumer& consumer, EnableFloat = {},
if (ps.code <= pec::trailing_character) if (ps.code <= pec::trailing_character)
consumer.value(result); consumer.value(result);
}); });
using odbl = optional<double>; using odbl = std::optional<double>;
// clang-format off // clang-format off
// Definition of our parser FSM. // Definition of our parser FSM.
start(); start();
...@@ -179,8 +179,8 @@ void read_number(State& ps, Consumer& consumer, EnableFloat = {}, ...@@ -179,8 +179,8 @@ void read_number(State& ps, Consumer& consumer, EnableFloat = {},
template <class State, class Consumer> template <class State, class Consumer>
void read_number_range(State& ps, Consumer& consumer, int64_t begin) { void read_number_range(State& ps, Consumer& consumer, int64_t begin) {
optional<int64_t> end; std::optional<int64_t> end;
optional<int64_t> step; std::optional<int64_t> step;
auto end_consumer = make_consumer(end); auto end_consumer = make_consumer(end);
auto step_consumer = make_consumer(step); auto step_consumer = make_consumer(step);
auto generate_2 = [&](int64_t n, int64_t m) { auto generate_2 = [&](int64_t n, int64_t m) {
......
...@@ -15,10 +15,8 @@ ...@@ -15,10 +15,8 @@
#include "caf/detail/parser/read_timespan.hpp" #include "caf/detail/parser/read_timespan.hpp"
#include "caf/detail/scope_guard.hpp" #include "caf/detail/scope_guard.hpp"
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/optional.hpp"
#include "caf/pec.hpp" #include "caf/pec.hpp"
#include "caf/timestamp.hpp" #include "caf/timestamp.hpp"
#include "caf/variant.hpp"
CAF_PUSH_UNUSED_LABEL_WARNING CAF_PUSH_UNUSED_LABEL_WARNING
...@@ -35,15 +33,15 @@ void read_number_or_timespan(State& ps, Consumer& consumer, ...@@ -35,15 +33,15 @@ void read_number_or_timespan(State& ps, Consumer& consumer,
struct interim_consumer { struct interim_consumer {
size_t invocations = 0; size_t invocations = 0;
Consumer* outer = nullptr; Consumer* outer = nullptr;
variant<none_t, int64_t, double> interim; std::variant<none_t, int64_t, double> interim;
void value(int64_t x) { void value(int64_t x) {
switch (++invocations) { switch (++invocations) {
case 1: case 1:
interim = x; interim = x;
break; break;
case 2: case 2:
CAF_ASSERT(holds_alternative<int64_t>(interim)); CAF_ASSERT(std::holds_alternative<int64_t>(interim));
outer->value(get<int64_t>(interim)); outer->value(std::get<int64_t>(interim));
interim = none; interim = none;
[[fallthrough]]; [[fallthrough]];
default: default:
...@@ -56,13 +54,13 @@ void read_number_or_timespan(State& ps, Consumer& consumer, ...@@ -56,13 +54,13 @@ void read_number_or_timespan(State& ps, Consumer& consumer,
}; };
interim_consumer ic; interim_consumer ic;
ic.outer = &consumer; ic.outer = &consumer;
auto has_int = [&] { return holds_alternative<int64_t>(ic.interim); }; auto has_int = [&] { return std::holds_alternative<int64_t>(ic.interim); };
auto has_dbl = [&] { return holds_alternative<double>(ic.interim); }; auto has_dbl = [&] { return std::holds_alternative<double>(ic.interim); };
auto get_int = [&] { return get<int64_t>(ic.interim); }; auto get_int = [&] { return std::get<int64_t>(ic.interim); };
auto g = make_scope_guard([&] { auto g = make_scope_guard([&] {
if (ps.code <= pec::trailing_character) { if (ps.code <= pec::trailing_character) {
if (has_dbl()) if (has_dbl())
consumer.value(get<double>(ic.interim)); consumer.value(std::get<double>(ic.interim));
else if (has_int()) else if (has_int())
consumer.value(get_int()); consumer.value(get_int());
} }
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
#include <chrono> #include <chrono>
#include <cstdint> #include <cstdint>
#include <optional>
#include <string> #include <string>
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/detail/parser/read_signed_integer.hpp" #include "caf/detail/parser/read_signed_integer.hpp"
#include "caf/detail/scope_guard.hpp" #include "caf/detail/scope_guard.hpp"
#include "caf/optional.hpp"
#include "caf/pec.hpp" #include "caf/pec.hpp"
#include "caf/timestamp.hpp" #include "caf/timestamp.hpp"
...@@ -24,7 +24,7 @@ namespace caf::detail::parser { ...@@ -24,7 +24,7 @@ namespace caf::detail::parser {
/// Reads a timespan. /// Reads a timespan.
template <class State, class Consumer> template <class State, class Consumer>
void read_timespan(State& ps, Consumer&& consumer, void read_timespan(State& ps, Consumer&& consumer,
optional<int64_t> num = none) { std::optional<int64_t> num = std::nullopt) {
using namespace std::chrono; using namespace std::chrono;
struct interim_consumer { struct interim_consumer {
using value_type = int64_t; using value_type = int64_t;
......
...@@ -4,13 +4,14 @@ ...@@ -4,13 +4,14 @@
#pragma once #pragma once
#include "caf/detail/core_export.hpp"
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/string_view.hpp"
#include <chrono> #include <chrono>
#include <cstdint> #include <cstdint>
#include <ctime> #include <ctime>
#include <limits> #include <limits>
#include <string_view>
#include <type_traits> #include <type_traits>
namespace caf::detail { namespace caf::detail {
...@@ -19,7 +20,7 @@ CAF_CORE_EXPORT ...@@ -19,7 +20,7 @@ CAF_CORE_EXPORT
size_t print_timestamp(char* buf, size_t buf_size, time_t ts, size_t ms); size_t print_timestamp(char* buf, size_t buf_size, time_t ts, size_t ms);
template <class Buffer> template <class Buffer>
void print_escaped(Buffer& buf, string_view str) { void print_escaped(Buffer& buf, std::string_view str) {
buf.push_back('"'); buf.push_back('"');
for (auto c : str) { for (auto c : str) {
switch (c) { switch (c) {
...@@ -64,7 +65,7 @@ void print_escaped(Buffer& buf, string_view str) { ...@@ -64,7 +65,7 @@ void print_escaped(Buffer& buf, string_view str) {
} }
template <class Buffer> template <class Buffer>
void print_unescaped(Buffer& buf, string_view str) { void print_unescaped(Buffer& buf, std::string_view str) {
buf.reserve(buf.size() + str.size()); buf.reserve(buf.size() + str.size());
auto i = str.begin(); auto i = str.begin();
auto e = str.end(); auto e = str.end();
...@@ -112,15 +113,15 @@ void print_unescaped(Buffer& buf, string_view str) { ...@@ -112,15 +113,15 @@ void print_unescaped(Buffer& buf, string_view str) {
template <class Buffer> template <class Buffer>
void print(Buffer& buf, none_t) { void print(Buffer& buf, none_t) {
using namespace caf::literals; using namespace std::literals;
auto str = "null"_sv; auto str = "null"sv;
buf.insert(buf.end(), str.begin(), str.end()); buf.insert(buf.end(), str.begin(), str.end());
} }
template <class Buffer> template <class Buffer>
void print(Buffer& buf, bool x) { void print(Buffer& buf, bool x) {
using namespace caf::literals; using namespace std::literals;
auto str = x ? "true"_sv : "false"_sv; auto str = x ? "true"sv : "false"sv;
buf.insert(buf.end(), str.begin(), str.end()); buf.insert(buf.end(), str.begin(), str.end());
} }
...@@ -132,20 +133,20 @@ std::enable_if_t<std::is_integral<T>::value> print(Buffer& buf, T x) { ...@@ -132,20 +133,20 @@ std::enable_if_t<std::is_integral<T>::value> print(Buffer& buf, T x) {
// Convert negative values into positives as necessary. // Convert negative values into positives as necessary.
if constexpr (std::is_signed<T>::value) { if constexpr (std::is_signed<T>::value) {
if (x == std::numeric_limits<T>::min()) { if (x == std::numeric_limits<T>::min()) {
using namespace caf::literals; using namespace std::literals;
// The code below would fail for the smallest value, because this value // The code below would fail for the smallest value, because this value
// has no positive counterpart. For example, an int8_t ranges from -128 to // has no positive counterpart. For example, an int8_t ranges from -128 to
// 127. Hence, an int8_t cannot represent `abs(-128)`. // 127. Hence, an int8_t cannot represent `abs(-128)`.
string_view result; std::string_view result;
if constexpr (sizeof(T) == 1) { if constexpr (sizeof(T) == 1) {
result = "-128"_sv; result = "-128"sv;
} else if constexpr (sizeof(T) == 2) { } else if constexpr (sizeof(T) == 2) {
result = "-32768"_sv; result = "-32768"sv;
} else if constexpr (sizeof(T) == 4) { } else if constexpr (sizeof(T) == 4) {
result = "-2147483648"_sv; result = "-2147483648"sv;
} else { } else {
static_assert(sizeof(T) == 8); static_assert(sizeof(T) == 8);
result = "-9223372036854775808"_sv; result = "-9223372036854775808"sv;
} }
buf.insert(buf.end(), result.begin(), result.end()); buf.insert(buf.end(), result.begin(), result.end());
return; return;
...@@ -186,13 +187,13 @@ std::enable_if_t<std::is_floating_point<T>::value> print(Buffer& buf, T x) { ...@@ -186,13 +187,13 @@ std::enable_if_t<std::is_floating_point<T>::value> print(Buffer& buf, T x) {
template <class Buffer, class Rep, class Period> template <class Buffer, class Rep, class Period>
void print(Buffer& buf, std::chrono::duration<Rep, Period> x) { void print(Buffer& buf, std::chrono::duration<Rep, Period> x) {
using namespace caf::literals; using namespace std::literals;
if (x.count() == 0) { if (x.count() == 0) {
auto str = "0s"_sv; auto str = "0s"sv;
buf.insert(buf.end(), str.begin(), str.end()); buf.insert(buf.end(), str.begin(), str.end());
return; return;
} }
auto try_print = [&buf](auto converted, string_view suffix) { auto try_print = [&buf](auto converted, std::string_view suffix) {
if (converted.count() < 1) if (converted.count() < 1)
return false; return false;
print(buf, converted.count()); print(buf, converted.count());
...@@ -213,7 +214,7 @@ void print(Buffer& buf, std::chrono::duration<Rep, Period> x) { ...@@ -213,7 +214,7 @@ void print(Buffer& buf, std::chrono::duration<Rep, Period> x) {
return; return;
auto converted = sc::duration_cast<sc::nanoseconds>(x); auto converted = sc::duration_cast<sc::nanoseconds>(x);
print(buf, converted.count()); print(buf, converted.count());
auto suffix = "ns"_sv; auto suffix = "ns"sv;
buf.insert(buf.end(), suffix.begin(), suffix.end()); buf.insert(buf.end(), suffix.begin(), suffix.end());
} }
......
...@@ -18,19 +18,19 @@ public: ...@@ -18,19 +18,19 @@ public:
size_t result = 0; size_t result = 0;
bool begin_object(type_id_t, string_view) override; bool begin_object(type_id_t, std::string_view) override;
bool end_object() override; bool end_object() override;
bool begin_field(string_view) override; bool begin_field(std::string_view) override;
bool begin_field(string_view, bool is_present) override; bool begin_field(std::string_view, bool is_present) override;
bool begin_field(string_view, span<const type_id_t> types, bool begin_field(std::string_view, span<const type_id_t> types,
size_t index) override; size_t index) override;
bool begin_field(string_view, bool is_present, span<const type_id_t> types, bool begin_field(std::string_view, bool is_present,
size_t index) override; span<const type_id_t> types, size_t index) override;
bool end_field() override; bool end_field() override;
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
bool end_sequence() override; bool end_sequence() override;
bool value(byte x) override; bool value(std::byte x) override;
bool value(bool x) override; bool value(bool x) override;
...@@ -68,13 +68,13 @@ public: ...@@ -68,13 +68,13 @@ public:
bool value(long double x) override; bool value(long double x) override;
bool value(string_view x) override; bool value(std::string_view x) override;
bool value(const std::u16string& x) override; bool value(const std::u16string& x) override;
bool value(const std::u32string& x) override; bool value(const std::u32string& x) override;
bool value(span<const byte> x) override; bool value(span<const std::byte> x) override;
using super::list; using super::list;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <chrono> #include <chrono>
#include <cstring> #include <cstring>
#include <string> #include <string>
#include <string_view>
#include <type_traits> #include <type_traits>
#include <vector> #include <vector>
...@@ -14,10 +15,8 @@ ...@@ -14,10 +15,8 @@
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/inspector_access.hpp" #include "caf/inspector_access.hpp"
#include "caf/save_inspector_base.hpp" #include "caf/save_inspector_base.hpp"
#include "caf/string_view.hpp"
#include "caf/timespan.hpp" #include "caf/timespan.hpp"
#include "caf/timestamp.hpp" #include "caf/timestamp.hpp"
#include "caf/variant.hpp"
namespace caf::detail { namespace caf::detail {
...@@ -44,17 +43,17 @@ public: ...@@ -44,17 +43,17 @@ public:
// -- serializer interface --------------------------------------------------- // -- serializer interface ---------------------------------------------------
bool begin_object(type_id_t, string_view name); bool begin_object(type_id_t, std::string_view name);
bool end_object(); bool end_object();
bool begin_field(string_view); bool begin_field(std::string_view);
bool begin_field(string_view name, bool is_present); bool begin_field(std::string_view name, bool is_present);
bool begin_field(string_view name, span<const type_id_t>, size_t); bool begin_field(std::string_view name, span<const type_id_t>, size_t);
bool begin_field(string_view name, bool, span<const type_id_t>, size_t); bool begin_field(std::string_view name, bool, span<const type_id_t>, size_t);
bool end_field(); bool end_field();
...@@ -86,7 +85,7 @@ public: ...@@ -86,7 +85,7 @@ public:
return end_sequence(); return end_sequence();
} }
bool value(byte x); bool value(std::byte x);
bool value(bool x); bool value(bool x);
...@@ -108,13 +107,13 @@ public: ...@@ -108,13 +107,13 @@ public:
bool value(timestamp x); bool value(timestamp x);
bool value(string_view x); bool value(std::string_view x);
bool value(const std::u16string& x); bool value(const std::u16string& x);
bool value(const std::u32string& x); bool value(const std::u32string& x);
bool value(span<const byte> x); bool value(span<const std::byte> x);
using super::list; using super::list;
...@@ -153,7 +152,7 @@ public: ...@@ -153,7 +152,7 @@ public:
template <class T> template <class T>
std::enable_if_t<has_to_string<T>::value std::enable_if_t<has_to_string<T>::value
&& !std::is_convertible<T, string_view>::value, && !std::is_convertible<T, std::string_view>::value,
bool> bool>
builtin_inspect(const T& x) { builtin_inspect(const T& x) {
auto str = to_string(x); auto str = to_string(x);
...@@ -174,7 +173,7 @@ public: ...@@ -174,7 +173,7 @@ public:
result_ += "null"; result_ += "null";
return true; return true;
} else if constexpr (std::is_same<T, char>::value) { } else if constexpr (std::is_same<T, char>::value) {
return value(string_view{x, strlen(x)}); return value(std::string_view{x, strlen(x)});
} else if constexpr (std::is_same<T, void>::value) { } else if constexpr (std::is_same<T, void>::value) {
sep(); sep();
result_ += "*<"; result_ += "*<";
...@@ -191,7 +190,7 @@ public: ...@@ -191,7 +190,7 @@ public:
} }
template <class T> template <class T>
bool builtin_inspect(const optional<T>& x) { bool builtin_inspect(const std::optional<T>& x) {
sep(); sep();
if (!x) { if (!x) {
result_ += "null"; result_ += "null";
...@@ -221,12 +220,12 @@ public: ...@@ -221,12 +220,12 @@ public:
static std::string render(const T& x) { static std::string render(const T& x) {
if constexpr (std::is_same<std::nullptr_t, T>::value) { if constexpr (std::is_same<std::nullptr_t, T>::value) {
return "null"; return "null";
} else if constexpr (std::is_constructible<string_view, T>::value) { } else if constexpr (std::is_constructible<std::string_view, T>::value) {
if constexpr (std::is_pointer<T>::value) { if constexpr (std::is_pointer<T>::value) {
if (x == nullptr) if (x == nullptr)
return "null"; return "null";
} }
auto str = string_view{x}; auto str = std::string_view{x};
return std::string{str.begin(), str.end()}; return std::string{str.begin(), str.end()};
} else { } else {
std::string result; std::string result;
......
...@@ -321,9 +321,8 @@ struct tl_index_of<type_list<Ts...>, T> { ...@@ -321,9 +321,8 @@ struct tl_index_of<type_list<Ts...>, T> {
static constexpr int value = tl_index_of_impl<0, T, Ts...>::value; static constexpr int value = tl_index_of_impl<0, T, Ts...>::value;
}; };
// Uncomment after having switched to C++14 template <class List, class T>
// template <class List, class T> constexpr int tl_index_of_v = tl_index_of<List, T>::value;
// inline constexpr int tl_index_of_v = tl_index_of<List, T>::value;
// int index_of(list, predicate) // int index_of(list, predicate)
......
...@@ -925,7 +925,7 @@ struct is_trivial_inspector_value<true, T> { ...@@ -925,7 +925,7 @@ struct is_trivial_inspector_value<true, T> {
template <class T> template <class T>
struct is_trivial_inspector_value<false, T> { struct is_trivial_inspector_value<false, T> {
static constexpr bool value = std::is_convertible<T, string_view>::value; static constexpr bool value = std::is_convertible<T, std::string_view>::value;
}; };
#define CAF_ADD_TRIVIAL_LOAD_INSPECTOR_VALUE(type) \ #define CAF_ADD_TRIVIAL_LOAD_INSPECTOR_VALUE(type) \
...@@ -951,9 +951,9 @@ CAF_ADD_TRIVIAL_INSPECTOR_VALUE(long double) ...@@ -951,9 +951,9 @@ CAF_ADD_TRIVIAL_INSPECTOR_VALUE(long double)
CAF_ADD_TRIVIAL_INSPECTOR_VALUE(std::u16string) CAF_ADD_TRIVIAL_INSPECTOR_VALUE(std::u16string)
CAF_ADD_TRIVIAL_INSPECTOR_VALUE(std::u32string) CAF_ADD_TRIVIAL_INSPECTOR_VALUE(std::u32string)
CAF_ADD_TRIVIAL_INSPECTOR_VALUE(std::vector<bool>) CAF_ADD_TRIVIAL_INSPECTOR_VALUE(std::vector<bool>)
CAF_ADD_TRIVIAL_INSPECTOR_VALUE(span<byte>) CAF_ADD_TRIVIAL_INSPECTOR_VALUE(span<std::byte>)
CAF_ADD_TRIVIAL_SAVE_INSPECTOR_VALUE(span<const byte>) CAF_ADD_TRIVIAL_SAVE_INSPECTOR_VALUE(span<const std::byte>)
CAF_ADD_TRIVIAL_LOAD_INSPECTOR_VALUE(std::string) CAF_ADD_TRIVIAL_LOAD_INSPECTOR_VALUE(std::string)
...@@ -989,12 +989,12 @@ struct is_builtin_inspector_type { ...@@ -989,12 +989,12 @@ struct is_builtin_inspector_type {
}; };
template <bool IsLoading> template <bool IsLoading>
struct is_builtin_inspector_type<byte, IsLoading> { struct is_builtin_inspector_type<std::byte, IsLoading> {
static constexpr bool value = true; static constexpr bool value = true;
}; };
template <bool IsLoading> template <bool IsLoading>
struct is_builtin_inspector_type<span<byte>, IsLoading> { struct is_builtin_inspector_type<span<std::byte>, IsLoading> {
static constexpr bool value = true; static constexpr bool value = true;
}; };
...@@ -1014,12 +1014,12 @@ struct is_builtin_inspector_type<std::u32string, IsLoading> { ...@@ -1014,12 +1014,12 @@ struct is_builtin_inspector_type<std::u32string, IsLoading> {
}; };
template <> template <>
struct is_builtin_inspector_type<string_view, false> { struct is_builtin_inspector_type<std::string_view, false> {
static constexpr bool value = true; static constexpr bool value = true;
}; };
template <> template <>
struct is_builtin_inspector_type<span<const byte>, false> { struct is_builtin_inspector_type<span<const std::byte>, false> {
static constexpr bool value = true; static constexpr bool value = true;
}; };
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "caf/delegated.hpp" #include "caf/delegated.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
#include "caf/response_promise.hpp" #include "caf/response_promise.hpp"
#include "caf/system_messages.hpp" #include "caf/system_messages.hpp"
#include "caf/typed_response_promise.hpp" #include "caf/typed_response_promise.hpp"
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <stdexcept>
#include <type_traits>
#include "caf/none.hpp"
#include "caf/unit.hpp"
#define CAF_VARIANT_DATA_CONCAT(x, y) x##y
#define CAF_VARIANT_DATA_GETTER(pos) \
CAF_VARIANT_DATA_CONCAT(T, pos) \
&get(std::integral_constant<int, pos>) { \
return CAF_VARIANT_DATA_CONCAT(v, pos); \
} \
const CAF_VARIANT_DATA_CONCAT(T, pos) \
& get(std::integral_constant<int, pos>) const { \
return CAF_VARIANT_DATA_CONCAT(v, pos); \
}
namespace caf::detail {
template <class T0 = unit_t, class T1 = unit_t, class T2 = unit_t,
class T3 = unit_t, class T4 = unit_t, class T5 = unit_t,
class T6 = unit_t, class T7 = unit_t, class T8 = unit_t,
class T9 = unit_t, class T10 = unit_t, class T11 = unit_t,
class T12 = unit_t, class T13 = unit_t, class T14 = unit_t,
class T15 = unit_t, class T16 = unit_t, class T17 = unit_t,
class T18 = unit_t, class T19 = unit_t, class T20 = unit_t,
class T21 = unit_t, class T22 = unit_t, class T23 = unit_t,
class T24 = unit_t, class T25 = unit_t, class T26 = unit_t,
class T27 = unit_t, class T28 = unit_t, class T29 = unit_t>
struct variant_data {
union {
T0 v0;
T1 v1;
T2 v2;
T3 v3;
T4 v4;
T5 v5;
T6 v6;
T7 v7;
T8 v8;
T9 v9;
T10 v10;
T11 v11;
T12 v12;
T13 v13;
T14 v14;
T15 v15;
T16 v16;
T17 v17;
T18 v18;
T19 v19;
T20 v20;
T21 v21;
T22 v22;
T23 v23;
T24 v24;
T25 v25;
T26 v26;
T27 v27;
T28 v28;
T29 v29;
};
variant_data() {
// nop
}
~variant_data() {
// nop
}
CAF_VARIANT_DATA_GETTER(0)
CAF_VARIANT_DATA_GETTER(1)
CAF_VARIANT_DATA_GETTER(2)
CAF_VARIANT_DATA_GETTER(3)
CAF_VARIANT_DATA_GETTER(4)
CAF_VARIANT_DATA_GETTER(5)
CAF_VARIANT_DATA_GETTER(6)
CAF_VARIANT_DATA_GETTER(7)
CAF_VARIANT_DATA_GETTER(8)
CAF_VARIANT_DATA_GETTER(9)
CAF_VARIANT_DATA_GETTER(10)
CAF_VARIANT_DATA_GETTER(11)
CAF_VARIANT_DATA_GETTER(12)
CAF_VARIANT_DATA_GETTER(13)
CAF_VARIANT_DATA_GETTER(14)
CAF_VARIANT_DATA_GETTER(15)
CAF_VARIANT_DATA_GETTER(16)
CAF_VARIANT_DATA_GETTER(17)
CAF_VARIANT_DATA_GETTER(18)
CAF_VARIANT_DATA_GETTER(19)
CAF_VARIANT_DATA_GETTER(20)
CAF_VARIANT_DATA_GETTER(21)
CAF_VARIANT_DATA_GETTER(22)
CAF_VARIANT_DATA_GETTER(23)
CAF_VARIANT_DATA_GETTER(24)
CAF_VARIANT_DATA_GETTER(25)
CAF_VARIANT_DATA_GETTER(26)
CAF_VARIANT_DATA_GETTER(27)
CAF_VARIANT_DATA_GETTER(28)
CAF_VARIANT_DATA_GETTER(29)
};
struct variant_data_destructor {
using result_type = void;
template <class T>
void operator()(T& storage) const {
storage.~T();
}
};
} // namespace caf::detail
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
#include <map> #include <map>
#include <ostream> #include <ostream>
#include <string> #include <string>
#include <string_view>
#include "caf/deep_to_string.hpp" #include "caf/deep_to_string.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
/// Maps strings to values of type `V`, but unlike `std::map<std::string, V>` /// Maps strings to values of type `V`, but unlike `std::map<std::string, V>`
/// accepts `string_view` for looking up keys efficiently. /// accepts `std::string_view` for looking up keys efficiently.
template <class V> template <class V>
class dictionary { class dictionary {
public: public:
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
using iterator_bool_pair = std::pair<iterator, bool>; using iterator_bool_pair = std::pair<iterator, bool>;
struct mapped_type_less { struct mapped_type_less {
bool operator()(const value_type& x, string_view y) const { bool operator()(const value_type& x, std::string_view y) const {
return x.first < y; return x.first < y;
} }
...@@ -63,7 +63,7 @@ public: ...@@ -63,7 +63,7 @@ public:
return x.first < y.first; return x.first < y.first;
} }
bool operator()(string_view x, const value_type& y) const { bool operator()(std::string_view x, const value_type& y) const {
return x < y.first; return x < y.first;
} }
}; };
...@@ -194,7 +194,7 @@ public: ...@@ -194,7 +194,7 @@ public:
} }
template <class T> template <class T>
iterator_bool_pair insert(string_view key, T&& value) { iterator_bool_pair insert(std::string_view key, T&& value) {
return emplace(key, V{std::forward<T>(value)}); return emplace(key, V{std::forward<T>(value)});
} }
...@@ -202,7 +202,7 @@ public: ...@@ -202,7 +202,7 @@ public:
iterator emplace_hint(iterator hint, K&& key, T&& value) { iterator emplace_hint(iterator hint, K&& key, T&& value) {
if (hint == end() || hint->first > key) if (hint == end() || hint->first > key)
return xs_.emplace(copy(std::forward<K>(key)), V{std::forward<T>(value)}) return xs_.emplace(copy(std::forward<K>(key)), V{std::forward<T>(value)})
.first; .first;
if (hint->first == key) if (hint->first == key)
return hint; return hint;
return xs_.emplace_hint(hint, copy(std::forward<K>(key)), return xs_.emplace_hint(hint, copy(std::forward<K>(key)),
...@@ -210,7 +210,7 @@ public: ...@@ -210,7 +210,7 @@ public:
} }
template <class T> template <class T>
iterator insert(iterator hint, string_view key, T&& value) { iterator insert(iterator hint, std::string_view key, T&& value) {
return emplace_hint(hint, key, std::forward<T>(value)); return emplace_hint(hint, key, std::forward<T>(value));
} }
...@@ -219,7 +219,7 @@ public: ...@@ -219,7 +219,7 @@ public:
} }
template <class T> template <class T>
iterator_bool_pair insert_or_assign(string_view key, T&& value) { iterator_bool_pair insert_or_assign(std::string_view key, T&& value) {
auto i = lower_bound(key); auto i = lower_bound(key);
if (i == end()) if (i == end())
return xs_.emplace(copy(key), V{std::forward<T>(value)}); return xs_.emplace(copy(key), V{std::forward<T>(value)});
...@@ -231,7 +231,7 @@ public: ...@@ -231,7 +231,7 @@ public:
} }
template <class T> template <class T>
iterator insert_or_assign(iterator hint, string_view key, T&& value) { iterator insert_or_assign(iterator hint, std::string_view key, T&& value) {
if (hint == end() || hint->first > key) if (hint == end() || hint->first > key)
return insert_or_assign(key, std::forward<T>(value)).first; return insert_or_assign(key, std::forward<T>(value)).first;
hint = lower_bound(hint, key); hint = lower_bound(hint, key);
...@@ -244,56 +244,56 @@ public: ...@@ -244,56 +244,56 @@ public:
// -- lookup ----------------------------------------------------------------- // -- lookup -----------------------------------------------------------------
bool contains(string_view key) const noexcept { bool contains(std::string_view key) const noexcept {
auto i = lower_bound(key); auto i = lower_bound(key);
return !(i == end() || i->first != key); return !(i == end() || i->first != key);
} }
size_t count(string_view key) const noexcept { size_t count(std::string_view key) const noexcept {
return contains(key) ? 1u : 0u; return contains(key) ? 1u : 0u;
} }
iterator find(string_view key) noexcept { iterator find(std::string_view key) noexcept {
auto i = lower_bound(key); auto i = lower_bound(key);
return i != end() && i->first == key ? i : end(); return i != end() && i->first == key ? i : end();
} }
const_iterator find(string_view key) const noexcept { const_iterator find(std::string_view key) const noexcept {
auto i = lower_bound(key); auto i = lower_bound(key);
return i != end() && i->first == key ? i : end(); return i != end() && i->first == key ? i : end();
} }
iterator lower_bound(string_view key) { iterator lower_bound(std::string_view key) {
return lower_bound(begin(), key); return lower_bound(begin(), key);
} }
const_iterator lower_bound(string_view key) const { const_iterator lower_bound(std::string_view key) const {
return lower_bound(begin(), key); return lower_bound(begin(), key);
} }
iterator upper_bound(string_view key) { iterator upper_bound(std::string_view key) {
mapped_type_less cmp; mapped_type_less cmp;
return std::upper_bound(begin(), end(), key, cmp); return std::upper_bound(begin(), end(), key, cmp);
} }
const_iterator upper_bound(string_view key) const { const_iterator upper_bound(std::string_view key) const {
mapped_type_less cmp; mapped_type_less cmp;
return std::upper_bound(begin(), end(), key, cmp); return std::upper_bound(begin(), end(), key, cmp);
} }
// -- element access --------------------------------------------------------- // -- element access ---------------------------------------------------------
mapped_type& operator[](string_view key) { mapped_type& operator[](std::string_view key) {
return insert(key, mapped_type{}).first->second; return insert(key, mapped_type{}).first->second;
} }
private: private:
iterator lower_bound(iterator from, string_view key) { iterator lower_bound(iterator from, std::string_view key) {
mapped_type_less cmp; mapped_type_less cmp;
return std::lower_bound(from, end(), key, cmp); return std::lower_bound(from, end(), key, cmp);
} }
const_iterator lower_bound(const_iterator from, string_view key) const { const_iterator lower_bound(const_iterator from, std::string_view key) const {
mapped_type_less cmp; mapped_type_less cmp;
return std::lower_bound(from, end(), key, cmp); return std::lower_bound(from, end(), key, cmp);
} }
...@@ -304,7 +304,7 @@ private: ...@@ -304,7 +304,7 @@ private:
} }
// Copies the content of `str` into a new string. // Copies the content of `str` into a new string.
static std::string copy(string_view str) { static std::string copy(std::string_view str) {
return std::string{str.begin(), str.end()}; return std::string{str.begin(), str.end()};
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <string_view>
#include <type_traits> #include <type_traits>
#include "caf/default_enum_inspect.hpp" #include "caf/default_enum_inspect.hpp"
...@@ -45,7 +46,7 @@ enum class exit_reason : uint8_t { ...@@ -45,7 +46,7 @@ enum class exit_reason : uint8_t {
CAF_CORE_EXPORT std::string to_string(exit_reason); CAF_CORE_EXPORT std::string to_string(exit_reason);
/// @relates exit_reason /// @relates exit_reason
CAF_CORE_EXPORT bool from_string(string_view, exit_reason&); CAF_CORE_EXPORT bool from_string(std::string_view, exit_reason&);
/// @relates exit_reason /// @relates exit_reason
CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<exit_reason>, CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<exit_reason>,
......
...@@ -41,7 +41,7 @@ constexpr bool is_active(observable_state x) noexcept { ...@@ -41,7 +41,7 @@ constexpr bool is_active(observable_state x) noexcept {
CAF_CORE_EXPORT std::string to_string(observable_state); CAF_CORE_EXPORT std::string to_string(observable_state);
/// @relates observable_state /// @relates observable_state
CAF_CORE_EXPORT bool from_string(string_view, observable_state&); CAF_CORE_EXPORT bool from_string(std::string_view, observable_state&);
/// @relates observable_state /// @relates observable_state
CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<observable_state>, CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<observable_state>,
......
...@@ -37,7 +37,7 @@ constexpr bool is_active(observer_state x) noexcept { ...@@ -37,7 +37,7 @@ constexpr bool is_active(observer_state x) noexcept {
CAF_CORE_EXPORT std::string to_string(observer_state); CAF_CORE_EXPORT std::string to_string(observer_state);
/// @relates observer_state /// @relates observer_state
CAF_CORE_EXPORT bool from_string(string_view, observer_state&); CAF_CORE_EXPORT bool from_string(std::string_view, observer_state&);
/// @relates observer_state /// @relates observer_state
CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<observer_state>, CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<observer_state>,
......
...@@ -4,8 +4,11 @@ ...@@ -4,8 +4,11 @@
#pragma once #pragma once
#include <cstddef>
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
#include <string_view>
#include <variant>
#include <vector> #include <vector>
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
...@@ -25,7 +28,7 @@ template <class> class dictionary; ...@@ -25,7 +28,7 @@ template <class> class dictionary;
template <class> class expected; template <class> class expected;
template <class> class intrusive_cow_ptr; template <class> class intrusive_cow_ptr;
template <class> class intrusive_ptr; template <class> class intrusive_ptr;
template <class> class optional; template <class> class [[deprecated ("use std::optional instead")]] optional;
template <class> class param; template <class> class param;
template <class> class span; template <class> class span;
template <class> class weak_intrusive_ptr; template <class> class weak_intrusive_ptr;
...@@ -57,12 +60,12 @@ template <class...> class typed_actor_view; ...@@ -57,12 +60,12 @@ template <class...> class typed_actor_view;
template <class...> class typed_event_based_actor; template <class...> class typed_event_based_actor;
template <class...> class typed_message_view; template <class...> class typed_message_view;
template <class...> class typed_response_promise; template <class...> class typed_response_promise;
template <class...> class variant;
// clang-format on // clang-format on
// -- classes ------------------------------------------------------------------ // -- classes ------------------------------------------------------------------
class [[deprecated("use std::string_view instead")]] string_view;
class [[nodiscard]] error; class [[nodiscard]] error;
class abstract_actor; class abstract_actor;
class abstract_group; class abstract_group;
...@@ -117,7 +120,7 @@ class scheduled_actor; ...@@ -117,7 +120,7 @@ class scheduled_actor;
class scoped_actor; class scoped_actor;
class serializer; class serializer;
class skip_t; class skip_t;
class string_view; class skippable_result;
class tracing_data; class tracing_data;
class tracing_data_factory; class tracing_data_factory;
class type_id_list; class type_id_list;
...@@ -146,16 +149,17 @@ struct unit_t; ...@@ -146,16 +149,17 @@ struct unit_t;
// -- free template functions -------------------------------------------------- // -- free template functions --------------------------------------------------
template <class T> template <class T>
config_option make_config_option(string_view category, string_view name, config_option make_config_option(std::string_view category,
string_view description); std::string_view name,
std::string_view description);
template <class T> template <class T>
config_option make_config_option(T& storage, string_view category, config_option make_config_option(T& storage, std::string_view category,
string_view name, string_view description); std::string_view name,
std::string_view description);
// -- enums -------------------------------------------------------------------- // -- enums --------------------------------------------------------------------
enum class byte : uint8_t;
enum class exit_reason : uint8_t; enum class exit_reason : uint8_t;
enum class invoke_message_result; enum class invoke_message_result;
enum class pec : uint8_t; enum class pec : uint8_t;
...@@ -164,9 +168,10 @@ enum class sec : uint8_t; ...@@ -164,9 +168,10 @@ enum class sec : uint8_t;
// -- aliases ------------------------------------------------------------------ // -- aliases ------------------------------------------------------------------
using actor_id = uint64_t; using actor_id = uint64_t;
using byte_buffer = std::vector<byte>; using byte [[deprecated("use std::byte instead")]] = std::byte;
using byte_span = span<byte>; using byte_buffer = std::vector<std::byte>;
using const_byte_span = span<const byte>; using byte_span = span<std::byte>;
using const_byte_span = span<const std::byte>;
using cow_string = basic_cow_string<char>; using cow_string = basic_cow_string<char>;
using cow_u16string = basic_cow_string<char16_t>; using cow_u16string = basic_cow_string<char16_t>;
using cow_u32string = basic_cow_string<char32_t>; using cow_u32string = basic_cow_string<char32_t>;
...@@ -174,7 +179,6 @@ using ip_address = ipv6_address; ...@@ -174,7 +179,6 @@ using ip_address = ipv6_address;
using ip_endpoint = ipv6_endpoint; using ip_endpoint = ipv6_endpoint;
using ip_subnet = ipv6_subnet; using ip_subnet = ipv6_subnet;
using settings = dictionary<config_value>; using settings = dictionary<config_value>;
using skippable_result = variant<delegated<message>, message, error, skip_t>;
using type_id_t = uint16_t; using type_id_t = uint16_t;
// -- functions ---------------------------------------------------------------- // -- functions ----------------------------------------------------------------
......
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
#pragma once #pragma once
#include <cstddef>
#include <cstdint> #include <cstdint>
#include <string_view>
#include <type_traits> #include <type_traits>
#include "caf/byte.hpp"
#include "caf/detail/ieee_754.hpp" #include "caf/detail/ieee_754.hpp"
#include "caf/inspector_access.hpp" #include "caf/inspector_access.hpp"
#include "caf/save_inspector_base.hpp" #include "caf/save_inspector_base.hpp"
#include "caf/span.hpp" #include "caf/span.hpp"
#include "caf/string_view.hpp"
#include "caf/type_id.hpp" #include "caf/type_id.hpp"
namespace caf::hash { namespace caf::hash {
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
return false; return false;
} }
constexpr bool begin_object(type_id_t, string_view) { constexpr bool begin_object(type_id_t, std::string_view) {
return true; return true;
} }
...@@ -48,19 +48,19 @@ public: ...@@ -48,19 +48,19 @@ public:
return true; return true;
} }
bool begin_field(string_view) { bool begin_field(std::string_view) {
return true; return true;
} }
bool begin_field(string_view, bool is_present) { bool begin_field(std::string_view, bool is_present) {
return value(static_cast<uint8_t>(is_present)); return value(static_cast<uint8_t>(is_present));
} }
bool begin_field(string_view, span<const type_id_t>, size_t index) { bool begin_field(std::string_view, span<const type_id_t>, size_t index) {
return value(index); return value(index);
} }
bool begin_field(string_view, bool is_present, span<const type_id_t>, bool begin_field(std::string_view, bool is_present, span<const type_id_t>,
size_t index) { size_t index) {
value(static_cast<uint8_t>(is_present)); value(static_cast<uint8_t>(is_present));
if (is_present) if (is_present)
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
return true; return true;
} }
bool value(byte x) noexcept { bool value(std::byte x) noexcept {
return value(static_cast<uint8_t>(x)); return value(static_cast<uint8_t>(x));
} }
...@@ -129,13 +129,13 @@ public: ...@@ -129,13 +129,13 @@ public:
return value(detail::pack754(x)); return value(detail::pack754(x));
} }
bool value(string_view x) noexcept { bool value(std::string_view x) noexcept {
auto begin = reinterpret_cast<const uint8_t*>(x.data()); auto begin = reinterpret_cast<const uint8_t*>(x.data());
append(begin, begin + x.size()); append(begin, begin + x.size());
return true; return true;
} }
bool value(span<const byte> x) noexcept { bool value(span<const std::byte> x) noexcept {
auto begin = reinterpret_cast<const uint8_t*>(x.data()); auto begin = reinterpret_cast<const uint8_t*>(x.data());
append(begin, begin + x.size()); append(begin, begin + x.size());
return true; return true;
......
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
#pragma once #pragma once
#include "caf/byte.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/ieee_754.hpp" #include "caf/detail/ieee_754.hpp"
#include "caf/save_inspector_base.hpp" #include "caf/save_inspector_base.hpp"
#include "caf/span.hpp" #include "caf/span.hpp"
#include "caf/string_view.hpp"
#include "caf/type_id.hpp" #include "caf/type_id.hpp"
#include <array> #include <array>
#include <cstddef>
#include <cstdint> #include <cstdint>
#include <string_view>
namespace caf::hash { namespace caf::hash {
...@@ -27,7 +27,7 @@ public: ...@@ -27,7 +27,7 @@ public:
using super = save_inspector_base<sha1>; using super = save_inspector_base<sha1>;
/// Array type for storing a 160-bit hash. /// Array type for storing a 160-bit hash.
using result_type = std::array<byte, hash_size>; using result_type = std::array<std::byte, hash_size>;
sha1() noexcept; sha1() noexcept;
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
return false; return false;
} }
constexpr bool begin_object(type_id_t, string_view) { constexpr bool begin_object(type_id_t, std::string_view) {
return true; return true;
} }
...@@ -43,19 +43,19 @@ public: ...@@ -43,19 +43,19 @@ public:
return true; return true;
} }
bool begin_field(string_view) { bool begin_field(std::string_view) {
return true; return true;
} }
bool begin_field(string_view, bool is_present) { bool begin_field(std::string_view, bool is_present) {
return value(static_cast<uint8_t>(is_present)); return value(static_cast<uint8_t>(is_present));
} }
bool begin_field(string_view, span<const type_id_t>, size_t index) { bool begin_field(std::string_view, span<const type_id_t>, size_t index) {
return value(index); return value(index);
} }
bool begin_field(string_view, bool is_present, span<const type_id_t>, bool begin_field(std::string_view, bool is_present, span<const type_id_t>,
size_t index) { size_t index) {
value(static_cast<uint8_t>(is_present)); value(static_cast<uint8_t>(is_present));
if (is_present) if (is_present)
...@@ -120,13 +120,13 @@ public: ...@@ -120,13 +120,13 @@ public:
return value(detail::pack754(x)); return value(detail::pack754(x));
} }
bool value(string_view x) noexcept { bool value(std::string_view x) noexcept {
auto begin = reinterpret_cast<const uint8_t*>(x.data()); auto begin = reinterpret_cast<const uint8_t*>(x.data());
append(begin, begin + x.size()); append(begin, begin + x.size());
return true; return true;
} }
bool value(span<const byte> x) noexcept { bool value(span<const std::byte> x) noexcept {
auto begin = reinterpret_cast<const uint8_t*>(x.data()); auto begin = reinterpret_cast<const uint8_t*>(x.data());
append(begin, begin + x.size()); append(begin, begin + x.size());
return true; return true;
......
This diff is collapsed.
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
#pragma once #pragma once
#include <string>
#include <string_view>
#include "caf/detail/as_mutable_ref.hpp" #include "caf/detail/as_mutable_ref.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
...@@ -15,18 +17,18 @@ template <class T> ...@@ -15,18 +17,18 @@ template <class T>
struct inspector_access_base { struct inspector_access_base {
/// Loads a mandatory field from `f`. /// Loads a mandatory field from `f`.
template <class Inspector, class IsValid, class SyncValue> template <class Inspector, class IsValid, class SyncValue>
static bool load_field(Inspector& f, string_view field_name, T& x, static bool load_field(Inspector& f, std::string_view field_name, T& x,
IsValid& is_valid, SyncValue& sync_value) { IsValid& is_valid, SyncValue& sync_value) {
if (f.begin_field(field_name) && f.apply(x)) { if (f.begin_field(field_name) && f.apply(x)) {
if (!is_valid(x)) { if (!is_valid(x)) {
f.emplace_error(sec::field_invariant_check_failed, f.emplace_error(sec::field_invariant_check_failed,
to_string(field_name)); std::string(field_name));
return false; return false;
} }
if (!sync_value()) { if (!sync_value()) {
if (!f.get_error()) if (!f.get_error())
f.emplace_error(sec::field_value_synchronization_failed, f.emplace_error(sec::field_value_synchronization_failed,
to_string(field_name)); std::string(field_name));
return false; return false;
} }
return f.end_field(); return f.end_field();
...@@ -37,7 +39,7 @@ struct inspector_access_base { ...@@ -37,7 +39,7 @@ struct inspector_access_base {
/// Loads an optional field from `f`, calling `set_fallback` if the source /// Loads an optional field from `f`, calling `set_fallback` if the source
/// contains no value for `x`. /// contains no value for `x`.
template <class Inspector, class IsValid, class SyncValue, class SetFallback> template <class Inspector, class IsValid, class SyncValue, class SetFallback>
static bool load_field(Inspector& f, string_view field_name, T& x, static bool load_field(Inspector& f, std::string_view field_name, T& x,
IsValid& is_valid, SyncValue& sync_value, IsValid& is_valid, SyncValue& sync_value,
SetFallback& set_fallback) { SetFallback& set_fallback) {
bool is_present = false; bool is_present = false;
...@@ -48,13 +50,13 @@ struct inspector_access_base { ...@@ -48,13 +50,13 @@ struct inspector_access_base {
return false; return false;
if (!is_valid(x)) { if (!is_valid(x)) {
f.emplace_error(sec::field_invariant_check_failed, f.emplace_error(sec::field_invariant_check_failed,
to_string(field_name)); std::string(field_name));
return false; return false;
} }
if (!sync_value()) { if (!sync_value()) {
if (!f.get_error()) if (!f.get_error())
f.emplace_error(sec::field_value_synchronization_failed, f.emplace_error(sec::field_value_synchronization_failed,
to_string(field_name)); std::string(field_name));
return false; return false;
} }
return f.end_field(); return f.end_field();
...@@ -65,7 +67,7 @@ struct inspector_access_base { ...@@ -65,7 +67,7 @@ struct inspector_access_base {
/// Saves a mandatory field to `f`. /// Saves a mandatory field to `f`.
template <class Inspector> template <class Inspector>
static bool save_field(Inspector& f, string_view field_name, T& x) { static bool save_field(Inspector& f, std::string_view field_name, T& x) {
return f.begin_field(field_name) // return f.begin_field(field_name) //
&& f.apply(x) // && f.apply(x) //
&& f.end_field(); && f.end_field();
...@@ -73,7 +75,7 @@ struct inspector_access_base { ...@@ -73,7 +75,7 @@ struct inspector_access_base {
/// Saves an optional field to `f`. /// Saves an optional field to `f`.
template <class Inspector, class IsPresent, class Get> template <class Inspector, class IsPresent, class Get>
static bool save_field(Inspector& f, string_view field_name, static bool save_field(Inspector& f, std::string_view field_name,
IsPresent& is_present, Get& get) { IsPresent& is_present, Get& get) {
if (is_present()) { if (is_present()) {
auto&& x = get(); auto&& x = get();
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "caf/detail/type_traits.hpp" #include "caf/detail/type_traits.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/span.hpp" #include "caf/span.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
......
...@@ -4,10 +4,8 @@ ...@@ -4,10 +4,8 @@
#pragma once #pragma once
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp"
namespace caf::detail { namespace caf::detail {
......
...@@ -121,6 +121,6 @@ CAF_CORE_EXPORT std::string to_string(const ipv4_address& x); ...@@ -121,6 +121,6 @@ CAF_CORE_EXPORT std::string to_string(const ipv4_address& x);
/// Tries to parse the content of `str` into `dest`. /// Tries to parse the content of `str` into `dest`.
/// @relates ipv4_address /// @relates ipv4_address
CAF_CORE_EXPORT error parse(string_view str, ipv4_address& dest); CAF_CORE_EXPORT error parse(std::string_view str, ipv4_address& dest);
} // namespace caf } // namespace caf
...@@ -119,6 +119,6 @@ private: ...@@ -119,6 +119,6 @@ private:
}; };
}; };
CAF_CORE_EXPORT error parse(string_view str, ipv6_address& dest); CAF_CORE_EXPORT error parse(std::string_view str, ipv6_address& dest);
} // namespace caf } // namespace caf
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "caf/deserializer.hpp" #include "caf/deserializer.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/json.hpp" #include "caf/detail/json.hpp"
#include "caf/string_view.hpp"
#include <string_view>
#include <variant> #include <variant>
namespace caf { namespace caf {
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
} }
}; };
using json_key = string_view; using json_key = std::string_view;
using value_type using value_type
= std::variant<const detail::json::value*, const detail::json::object*, = std::variant<const detail::json::value*, const detail::json::object*,
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
// -- constants -------------------------------------------------------------- // -- constants --------------------------------------------------------------
/// The value value for `field_type_suffix()`. /// The value value for `field_type_suffix()`.
static constexpr string_view field_type_suffix_default = "-type"; static constexpr std::string_view field_type_suffix_default = "-type";
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
...@@ -103,12 +103,12 @@ public: ...@@ -103,12 +103,12 @@ public:
/// Returns the suffix for generating type annotation fields for variant /// Returns the suffix for generating type annotation fields for variant
/// fields. For example, CAF inserts field called "@foo${field_type_suffix}" /// fields. For example, CAF inserts field called "@foo${field_type_suffix}"
/// for a variant field called "foo". /// for a variant field called "foo".
[[nodiscard]] string_view field_type_suffix() const noexcept { [[nodiscard]] std::string_view field_type_suffix() const noexcept {
return field_type_suffix_; return field_type_suffix_;
} }
/// Configures whether the writer omits empty fields. /// Configures whether the writer omits empty fields.
void field_type_suffix(string_view suffix) noexcept { void field_type_suffix(std::string_view suffix) noexcept {
field_type_suffix_ = suffix; field_type_suffix_ = suffix;
} }
...@@ -121,7 +121,7 @@ public: ...@@ -121,7 +121,7 @@ public:
/// Hence, the buffer pointed to by the string view must remain valid /// Hence, the buffer pointed to by the string view must remain valid
/// until either destroying this reader or calling `reset`. /// until either destroying this reader or calling `reset`.
/// @note Implicitly calls `reset`. /// @note Implicitly calls `reset`.
bool load(string_view json_text); bool load(std::string_view json_text);
/// Reverts the state of the reader back to where it was after calling `load`. /// Reverts the state of the reader back to where it was after calling `load`.
/// @post The reader is ready for attempting to deserialize another /// @post The reader is ready for attempting to deserialize another
...@@ -135,20 +135,20 @@ public: ...@@ -135,20 +135,20 @@ public:
bool fetch_next_object_type(type_id_t& type) override; bool fetch_next_object_type(type_id_t& type) override;
bool fetch_next_object_name(string_view& type_name) override; bool fetch_next_object_name(std::string_view& type_name) override;
bool begin_object(type_id_t type, string_view name) override; bool begin_object(type_id_t type, std::string_view name) override;
bool end_object() override; bool end_object() override;
bool begin_field(string_view) override; bool begin_field(std::string_view) override;
bool begin_field(string_view name, bool& is_present) override; bool begin_field(std::string_view name, bool& is_present) override;
bool begin_field(string_view name, span<const type_id_t> types, bool begin_field(std::string_view name, span<const type_id_t> types,
size_t& index) override; size_t& index) override;
bool begin_field(string_view name, bool& is_present, bool begin_field(std::string_view name, bool& is_present,
span<const type_id_t> types, size_t& index) override; span<const type_id_t> types, size_t& index) override;
bool end_field() override; bool end_field() override;
...@@ -169,7 +169,7 @@ public: ...@@ -169,7 +169,7 @@ public:
bool end_associative_array() override; bool end_associative_array() override;
bool value(byte& x) override; bool value(std::byte& x) override;
bool value(bool& x) override; bool value(bool& x) override;
...@@ -201,7 +201,7 @@ public: ...@@ -201,7 +201,7 @@ public:
bool value(std::u32string& x) override; bool value(std::u32string& x) override;
bool value(span<byte> x) override; bool value(span<std::byte> x) override;
private: private:
[[nodiscard]] position pos() const noexcept; [[nodiscard]] position pos() const noexcept;
...@@ -210,7 +210,7 @@ private: ...@@ -210,7 +210,7 @@ private:
std::string current_field_name(); std::string current_field_name();
std::string mandatory_field_missing_str(string_view name); std::string mandatory_field_missing_str(std::string_view name);
template <bool PopOrAdvanceOnSuccess, class F> template <bool PopOrAdvanceOnSuccess, class F>
bool consume(const char* fun_name, F f); bool consume(const char* fun_name, F f);
...@@ -243,10 +243,10 @@ private: ...@@ -243,10 +243,10 @@ private:
detail::json::value* root_ = nullptr; detail::json::value* root_ = nullptr;
string_view field_type_suffix_ = field_type_suffix_default; std::string_view field_type_suffix_ = field_type_suffix_default;
/// Keeps track of the current field for better debugging output. /// Keeps track of the current field for better debugging output.
std::vector<string_view> field_; std::vector<std::string_view> field_;
}; };
} // namespace caf } // namespace caf
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
static constexpr bool skip_object_type_annotation_default = false; static constexpr bool skip_object_type_annotation_default = false;
/// The value value for `field_type_suffix()`. /// The value value for `field_type_suffix()`.
static constexpr string_view field_type_suffix_default = "-type"; static constexpr std::string_view field_type_suffix_default = "-type";
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
/// Returns a string view into the internal buffer. /// Returns a string view into the internal buffer.
/// @warning This view becomes invalid when calling any non-const member /// @warning This view becomes invalid when calling any non-const member
/// function on the writer object. /// function on the writer object.
[[nodiscard]] string_view str() const noexcept { [[nodiscard]] std::string_view str() const noexcept {
return {buf_.data(), buf_.size()}; return {buf_.data(), buf_.size()};
} }
...@@ -106,12 +106,12 @@ public: ...@@ -106,12 +106,12 @@ public:
/// Returns the suffix for generating type annotation fields for variant /// Returns the suffix for generating type annotation fields for variant
/// fields. For example, CAF inserts field called "@foo${field_type_suffix}" /// fields. For example, CAF inserts field called "@foo${field_type_suffix}"
/// for a variant field called "foo". /// for a variant field called "foo".
[[nodiscard]] string_view field_type_suffix() const noexcept { [[nodiscard]] std::string_view field_type_suffix() const noexcept {
return field_type_suffix_; return field_type_suffix_;
} }
/// Configures whether the writer omits empty fields. /// Configures whether the writer omits empty fields.
void field_type_suffix(string_view suffix) noexcept { void field_type_suffix(std::string_view suffix) noexcept {
field_type_suffix_ = suffix; field_type_suffix_ = suffix;
} }
...@@ -124,18 +124,18 @@ public: ...@@ -124,18 +124,18 @@ public:
// -- overrides -------------------------------------------------------------- // -- overrides --------------------------------------------------------------
bool begin_object(type_id_t type, string_view name) override; bool begin_object(type_id_t type, std::string_view name) override;
bool end_object() override; bool end_object() override;
bool begin_field(string_view) override; bool begin_field(std::string_view) override;
bool begin_field(string_view name, bool is_present) override; bool begin_field(std::string_view name, bool is_present) override;
bool begin_field(string_view name, span<const type_id_t> types, bool begin_field(std::string_view name, span<const type_id_t> types,
size_t index) override; size_t index) override;
bool begin_field(string_view name, bool is_present, bool begin_field(std::string_view name, bool is_present,
span<const type_id_t> types, size_t index) override; span<const type_id_t> types, size_t index) override;
bool end_field() override; bool end_field() override;
...@@ -156,7 +156,7 @@ public: ...@@ -156,7 +156,7 @@ public:
bool end_associative_array() override; bool end_associative_array() override;
bool value(byte x) override; bool value(std::byte x) override;
bool value(bool x) override; bool value(bool x) override;
...@@ -182,13 +182,13 @@ public: ...@@ -182,13 +182,13 @@ public:
bool value(long double x) override; bool value(long double x) override;
bool value(string_view x) override; bool value(std::string_view x) override;
bool value(const std::u16string& x) override; bool value(const std::u16string& x) override;
bool value(const std::u32string& x) override; bool value(const std::u32string& x) override;
bool value(span<const byte> x) override; bool value(span<const std::byte> x) override;
private: private:
// -- implementation details ------------------------------------------------- // -- implementation details -------------------------------------------------
...@@ -242,7 +242,7 @@ private: ...@@ -242,7 +242,7 @@ private:
} }
// Adds `str` to the output buffer. // Adds `str` to the output buffer.
void add(string_view str) { void add(std::string_view str) {
buf_.insert(buf_.end(), str.begin(), str.end()); buf_.insert(buf_.end(), str.begin(), str.end());
} }
...@@ -280,7 +280,7 @@ private: ...@@ -280,7 +280,7 @@ private:
// Configures whether we omit the top-level '@type' annotation. // Configures whether we omit the top-level '@type' annotation.
bool skip_object_type_annotation_ = false; bool skip_object_type_annotation_ = false;
string_view field_type_suffix_ = field_type_suffix_default; std::string_view field_type_suffix_ = field_type_suffix_default;
}; };
} // namespace caf } // namespace caf
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <string_view>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
...@@ -11,7 +12,6 @@ ...@@ -11,7 +12,6 @@
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/error.hpp" #include "caf/error.hpp"
#include "caf/inspector_access.hpp" #include "caf/inspector_access.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
template <class T, class U, class Predicate> template <class T, class U, class Predicate>
struct field_with_invariant_and_fallback_t { struct field_with_invariant_and_fallback_t {
string_view field_name; std::string_view field_name;
T* val; T* val;
U fallback; U fallback;
Predicate predicate; Predicate predicate;
...@@ -83,7 +83,7 @@ public: ...@@ -83,7 +83,7 @@ public:
template <class T, class U> template <class T, class U>
struct field_with_fallback_t { struct field_with_fallback_t {
string_view field_name; std::string_view field_name;
T* val; T* val;
U fallback; U fallback;
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
template <class T, class Predicate> template <class T, class Predicate>
struct field_with_invariant_t { struct field_with_invariant_t {
string_view field_name; std::string_view field_name;
T* val; T* val;
Predicate predicate; Predicate predicate;
...@@ -130,7 +130,7 @@ public: ...@@ -130,7 +130,7 @@ public:
template <class T> template <class T>
struct field_t { struct field_t {
string_view field_name; std::string_view field_name;
T* val; T* val;
template <class Inspector> template <class Inspector>
...@@ -158,7 +158,7 @@ public: ...@@ -158,7 +158,7 @@ public:
template <class T, class Set, class U, class Predicate> template <class T, class Set, class U, class Predicate>
struct virt_field_with_invariant_and_fallback_t { struct virt_field_with_invariant_and_fallback_t {
string_view field_name; std::string_view field_name;
Set set; Set set;
U fallback; U fallback;
Predicate predicate; Predicate predicate;
...@@ -174,7 +174,7 @@ public: ...@@ -174,7 +174,7 @@ public:
template <class T, class Set, class U> template <class T, class Set, class U>
struct virt_field_with_fallback_t { struct virt_field_with_fallback_t {
string_view field_name; std::string_view field_name;
Set set; Set set;
U fallback; U fallback;
...@@ -200,7 +200,7 @@ public: ...@@ -200,7 +200,7 @@ public:
template <class T, class Set, class Predicate> template <class T, class Set, class Predicate>
struct virt_field_with_invariant_t { struct virt_field_with_invariant_t {
string_view field_name; std::string_view field_name;
Set set; Set set;
Predicate predicate; Predicate predicate;
...@@ -224,7 +224,7 @@ public: ...@@ -224,7 +224,7 @@ public:
template <class T, class Set> template <class T, class Set>
struct virt_field_t { struct virt_field_t {
string_view field_name; std::string_view field_name;
Set set; Set set;
template <class Inspector> template <class Inspector>
...@@ -255,7 +255,7 @@ public: ...@@ -255,7 +255,7 @@ public:
template <class T, class Reset, class Set> template <class T, class Reset, class Set>
struct optional_virt_field_t { struct optional_virt_field_t {
string_view field_name; std::string_view field_name;
Reset reset; Reset reset;
Set set; Set set;
...@@ -273,7 +273,7 @@ public: ...@@ -273,7 +273,7 @@ public:
template <class Inspector, class LoadCallback> template <class Inspector, class LoadCallback>
struct object_with_load_callback_t { struct object_with_load_callback_t {
type_id_t object_type; type_id_t object_type;
string_view object_name; std::string_view object_name;
Inspector* f; Inspector* f;
LoadCallback load_callback; LoadCallback load_callback;
...@@ -296,7 +296,7 @@ public: ...@@ -296,7 +296,7 @@ public:
return f->end_object(); return f->end_object();
} }
auto pretty_name(string_view name) && { auto pretty_name(std::string_view name) && {
return object_t{object_type, name, f}; return object_t{object_type, name, f};
} }
...@@ -309,7 +309,7 @@ public: ...@@ -309,7 +309,7 @@ public:
template <class Inspector> template <class Inspector>
struct object_t { struct object_t {
type_id_t object_type; type_id_t object_type;
string_view object_name; std::string_view object_name;
Inspector* f; Inspector* f;
template <class... Fields> template <class... Fields>
...@@ -319,7 +319,7 @@ public: ...@@ -319,7 +319,7 @@ public:
&& f->end_object(); && f->end_object();
} }
auto pretty_name(string_view name) && { auto pretty_name(std::string_view name) && {
return object_t{object_type, name, f}; return object_t{object_type, name, f};
} }
...@@ -342,13 +342,13 @@ public: ...@@ -342,13 +342,13 @@ public:
// -- factory functions ------------------------------------------------------ // -- factory functions ------------------------------------------------------
template <class T> template <class T>
static auto field(string_view name, T& x) { static auto field(std::string_view name, T& x) {
static_assert(!std::is_const<T>::value); static_assert(!std::is_const<T>::value);
return field_t<T>{name, &x}; return field_t<T>{name, &x};
} }
template <class Get, class Set> template <class Get, class Set>
static auto field(string_view name, Get get, Set set) { static auto field(std::string_view name, Get get, Set set) {
using field_type = std::decay_t<decltype(get())>; using field_type = std::decay_t<decltype(get())>;
using setter_result = decltype(set(std::declval<field_type&&>())); using setter_result = decltype(set(std::declval<field_type&&>()));
if constexpr (std::is_same<setter_result, error>::value if constexpr (std::is_same<setter_result, error>::value
...@@ -368,7 +368,7 @@ public: ...@@ -368,7 +368,7 @@ public:
template <class IsPresent, class Get, class Reset, class Set> template <class IsPresent, class Get, class Reset, class Set>
static auto static auto
field(string_view name, IsPresent&&, Get&& get, Reset reset, Set set) { field(std::string_view name, IsPresent&&, Get&& get, Reset reset, Set set) {
using field_type = std::decay_t<decltype(get())>; using field_type = std::decay_t<decltype(get())>;
using setter_result = decltype(set(std::declval<field_type&&>())); using setter_result = decltype(set(std::declval<field_type&&>()));
if constexpr (std::is_same<setter_result, error>::value if constexpr (std::is_same<setter_result, error>::value
......
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
type_name_or_anonymous<T>(), dptr()}; type_name_or_anonymous<T>(), dptr()};
} }
constexpr auto virtual_object(string_view type_name) noexcept { constexpr auto virtual_object(std::string_view type_name) noexcept {
return super::object_t<Subtype>{invalid_type_id, type_name, dptr()}; return super::object_t<Subtype>{invalid_type_id, type_name, dptr()};
} }
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
template <class T, size_t... Is> template <class T, size_t... Is>
bool tuple(T& xs, std::index_sequence<Is...>) { bool tuple(T& xs, std::index_sequence<Is...>) {
return dref().begin_tuple(sizeof...(Is)) return dref().begin_tuple(sizeof...(Is))
&& (detail::load(dref(), get<Is>(xs)) && ...) // && (detail::load(dref(), std::get<Is>(xs)) && ...) //
&& dref().end_tuple(); && dref().end_tuple();
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <string_view>
#include <thread> #include <thread>
#include <type_traits> #include <type_traits>
#include <typeinfo> #include <typeinfo>
...@@ -28,7 +29,6 @@ ...@@ -28,7 +29,6 @@
#include "caf/intrusive/fifo_inbox.hpp" #include "caf/intrusive/fifo_inbox.hpp"
#include "caf/intrusive/singly_linked.hpp" #include "caf/intrusive/singly_linked.hpp"
#include "caf/ref_counted.hpp" #include "caf/ref_counted.hpp"
#include "caf/string_view.hpp"
#include "caf/timestamp.hpp" #include "caf/timestamp.hpp"
#include "caf/unifyn.hpp" #include "caf/unifyn.hpp"
...@@ -99,9 +99,9 @@ public: ...@@ -99,9 +99,9 @@ public:
event& operator=(const event&) = default; event& operator=(const event&) = default;
event(unsigned lvl, unsigned line, string_view cat, string_view full_fun, event(unsigned lvl, unsigned line, std::string_view cat,
string_view fun, string_view fn, std::string msg, std::thread::id t, std::string_view full_fun, std::string_view fun, std::string_view fn,
actor_id a, timestamp ts); std::string msg, std::thread::id t, actor_id a, timestamp ts);
// -- member variables ----------------------------------------------------- // -- member variables -----------------------------------------------------
...@@ -112,16 +112,16 @@ public: ...@@ -112,16 +112,16 @@ public:
unsigned line_number; unsigned line_number;
/// Name of the category (component) logging the event. /// Name of the category (component) logging the event.
string_view category_name; std::string_view category_name;
/// Name of the current function as reported by `__PRETTY_FUNCTION__`. /// Name of the current function as reported by `__PRETTY_FUNCTION__`.
string_view pretty_fun; std::string_view pretty_fun;
/// Name of the current function as reported by `__func__`. /// Name of the current function as reported by `__func__`.
string_view simple_fun; std::string_view simple_fun;
/// Name of the current file. /// Name of the current file.
string_view file_name; std::string_view file_name;
/// User-provided message. /// User-provided message.
std::string message; std::string message;
...@@ -181,7 +181,7 @@ public: ...@@ -181,7 +181,7 @@ public:
line_builder& operator<<(const std::string& str); line_builder& operator<<(const std::string& str);
line_builder& operator<<(string_view str); line_builder& operator<<(std::string_view str);
line_builder& operator<<(const char* str); line_builder& operator<<(const char* str);
...@@ -213,7 +213,7 @@ public: ...@@ -213,7 +213,7 @@ public:
/// Returns whether the logger is configured to accept input for given /// Returns whether the logger is configured to accept input for given
/// component and log level. /// component and log level.
bool accepts(unsigned level, string_view component_name); bool accepts(unsigned level, std::string_view component_name);
/// Returns the output format used for the log file. /// Returns the output format used for the log file.
const line_format& file_format() const { const line_format& file_format() const {
...@@ -253,7 +253,7 @@ public: ...@@ -253,7 +253,7 @@ public:
static line_format parse_format(const std::string& format_str); static line_format parse_format(const std::string& format_str);
/// Skips path in `filename`. /// Skips path in `filename`.
static string_view skip_path(string_view filename); static std::string_view skip_path(std::string_view filename);
// -- utility functions ------------------------------------------------------ // -- utility functions ------------------------------------------------------
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <string_view>
#include "caf/config_option.hpp" #include "caf/config_option.hpp"
#include "caf/config_value.hpp" #include "caf/config_value.hpp"
...@@ -13,7 +14,6 @@ ...@@ -13,7 +14,6 @@
#include "caf/expected.hpp" #include "caf/expected.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/pec.hpp" #include "caf/pec.hpp"
#include "caf/string_view.hpp"
namespace caf::detail { namespace caf::detail {
...@@ -53,15 +53,17 @@ namespace caf { ...@@ -53,15 +53,17 @@ namespace caf {
/// Creates a config option that synchronizes with `storage`. /// Creates a config option that synchronizes with `storage`.
template <class T> template <class T>
config_option make_config_option(string_view category, string_view name, config_option make_config_option(std::string_view category,
string_view description) { std::string_view name,
std::string_view description) {
return {category, name, description, detail::option_meta_state_instance<T>()}; return {category, name, description, detail::option_meta_state_instance<T>()};
} }
/// Creates a config option that synchronizes with `storage`. /// Creates a config option that synchronizes with `storage`.
template <class T> template <class T>
config_option make_config_option(T& storage, string_view category, config_option make_config_option(T& storage, std::string_view category,
string_view name, string_view description) { std::string_view name,
std::string_view description) {
return {category, name, description, detail::option_meta_state_instance<T>(), return {category, name, description, detail::option_meta_state_instance<T>(),
std::addressof(storage)}; std::addressof(storage)};
} }
...@@ -70,7 +72,7 @@ config_option make_config_option(T& storage, string_view category, ...@@ -70,7 +72,7 @@ config_option make_config_option(T& storage, string_view category,
// Inverts the value when writing to `storage`. // Inverts the value when writing to `storage`.
CAF_CORE_EXPORT config_option CAF_CORE_EXPORT config_option
make_negated_config_option(bool& storage, string_view category, make_negated_config_option(bool& storage, std::string_view category,
string_view name, string_view description); std::string_view name, std::string_view description);
} // namespace caf } // namespace caf
...@@ -72,8 +72,8 @@ public: ...@@ -72,8 +72,8 @@ public:
void assign(message_handler what); void assign(message_handler what);
/// Runs this handler and returns its (optional) result. /// Runs this handler and returns its (optional) result.
optional<message> operator()(message& arg) { std::optional<message> operator()(message& arg) {
return (impl_) ? impl_->invoke(arg) : none; return (impl_) ? impl_->invoke(arg) : std::nullopt;
} }
/// Runs this handler with callback. /// Runs this handler with callback.
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/ref_counted.hpp" #include "caf/ref_counted.hpp"
#include "caf/uri.hpp" #include "caf/uri.hpp"
#include "caf/variant.hpp"
namespace caf { namespace caf {
...@@ -51,7 +50,7 @@ public: ...@@ -51,7 +50,7 @@ public:
static bool valid(const host_id_type& x) noexcept; static bool valid(const host_id_type& x) noexcept;
static bool can_parse(string_view str) noexcept; static bool can_parse(std::string_view str) noexcept;
static node_id local(const actor_system_config&); static node_id local(const actor_system_config&);
...@@ -74,7 +73,7 @@ class CAF_CORE_EXPORT node_id_data : public ref_counted { ...@@ -74,7 +73,7 @@ class CAF_CORE_EXPORT node_id_data : public ref_counted {
public: public:
// -- member types ----------------------------------------------------------- // -- member types -----------------------------------------------------------
using variant_type = variant<uri, hashed_node_id>; using variant_type = std::variant<uri, hashed_node_id>;
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
...@@ -153,7 +152,7 @@ public: ...@@ -153,7 +152,7 @@ public:
void swap(node_id& other) noexcept; void swap(node_id& other) noexcept;
/// Returns whether `parse` would produce a valid node ID. /// Returns whether `parse` would produce a valid node ID.
static bool can_parse(string_view str) noexcept; static bool can_parse(std::string_view str) noexcept;
// -- friend functions ------------------------------------------------------- // -- friend functions -------------------------------------------------------
...@@ -203,7 +202,7 @@ private: ...@@ -203,7 +202,7 @@ private:
/// Returns whether `x` contains an URI. /// Returns whether `x` contains an URI.
/// @relates node_id /// @relates node_id
inline bool wraps_uri(const node_id& x) noexcept { inline bool wraps_uri(const node_id& x) noexcept {
return x && holds_alternative<uri>(x->content); return x && std::holds_alternative<uri>(x->content);
} }
/// @relates node_id /// @relates node_id
...@@ -279,11 +278,11 @@ CAF_CORE_EXPORT node_id make_node_id( ...@@ -279,11 +278,11 @@ CAF_CORE_EXPORT node_id make_node_id(
/// @param process_id System-wide unique process identifier. /// @param process_id System-wide unique process identifier.
/// @param host_hash Unique node ID as hexadecimal string representation. /// @param host_hash Unique node ID as hexadecimal string representation.
/// @relates node_id /// @relates node_id
CAF_CORE_EXPORT optional<node_id> make_node_id(uint32_t process_id, CAF_CORE_EXPORT std::optional<node_id> make_node_id(uint32_t process_id,
string_view host_hash); std::string_view host_hash);
/// @relates node_id /// @relates node_id
CAF_CORE_EXPORT error parse(string_view str, node_id& dest); CAF_CORE_EXPORT error parse(std::string_view str, node_id& dest);
} // namespace caf } // namespace caf
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/unit.hpp" #include "caf/unit.hpp"
CAF_PUSH_DEPRECATED_WARNING
namespace caf { namespace caf {
/// A C++17 compatible `optional` implementation. /// A C++17 compatible `optional` implementation.
...@@ -477,3 +479,5 @@ bool operator>=(const T& lhs, const optional<T>& rhs) { ...@@ -477,3 +479,5 @@ bool operator>=(const T& lhs, const optional<T>& rhs) {
} }
} // namespace caf } // namespace caf
CAF_POP_WARNINGS
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
#include <cctype> #include <cctype>
#include <cstdint> #include <cstdint>
#include <string_view>
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/pec.hpp" #include "caf/pec.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
...@@ -137,6 +137,6 @@ auto make_error(const parser_state<Iterator, Sentinel>& ps, Ts&&... xs) ...@@ -137,6 +137,6 @@ auto make_error(const parser_state<Iterator, Sentinel>& ps, Ts&&... xs)
} }
/// Specialization for parsers operating on string views. /// Specialization for parsers operating on string views.
using string_parser_state = parser_state<string_view::iterator>; using string_parser_state = parser_state<std::string_view::iterator>;
} // namespace caf } // namespace caf
...@@ -72,7 +72,7 @@ enum class pec : uint8_t { ...@@ -72,7 +72,7 @@ enum class pec : uint8_t {
CAF_CORE_EXPORT std::string to_string(pec); CAF_CORE_EXPORT std::string to_string(pec);
/// @relates pec /// @relates pec
CAF_CORE_EXPORT bool from_string(string_view, pec&); CAF_CORE_EXPORT bool from_string(std::string_view, pec&);
/// @relates pec /// @relates pec
CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<pec>, pec&); CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<pec>, pec&);
......
...@@ -17,12 +17,15 @@ replies_to_type_name(size_t input_size, const std::string* input, ...@@ -17,12 +17,15 @@ replies_to_type_name(size_t input_size, const std::string* input,
size_t output_size, const std::string* output); size_t output_size, const std::string* output);
template <class... Is> template <class... Is>
struct replies_to { struct [[deprecated("write 'result<foo>(bar)' instead of "
"'replies_to<bar>::with<foo>'")]] replies_to {
template <class... Os> template <class... Os>
using with = result<Os...>(Is...); using with = result<Os...>(Is...);
}; };
template <class... Is> template <class... Is>
using reacts_to = result<void>(Is...); using reacts_to
[[deprecated("write 'result<void>(foo)' instead of 'reacts_to<foo>'")]]
= result<void>(Is...);
} // namespace caf } // namespace caf
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
namespace caf { namespace caf {
......
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
#pragma once #pragma once
#include <type_traits>
#include "caf/default_sum_type_access.hpp"
#include "caf/delegated.hpp" #include "caf/delegated.hpp"
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/detail/type_traits.hpp" #include "caf/detail/type_traits.hpp"
...@@ -16,8 +13,10 @@ ...@@ -16,8 +13,10 @@
#include "caf/message.hpp" #include "caf/message.hpp"
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/skip.hpp" #include "caf/skip.hpp"
#include "caf/sum_type.hpp" #include "caf/variant_wrapper.hpp"
#include "caf/variant.hpp"
#include <type_traits>
#include <variant>
namespace caf::detail { namespace caf::detail {
...@@ -71,15 +70,20 @@ public: ...@@ -71,15 +70,20 @@ public:
} }
/// @private /// @private
auto& get_data() { auto& get_data() & {
return content_; return content_;
} }
/// @private /// @private
const auto& get_data() const { const auto& get_data() const& {
return content_; return content_;
} }
/// @private
auto&& get_data() && {
return std::move(content_);
}
protected: protected:
explicit result_base(detail::result_base_message_init) : content_(message{}) { explicit result_base(detail::result_base_message_init) : content_(message{}) {
// nop // nop
...@@ -91,7 +95,7 @@ protected: ...@@ -91,7 +95,7 @@ protected:
// nop // nop
} }
variant<delegated<Ts...>, message, error> content_; std::variant<delegated<Ts...>, message, error> content_;
}; };
// -- result<Ts...> and its specializations ------------------------------------ // -- result<Ts...> and its specializations ------------------------------------
...@@ -235,19 +239,73 @@ auto make_result(Ts&&... xs) { ...@@ -235,19 +239,73 @@ auto make_result(Ts&&... xs) {
// -- special type alias for a skippable result<message> ----------------------- // -- special type alias for a skippable result<message> -----------------------
/// Similar to `result<message>`, but also allows to *skip* a message. /// Similar to `result<message>`, but also allows to *skip* a message.
using skippable_result = variant<delegated<message>, message, error, skip_t>; class skippable_result {
public:
skippable_result() = default;
skippable_result(skippable_result&&) = default;
skippable_result(const skippable_result&) = default;
skippable_result& operator=(skippable_result&&) = default;
skippable_result& operator=(const skippable_result&) = default;
// -- sum type access to result<Ts...> ----------------------------------------- skippable_result(delegated<message> x) : content_(std::move(x)) {
// nop
}
template <class... Ts> skippable_result(message x) : content_(std::move(x)) {
struct sum_type_access<result<Ts...>> : default_sum_type_access<result<Ts...>> { // nop
// nop }
skippable_result(error x) : content_(std::move(x)) {
// nop
}
skippable_result(skip_t x) : content_(std::move(x)) {
// nop
}
skippable_result(expected<message> x) {
if (x)
this->content_ = std::move(*x);
else
this->content_ = std::move(x.error());
}
skippable_result& operator=(expected<message> x) {
if (x)
this->content_ = std::move(*x);
else
this->content_ = std::move(x.error());
return *this;
}
/// @private
auto& get_data() {
return content_;
}
/// @private
const auto& get_data() const {
return content_;
}
private:
std::variant<delegated<message>, message, error, skip_t> content_;
}; };
// -- type traits --------------------------------------------------------------
template <class T> template <class T>
struct is_result : std::false_type {}; struct is_result : std::false_type {};
template <class... Ts> template <class... Ts>
struct is_result<result<Ts...>> : std::true_type {}; struct is_result<result<Ts...>> : std::true_type {};
// -- enable std::variant-style interface --------------------------------------
template <class... Ts>
struct is_variant_wrapper<result<Ts...>> : std::true_type {};
template <>
struct is_variant_wrapper<skippable_result> : std::true_type {};
} // namespace caf } // namespace caf
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <string_view>
#include <utility> #include <utility>
#include "caf/detail/as_mutable_ref.hpp" #include "caf/detail/as_mutable_ref.hpp"
...@@ -11,7 +12,6 @@ ...@@ -11,7 +12,6 @@
#include "caf/error.hpp" #include "caf/error.hpp"
#include "caf/inspector_access.hpp" #include "caf/inspector_access.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
template <class T, class U> template <class T, class U>
struct field_with_fallback_t { struct field_with_fallback_t {
string_view field_name; std::string_view field_name;
T* val; T* val;
U fallback; U fallback;
...@@ -87,7 +87,7 @@ public: ...@@ -87,7 +87,7 @@ public:
template <class T> template <class T>
struct field_t { struct field_t {
string_view field_name; std::string_view field_name;
T* val; T* val;
template <class Inspector> template <class Inspector>
...@@ -110,7 +110,7 @@ public: ...@@ -110,7 +110,7 @@ public:
template <class T, class Get, class U> template <class T, class Get, class U>
struct virt_field_with_fallback_t { struct virt_field_with_fallback_t {
string_view field_name; std::string_view field_name;
Get get; Get get;
U fallback; U fallback;
...@@ -128,7 +128,7 @@ public: ...@@ -128,7 +128,7 @@ public:
template <class T, class Get> template <class T, class Get>
struct virt_field_t { struct virt_field_t {
string_view field_name; std::string_view field_name;
Get get; Get get;
template <class Inspector> template <class Inspector>
...@@ -154,7 +154,7 @@ public: ...@@ -154,7 +154,7 @@ public:
template <class T, class IsPresent, class Get> template <class T, class IsPresent, class Get>
struct optional_virt_field_t { struct optional_virt_field_t {
string_view field_name; std::string_view field_name;
IsPresent is_present; IsPresent is_present;
Get get; Get get;
...@@ -169,7 +169,7 @@ public: ...@@ -169,7 +169,7 @@ public:
template <class Inspector, class SaveCallback> template <class Inspector, class SaveCallback>
struct object_with_save_callback_t { struct object_with_save_callback_t {
type_id_t object_type; type_id_t object_type;
string_view object_name; std::string_view object_name;
Inspector* f; Inspector* f;
SaveCallback save_callback; SaveCallback save_callback;
...@@ -192,7 +192,7 @@ public: ...@@ -192,7 +192,7 @@ public:
return f->end_object(); return f->end_object();
} }
auto pretty_name(string_view name) && { auto pretty_name(std::string_view name) && {
return object_t{name, f}; return object_t{name, f};
} }
...@@ -205,7 +205,7 @@ public: ...@@ -205,7 +205,7 @@ public:
template <class Inspector> template <class Inspector>
struct object_t { struct object_t {
type_id_t object_type; type_id_t object_type;
string_view object_name; std::string_view object_name;
Inspector* f; Inspector* f;
template <class... Fields> template <class... Fields>
...@@ -215,7 +215,7 @@ public: ...@@ -215,7 +215,7 @@ public:
&& f->end_object(); && f->end_object();
} }
auto pretty_name(string_view name) && { auto pretty_name(std::string_view name) && {
return object_t{object_type, name, f}; return object_t{object_type, name, f};
} }
...@@ -238,19 +238,20 @@ public: ...@@ -238,19 +238,20 @@ public:
// -- factory functions ------------------------------------------------------ // -- factory functions ------------------------------------------------------
template <class T> template <class T>
static auto field(string_view name, T& x) { static auto field(std::string_view name, T& x) {
static_assert(!std::is_const<T>::value); static_assert(!std::is_const<T>::value);
return field_t<T>{name, std::addressof(x)}; return field_t<T>{name, std::addressof(x)};
} }
template <class Get, class Set> template <class Get, class Set>
static auto field(string_view name, Get get, Set&&) { static auto field(std::string_view name, Get get, Set&&) {
using field_type = std::decay_t<decltype(get())>; using field_type = std::decay_t<decltype(get())>;
return virt_field_t<field_type, Get>{name, get}; return virt_field_t<field_type, Get>{name, get};
} }
template <class IsPresent, class Get, class... Ts> template <class IsPresent, class Get, class... Ts>
static auto field(string_view name, IsPresent is_present, Get get, Ts&&...) { static auto
field(std::string_view name, IsPresent is_present, Get get, Ts&&...) {
using field_type = std::decay_t<decltype(get())>; using field_type = std::decay_t<decltype(get())>;
return optional_virt_field_t<field_type, IsPresent, Get>{ return optional_virt_field_t<field_type, IsPresent, Get>{
name, name,
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#pragma once #pragma once
#include <string_view>
#include <tuple>
#include "caf/inspector_access.hpp" #include "caf/inspector_access.hpp"
#include "caf/save_inspector.hpp" #include "caf/save_inspector.hpp"
...@@ -24,7 +27,7 @@ public: ...@@ -24,7 +27,7 @@ public:
type_name_or_anonymous<T>(), dptr()}; type_name_or_anonymous<T>(), dptr()};
} }
constexpr auto virtual_object(string_view type_name) noexcept { constexpr auto virtual_object(std::string_view type_name) noexcept {
return super::object_t<Subtype>{invalid_type_id, type_name, dptr()}; return super::object_t<Subtype>{invalid_type_id, type_name, dptr()};
} }
...@@ -70,6 +73,7 @@ public: ...@@ -70,6 +73,7 @@ public:
template <class T, size_t... Is> template <class T, size_t... Is>
bool tuple(const T& xs, std::index_sequence<Is...>) { bool tuple(const T& xs, std::index_sequence<Is...>) {
using std::get;
return dref().begin_tuple(sizeof...(Is)) // return dref().begin_tuple(sizeof...(Is)) //
&& (detail::save(dref(), get<Is>(xs)) && ...) // && (detail::save(dref(), get<Is>(xs)) && ...) //
&& dref().end_tuple(); && dref().end_tuple();
......
...@@ -182,7 +182,7 @@ enum class sec : uint8_t { ...@@ -182,7 +182,7 @@ enum class sec : uint8_t {
CAF_CORE_EXPORT std::string to_string(sec); CAF_CORE_EXPORT std::string to_string(sec);
/// @relates sec /// @relates sec
CAF_CORE_EXPORT bool from_string(string_view, sec&); CAF_CORE_EXPORT bool from_string(std::string_view, sec&);
/// @relates sec /// @relates sec
CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<sec>, sec&); CAF_CORE_EXPORT bool from_integer(std::underlying_type_t<sec>, sec&);
......
...@@ -7,18 +7,17 @@ ...@@ -7,18 +7,17 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <string_view>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "caf/byte.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/squashed_int.hpp" #include "caf/detail/squashed_int.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/save_inspector_base.hpp" #include "caf/save_inspector_base.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/span.hpp" #include "caf/span.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
...@@ -53,20 +52,20 @@ public: ...@@ -53,20 +52,20 @@ public:
/// Begins processing of an object. May save the type information to the /// Begins processing of an object. May save the type information to the
/// underlying storage to allow a @ref deserializer to retrieve and check the /// underlying storage to allow a @ref deserializer to retrieve and check the
/// type information for data formats that provide deserialization. /// type information for data formats that provide deserialization.
virtual bool begin_object(type_id_t type, string_view name) = 0; virtual bool begin_object(type_id_t type, std::string_view name) = 0;
/// Ends processing of an object. /// Ends processing of an object.
virtual bool end_object() = 0; virtual bool end_object() = 0;
virtual bool begin_field(string_view) = 0; virtual bool begin_field(std::string_view) = 0;
virtual bool begin_field(string_view name, bool is_present) = 0; virtual bool begin_field(std::string_view name, bool is_present) = 0;
virtual bool virtual bool
begin_field(string_view name, span<const type_id_t> types, size_t index) begin_field(std::string_view name, span<const type_id_t> types, size_t index)
= 0; = 0;
virtual bool begin_field(string_view name, bool is_present, virtual bool begin_field(std::string_view name, bool is_present,
span<const type_id_t> types, size_t index) span<const type_id_t> types, size_t index)
= 0; = 0;
...@@ -104,7 +103,7 @@ public: ...@@ -104,7 +103,7 @@ public:
/// Adds `x` to the output. /// Adds `x` to the output.
/// @param x A value for a builtin type. /// @param x A value for a builtin type.
/// @returns `true` on success, `false` otherwise. /// @returns `true` on success, `false` otherwise.
virtual bool value(byte x) = 0; virtual bool value(std::byte x) = 0;
/// @copydoc value /// @copydoc value
virtual bool value(bool x) = 0; virtual bool value(bool x) = 0;
...@@ -149,7 +148,7 @@ public: ...@@ -149,7 +148,7 @@ public:
virtual bool value(long double x) = 0; virtual bool value(long double x) = 0;
/// @copydoc value /// @copydoc value
virtual bool value(string_view x) = 0; virtual bool value(std::string_view x) = 0;
/// @copydoc value /// @copydoc value
virtual bool value(const std::u16string& x) = 0; virtual bool value(const std::u16string& x) = 0;
...@@ -160,13 +159,13 @@ public: ...@@ -160,13 +159,13 @@ public:
/// Adds `x` as raw byte block to the output. /// Adds `x` as raw byte block to the output.
/// @param x The byte sequence. /// @param x The byte sequence.
/// @returns A non-zero error code on failure, `sec::success` otherwise. /// @returns A non-zero error code on failure, `sec::success` otherwise.
virtual bool value(span<const byte> x) = 0; virtual bool value(span<const std::byte> x) = 0;
using super::list; using super::list;
/// Adds each boolean in `xs` to the output. Derived classes can override this /// Adds each boolean in `xs` to the output. Derived classes can override this
/// member function to pack the booleans, for example to avoid using one byte /// member function to pack the booleans, for example to avoid using one
/// for each value in a binary output format. /// byte for each value in a binary output format.
virtual bool list(const std::vector<bool>& xs); virtual bool list(const std::vector<bool>& xs);
protected: protected:
......
...@@ -4,14 +4,13 @@ ...@@ -4,14 +4,13 @@
#pragma once #pragma once
#include <string_view>
#include "caf/config_value.hpp" #include "caf/config_value.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/move_if_not_ptr.hpp" #include "caf/detail/move_if_not_ptr.hpp"
#include "caf/dictionary.hpp" #include "caf/dictionary.hpp"
#include "caf/optional.hpp"
#include "caf/raise_error.hpp" #include "caf/raise_error.hpp"
#include "caf/string_view.hpp"
#include "caf/sum_type.hpp"
namespace caf { namespace caf {
...@@ -25,12 +24,12 @@ CAF_CORE_EXPORT std::string to_string(const settings& xs); ...@@ -25,12 +24,12 @@ CAF_CORE_EXPORT std::string to_string(const settings& xs);
/// Tries to retrieve the value associated to `name` from `xs`. /// Tries to retrieve the value associated to `name` from `xs`.
/// @relates config_value /// @relates config_value
CAF_CORE_EXPORT const config_value* get_if(const settings* xs, CAF_CORE_EXPORT const config_value* get_if(const settings* xs,
string_view name); std::string_view name);
/// Tries to retrieve the value associated to `name` from `xs`. /// Tries to retrieve the value associated to `name` from `xs`.
/// @relates config_value /// @relates config_value
template <class T> template <class T>
auto get_if(const settings* xs, string_view name) { auto get_if(const settings* xs, std::string_view name) {
auto value = get_if(xs, name); auto value = get_if(xs, name);
using result_type = decltype(get_if<T>(value)); using result_type = decltype(get_if<T>(value));
return value ? get_if<T>(value) : result_type{}; return value ? get_if<T>(value) : result_type{};
...@@ -39,7 +38,7 @@ auto get_if(const settings* xs, string_view name) { ...@@ -39,7 +38,7 @@ auto get_if(const settings* xs, string_view name) {
/// Returns whether `xs` associates a value of type `T` to `name`. /// Returns whether `xs` associates a value of type `T` to `name`.
/// @relates config_value /// @relates config_value
template <class T> template <class T>
bool holds_alternative(const settings& xs, string_view name) { bool holds_alternative(const settings& xs, std::string_view name) {
if (auto value = get_if(&xs, name)) if (auto value = get_if(&xs, name))
return holds_alternative<T>(*value); return holds_alternative<T>(*value);
else else
...@@ -49,7 +48,7 @@ bool holds_alternative(const settings& xs, string_view name) { ...@@ -49,7 +48,7 @@ bool holds_alternative(const settings& xs, string_view name) {
/// Retrieves the value associated to `name` from `xs`. /// Retrieves the value associated to `name` from `xs`.
/// @relates actor_system_config /// @relates actor_system_config
template <class T> template <class T>
T get(const settings& xs, string_view name) { T get(const settings& xs, std::string_view name) {
auto result = get_if<T>(&xs, name); auto result = get_if<T>(&xs, name);
CAF_ASSERT(result); CAF_ASSERT(result);
return detail::move_if_not_ptr(result); return detail::move_if_not_ptr(result);
...@@ -58,7 +57,7 @@ T get(const settings& xs, string_view name) { ...@@ -58,7 +57,7 @@ T get(const settings& xs, string_view name) {
/// Retrieves the value associated to `name` from `xs` or returns `fallback`. /// Retrieves the value associated to `name` from `xs` or returns `fallback`.
/// @relates actor_system_config /// @relates actor_system_config
template <class To = get_or_auto_deduce, class Fallback> template <class To = get_or_auto_deduce, class Fallback>
auto get_or(const settings& xs, string_view name, Fallback&& fallback) { auto get_or(const settings& xs, std::string_view name, Fallback&& fallback) {
if (auto ptr = get_if(&xs, name)) { if (auto ptr = get_if(&xs, name)) {
return get_or<To>(*ptr, std::forward<Fallback>(fallback)); return get_or<To>(*ptr, std::forward<Fallback>(fallback));
} else if constexpr (std::is_same<To, get_or_auto_deduce>::value) { } else if constexpr (std::is_same<To, get_or_auto_deduce>::value) {
...@@ -73,7 +72,7 @@ auto get_or(const settings& xs, string_view name, Fallback&& fallback) { ...@@ -73,7 +72,7 @@ auto get_or(const settings& xs, string_view name, Fallback&& fallback) {
/// type `T`. /// type `T`.
/// @relates actor_system_config /// @relates actor_system_config
template <class T> template <class T>
expected<T> get_as(const settings& xs, string_view name) { expected<T> get_as(const settings& xs, std::string_view name) {
if (auto ptr = get_if(&xs, name)) if (auto ptr = get_if(&xs, name))
return get_as<T>(*ptr); return get_as<T>(*ptr);
else else
...@@ -81,7 +80,7 @@ expected<T> get_as(const settings& xs, string_view name) { ...@@ -81,7 +80,7 @@ expected<T> get_as(const settings& xs, string_view name) {
} }
/// @private /// @private
CAF_CORE_EXPORT config_value& put_impl(settings& dict, string_view name, CAF_CORE_EXPORT config_value& put_impl(settings& dict, std::string_view name,
config_value& value); config_value& value);
/// Converts `value` to a `config_value` and assigns it to `key`. /// Converts `value` to a `config_value` and assigns it to `key`.
...@@ -89,7 +88,7 @@ CAF_CORE_EXPORT config_value& put_impl(settings& dict, string_view name, ...@@ -89,7 +88,7 @@ CAF_CORE_EXPORT config_value& put_impl(settings& dict, string_view name,
/// @param key Human-readable nested keys in the form `category.key`. /// @param key Human-readable nested keys in the form `category.key`.
/// @param value New value for given `key`. /// @param value New value for given `key`.
template <class T> template <class T>
config_value& put(settings& dict, string_view key, T&& value) { config_value& put(settings& dict, std::string_view key, T&& value) {
config_value tmp{std::forward<T>(value)}; config_value tmp{std::forward<T>(value)};
return put_impl(dict, key, tmp); return put_impl(dict, key, tmp);
} }
...@@ -100,7 +99,7 @@ config_value& put(settings& dict, string_view key, T&& value) { ...@@ -100,7 +99,7 @@ config_value& put(settings& dict, string_view key, T&& value) {
/// @param key Human-readable nested keys in the form `category.key`. /// @param key Human-readable nested keys in the form `category.key`.
/// @param value New value for given `key`. /// @param value New value for given `key`.
template <class T> template <class T>
void put_missing(settings& xs, string_view key, T&& value) { void put_missing(settings& xs, std::string_view key, T&& value) {
if (get_if(&xs, key) != nullptr) if (get_if(&xs, key) != nullptr)
return; return;
config_value tmp{std::forward<T>(value)}; config_value tmp{std::forward<T>(value)};
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#pragma once #pragma once
#include <array> #include <array>
#include <cstddef>
#include <type_traits> #include <type_traits>
#include "caf/byte.hpp"
#include "caf/detail/type_traits.hpp" #include "caf/detail/type_traits.hpp"
namespace caf { namespace caf {
...@@ -197,13 +197,13 @@ auto cend(const span<T>& xs) -> decltype(xs.cend()) { ...@@ -197,13 +197,13 @@ auto cend(const span<T>& xs) -> decltype(xs.cend()) {
} }
template <class T> template <class T>
span<const byte> as_bytes(span<T> xs) { span<const std::byte> as_bytes(span<T> xs) {
return {reinterpret_cast<const byte*>(xs.data()), xs.size_bytes()}; return {reinterpret_cast<const std::byte*>(xs.data()), xs.size_bytes()};
} }
template <class T> template <class T>
span<byte> as_writable_bytes(span<T> xs) { span<std::byte> as_writable_bytes(span<T> xs) {
return {reinterpret_cast<byte*>(xs.data()), xs.size_bytes()}; return {reinterpret_cast<std::byte*>(xs.data()), xs.size_bytes()};
} }
/// Convenience function to make using `caf::span` more convenient without the /// Convenience function to make using `caf::span` more convenient without the
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
namespace caf {
template <class Result = void>
struct static_visitor {
using result_type = Result;
};
} // namespace caf
...@@ -8,38 +8,43 @@ ...@@ -8,38 +8,43 @@
#include <limits> #include <limits>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <string_view>
#include <type_traits> #include <type_traits>
#include <vector> #include <vector>
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/detail/type_traits.hpp" #include "caf/detail/type_traits.hpp"
#include "caf/string_view.hpp"
namespace caf { namespace caf {
// provide boost::split compatible interface // provide boost::split compatible interface
constexpr string_view is_any_of(string_view arg) noexcept { constexpr std::string_view is_any_of(std::string_view arg) noexcept {
return arg; return arg;
} }
constexpr bool token_compress_on = false; constexpr bool token_compress_on = false;
CAF_CORE_EXPORT void split(std::vector<std::string>& result, string_view str, CAF_CORE_EXPORT void split(std::vector<std::string>& result,
string_view delims, bool keep_all = true); std::string_view str, std::string_view delims,
bool keep_all = true);
CAF_CORE_EXPORT void split(std::vector<string_view>& result, string_view str, CAF_CORE_EXPORT void split(std::vector<std::string_view>& result,
string_view delims, bool keep_all = true); std::string_view str, std::string_view delims,
bool keep_all = true);
CAF_CORE_EXPORT void split(std::vector<std::string>& result, string_view str, CAF_CORE_EXPORT void split(std::vector<std::string>& result,
char delim, bool keep_all = true); std::string_view str, char delim,
bool keep_all = true);
CAF_CORE_EXPORT void split(std::vector<string_view>& result, string_view str, CAF_CORE_EXPORT void split(std::vector<std::string_view>& result,
char delim, bool keep_all = true); std::string_view str, char delim,
bool keep_all = true);
template <class InputIterator> template <class InputIterator>
std::string join(InputIterator first, InputIterator last, string_view glue) { std::string
join(InputIterator first, InputIterator last, std::string_view glue) {
if (first == last) if (first == last)
return {}; return {};
std::ostringstream oss; std::ostringstream oss;
...@@ -50,18 +55,18 @@ std::string join(InputIterator first, InputIterator last, string_view glue) { ...@@ -50,18 +55,18 @@ std::string join(InputIterator first, InputIterator last, string_view glue) {
} }
template <class Container> template <class Container>
std::string join(const Container& c, string_view glue) { std::string join(const Container& c, std::string_view glue) {
return join(c.begin(), c.end(), glue); return join(c.begin(), c.end(), glue);
} }
/// Replaces all occurrences of `what` by `with` in `str`. /// Replaces all occurrences of `what` by `with` in `str`.
CAF_CORE_EXPORT void CAF_CORE_EXPORT void replace_all(std::string& str, std::string_view what,
replace_all(std::string& str, string_view what, string_view with); std::string_view with);
/// Returns whether `str` begins with `prefix`. /// Returns whether `str` begins with `prefix`.
CAF_CORE_EXPORT bool starts_with(string_view str, string_view prefix); CAF_CORE_EXPORT bool starts_with(std::string_view str, std::string_view prefix);
/// Returns whether `str` ends with `suffix`. /// Returns whether `str` ends with `suffix`.
CAF_CORE_EXPORT bool ends_with(string_view str, string_view suffix); CAF_CORE_EXPORT bool ends_with(std::string_view str, std::string_view suffix);
} // namespace caf } // namespace caf
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include "caf/config.hpp"
#include "caf/detail/comparable.hpp" #include "caf/detail/comparable.hpp"
#include "caf/detail/core_export.hpp" #include "caf/detail/core_export.hpp"
#include "caf/fwd.hpp"
namespace caf { namespace caf {
...@@ -200,8 +202,8 @@ public: ...@@ -200,8 +202,8 @@ public:
int compare(size_type pos, size_type n, const_pointer str) const noexcept; int compare(size_type pos, size_type n, const_pointer str) const noexcept;
int compare(size_type pos1, size_type n1, const_pointer s, size_type n2) const int compare(size_type pos1, size_type n1, const_pointer s,
noexcept; size_type n2) const noexcept;
size_type find(string_view str, size_type pos = 0) const noexcept; size_type find(string_view str, size_type pos = 0) const noexcept;
...@@ -223,8 +225,8 @@ public: ...@@ -223,8 +225,8 @@ public:
size_type find_first_of(value_type ch, size_type pos = 0) const noexcept; size_type find_first_of(value_type ch, size_type pos = 0) const noexcept;
size_type find_first_of(const_pointer str, size_type pos, size_type n) const size_type find_first_of(const_pointer str, size_type pos,
noexcept; size_type n) const noexcept;
size_type find_first_of(const_pointer str, size_type pos = 0) const noexcept; size_type find_first_of(const_pointer str, size_type pos = 0) const noexcept;
...@@ -232,40 +234,42 @@ public: ...@@ -232,40 +234,42 @@ public:
size_type find_last_of(value_type ch, size_type pos = npos) const noexcept; size_type find_last_of(value_type ch, size_type pos = npos) const noexcept;
size_type find_last_of(const_pointer str, size_type pos, size_type n) const size_type find_last_of(const_pointer str, size_type pos,
noexcept; size_type n) const noexcept;
size_type find_last_of(const_pointer str, size_type pos = npos) const size_type find_last_of(const_pointer str,
noexcept; size_type pos = npos) const noexcept;
size_type find_first_not_of(string_view str, size_type pos = 0) const size_type find_first_not_of(string_view str,
noexcept; size_type pos = 0) const noexcept;
size_type find_first_not_of(value_type ch, size_type pos = 0) const noexcept; size_type find_first_not_of(value_type ch, size_type pos = 0) const noexcept;
size_type find_first_not_of(const_pointer str, size_type pos, size_type find_first_not_of(const_pointer str, size_type pos,
size_type n) const noexcept; size_type n) const noexcept;
size_type find_first_not_of(const_pointer str, size_type pos = 0) const size_type find_first_not_of(const_pointer str,
noexcept; size_type pos = 0) const noexcept;
size_type find_last_not_of(string_view str, size_type pos = npos) const size_type find_last_not_of(string_view str,
noexcept; size_type pos = npos) const noexcept;
size_type find_last_not_of(value_type ch, size_type pos = npos) const size_type find_last_not_of(value_type ch,
noexcept; size_type pos = npos) const noexcept;
size_type find_last_not_of(const_pointer str, size_type pos, size_type find_last_not_of(const_pointer str, size_type pos,
size_type n) const noexcept; size_type n) const noexcept;
size_type find_last_not_of(const_pointer str, size_type pos = npos) const size_type find_last_not_of(const_pointer str,
noexcept; size_type pos = npos) const noexcept;
private: private:
const char* data_; const char* data_;
size_t size_; size_t size_;
}; };
CAF_PUSH_DEPRECATED_WARNING
/// @relates string_view /// @relates string_view
inline std::string to_string(string_view x) { inline std::string to_string(string_view x) {
return std::string{x.begin(), x.end()}; return std::string{x.begin(), x.end()};
...@@ -286,3 +290,5 @@ namespace std { ...@@ -286,3 +290,5 @@ namespace std {
CAF_CORE_EXPORT std::ostream& operator<<(std::ostream& out, caf::string_view); CAF_CORE_EXPORT std::ostream& operator<<(std::ostream& out, caf::string_view);
} // namespace std } // namespace std
CAF_POP_WARNINGS
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/detail/type_list.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/sum_type_access.hpp"
#include "caf/sum_type_token.hpp"
namespace caf {
/// @defgroup SumType Sum Types
/// Opt-in sum type concept for `variant`-style types.
/// @{
/// Concept for checking whether `T` supports the sum type API by specializing
/// `sum_type_access`.
template <class T>
constexpr bool SumType() {
return has_sum_type_access<typename std::decay<T>::type>::value;
}
/// Concept for checking whether all `Ts` support the sum type API by
/// specializing `sum_type_access`.
template <class... Ts>
constexpr bool SumTypes() {
using namespace detail;
using types = type_list<decay_t<Ts>...>;
return tl_forall<types, has_sum_type_access>::value;
}
template <class Trait, class T, bool = Trait::specialized>
struct sum_type_index {
static constexpr int value = -1;
};
template <class Trait, class T>
struct sum_type_index<Trait, T, true> {
static constexpr int value =
detail::tl_index_of<typename Trait::types, T>::value;
};
template <class Trait, class T>
constexpr sum_type_token<T, sum_type_index<Trait, T>::value>
make_sum_type_token() {
return {};
}
/// Returns a reference to the value of a sum type.
/// @pre `holds_alternative<T>(x)`
template <class T, class U, class Trait = sum_type_access<U>>
auto get(U& x) -> decltype(Trait::get(x, make_sum_type_token<Trait, T>())) {
return Trait::get(x, make_sum_type_token<Trait, T>());
}
/// Returns a reference to the value of a sum type.
/// @pre `holds_alternative<T>(x)`
template <class T, class U, class Trait = sum_type_access<U>>
auto get(const U& x)
-> decltype(Trait::get(x, make_sum_type_token<Trait, T>())) {
return Trait::get(x, make_sum_type_token<Trait, T>());
}
/// Returns a pointer to the value of a sum type if it is of type `T`,
/// `nullptr` otherwise.
template <class T, class U, class Trait = sum_type_access<U>>
auto get_if(U* x)
-> decltype(Trait::get_if(x, make_sum_type_token<Trait, T>())) {
return Trait::get_if(x, make_sum_type_token<Trait, T>());
}
/// Returns a pointer to the value of a sum type if it is of type `T`,
/// `nullptr` otherwise.
template <class T, class U, class Trait = sum_type_access<U>>
auto get_if(const U* x)
-> decltype(Trait::get_if(x, make_sum_type_token<Trait, T>())) {
return Trait::get_if(x, make_sum_type_token<Trait, T>());
}
/// Returns whether a sum type has a value of type `T`.
template <class T, class U>
bool holds_alternative(const U& x) {
using namespace detail;
using trait = sum_type_access<U>;
return trait::is(x, make_sum_type_token<trait, T>());
}
template <bool Valid, class F, class... Ts>
struct sum_type_visit_result_impl {
using type = decltype((std::declval<F&>())(
std::declval<typename sum_type_access<Ts>::type0&>()...));
};
template <class F, class... Ts>
struct sum_type_visit_result_impl<false, F, Ts...> {};
template <class F, class... Ts>
struct sum_type_visit_result
: sum_type_visit_result_impl<
detail::conjunction<SumType<Ts>()...>::value, F, Ts...> {};
template <class F, class... Ts>
using sum_type_visit_result_t =
typename sum_type_visit_result<detail::decay_t<F>,
detail::decay_t<Ts>...>::type;
template <class Result, size_t I, class Visitor>
struct visit_impl_continuation;
template <class Result, size_t I>
struct visit_impl {
template <class Visitor, class T, class... Ts>
static Result apply(Visitor&& f, T&& x, Ts&&... xs) {
visit_impl_continuation<Result, I - 1, Visitor> continuation{f};
using trait = sum_type_access<detail::decay_t<T>>;
return trait::template apply<Result>(x, continuation,
std::forward<Ts>(xs)...);
}
};
template <class Result>
struct visit_impl<Result, 0> {
template <class Visitor, class... Ts>
static Result apply(Visitor&& f, Ts&&... xs) {
return f(std::forward<Ts>(xs)...);
}
};
template <class Result, size_t I, class Visitor>
struct visit_impl_continuation {
Visitor& f;
template <class... Ts>
Result operator()(Ts&&... xs) {
return visit_impl<Result, I>::apply(f, std::forward<Ts>(xs)...);
}
};
/// Applies the values of any number of sum types to the visitor.
template <class Visitor, class T, class... Ts,
class Result = sum_type_visit_result_t<Visitor, T, Ts...>>
detail::enable_if_t<SumTypes<T, Ts...>(), Result>
visit(Visitor&& f, T&& x, Ts&&... xs) {
return visit_impl<Result, sizeof...(Ts) + 1>::apply(std::forward<Visitor>(f),
std::forward<T>(x),
std::forward<Ts>(xs)...);
}
/// @}
} // namespace caf
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <type_traits>
namespace caf {
/// Specializing this trait allows users to enable `holds_alternative`, `get`,
/// `get_if`, and `visit` for any user-defined sum type.
/// @relates SumType
template <class T>
struct sum_type_access {
static constexpr bool specialized = false;
};
/// Evaluates to `true` if `T` specializes `sum_type_access`.
/// @relates SumType
template <class T>
struct has_sum_type_access {
static constexpr bool value = sum_type_access<T>::specialized;
};
} // namespace caf
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <type_traits>
namespace caf {
template <class T, int Pos>
struct sum_type_token {};
template <class T, int Pos>
constexpr std::integral_constant<int, Pos> pos(sum_type_token<T, Pos>) {
return {};
}
} // namespace caf
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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