Commit da15a1d6 authored by Dominik Charousset's avatar Dominik Charousset

Integrate review feedback

parent f8316e8e
......@@ -32,7 +32,7 @@
namespace caf {
/// Implements the deserializer interface with a binary serialization protocol.
/// Deserializes objects from sequence of bytes.
class binary_deserializer : public write_inspector<binary_deserializer> {
public:
// -- member types -----------------------------------------------------------
......
......@@ -35,6 +35,7 @@
namespace caf {
/// Serializes objects into a sequence of bytes.
class binary_serializer : public read_inspector<binary_serializer> {
public:
// -- member types -----------------------------------------------------------
......
......@@ -45,7 +45,7 @@ public:
virtual Result operator()(Ts...) = 0;
};
/// Utility class for wrapping a function object of type `Base`.
/// Utility class for wrapping a function object of type `F`.
template <class F, class Signature>
class callback_impl;
......@@ -68,7 +68,7 @@ private:
F f_;
};
/// Creates a callback from a lambda expression.
/// Creates a ::callback from the function object `fun`.
/// @relates callback
template <class F>
auto make_callback(F fun) {
......
......@@ -55,18 +55,15 @@ public:
// -- interface functions ----------------------------------------------------
/// Begins processing of an object. Saves the type information
/// to the underlying storage.
/// Begins processing of an object.
virtual result_type begin_object(uint16_t& typenr, std::string& type_name)
= 0;
/// Ends processing of an object.
virtual result_type end_object() = 0;
/// Begins processing of a sequence. Saves the size
/// to the underlying storage when in saving mode, otherwise
/// sets `num` accordingly.
virtual result_type begin_sequence(size_t& num) = 0;
/// Begins processing of a sequence.
virtual result_type begin_sequence(size_t& size) = 0;
/// Ends processing of a sequence.
virtual result_type end_sequence() = 0;
......
......@@ -717,6 +717,7 @@ struct can_apply {
static auto sfinae(...) -> std::false_type;
using type = decltype(sfinae<T>(nullptr));
static constexpr bool value = type::value;
};
......
......@@ -99,12 +99,12 @@ public:
};
/// @relates type_erased_value_impl
inline auto inspect(serializer& f, type_erased_value& x) {
inline auto inspect(serializer& f, const type_erased_value& x) {
return x.save(f);
}
/// @relates type_erased_value_impl
inline auto inspect(binary_serializer& f, type_erased_value& x) {
inline auto inspect(binary_serializer& f, const type_erased_value& x) {
return x.save(f);
}
......
......@@ -217,6 +217,7 @@ result_type binary_deserializer::apply(std::u16string& x) {
if (!range_check(str_size * sizeof(uint16_t)))
return sec::end_of_stream;
for (size_t i = 0; i < str_size; ++i) {
// The standard does not guarantee that char16_t is exactly 16 bits.
uint16_t tmp;
unsafe_apply_int(*this, tmp);
x.push_back(static_cast<char16_t>(tmp));
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/error_code.hpp"
namespace caf::io::basp {
/// @addtogroup BASP
/// Storage type for raw bytes.
using buffer_type = std::vector<char>;
/// @}
} // namespace caf::io::basp
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