Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
86cdab59
Unverified
Commit
86cdab59
authored
Jul 30, 2021
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate byte
parent
52914200
Changes
50
Show whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
230 additions
and
410 deletions
+230
-410
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+0
-1
libcaf_core/caf/binary_deserializer.hpp
libcaf_core/caf/binary_deserializer.hpp
+16
-16
libcaf_core/caf/binary_serializer.hpp
libcaf_core/caf/binary_serializer.hpp
+3
-4
libcaf_core/caf/byte.hpp
libcaf_core/caf/byte.hpp
+1
-73
libcaf_core/caf/byte_buffer.hpp
libcaf_core/caf/byte_buffer.hpp
+2
-3
libcaf_core/caf/byte_span.hpp
libcaf_core/caf/byte_span.hpp
+4
-3
libcaf_core/caf/config_value_reader.hpp
libcaf_core/caf/config_value_reader.hpp
+2
-2
libcaf_core/caf/config_value_writer.hpp
libcaf_core/caf/config_value_writer.hpp
+2
-2
libcaf_core/caf/deserializer.hpp
libcaf_core/caf/deserializer.hpp
+6
-7
libcaf_core/caf/detail/message_builder_element.hpp
libcaf_core/caf/detail/message_builder_element.hpp
+9
-7
libcaf_core/caf/detail/message_data.hpp
libcaf_core/caf/detail/message_data.hpp
+19
-18
libcaf_core/caf/detail/serialized_size.hpp
libcaf_core/caf/detail/serialized_size.hpp
+2
-2
libcaf_core/caf/detail/stringification_inspector.hpp
libcaf_core/caf/detail/stringification_inspector.hpp
+2
-2
libcaf_core/caf/detail/type_traits.hpp
libcaf_core/caf/detail/type_traits.hpp
+5
-5
libcaf_core/caf/fwd.hpp
libcaf_core/caf/fwd.hpp
+5
-4
libcaf_core/caf/hash/fnv.hpp
libcaf_core/caf/hash/fnv.hpp
+3
-3
libcaf_core/caf/hash/sha1.hpp
libcaf_core/caf/hash/sha1.hpp
+3
-3
libcaf_core/caf/json_reader.hpp
libcaf_core/caf/json_reader.hpp
+2
-2
libcaf_core/caf/json_writer.hpp
libcaf_core/caf/json_writer.hpp
+2
-2
libcaf_core/caf/serializer.hpp
libcaf_core/caf/serializer.hpp
+6
-7
libcaf_core/caf/span.hpp
libcaf_core/caf/span.hpp
+5
-5
libcaf_core/caf/sum_type.hpp
libcaf_core/caf/sum_type.hpp
+7
-9
libcaf_core/caf/uuid.hpp
libcaf_core/caf/uuid.hpp
+2
-2
libcaf_core/src/binary_deserializer.cpp
libcaf_core/src/binary_deserializer.cpp
+3
-3
libcaf_core/src/binary_serializer.cpp
libcaf_core/src/binary_serializer.cpp
+5
-5
libcaf_core/src/config_value_reader.cpp
libcaf_core/src/config_value_reader.cpp
+4
-4
libcaf_core/src/config_value_writer.cpp
libcaf_core/src/config_value_writer.cpp
+2
-2
libcaf_core/src/detail/message_data.cpp
libcaf_core/src/detail/message_data.cpp
+6
-4
libcaf_core/src/detail/serialized_size.cpp
libcaf_core/src/detail/serialized_size.cpp
+2
-2
libcaf_core/src/detail/stringification_inspector.cpp
libcaf_core/src/detail/stringification_inspector.cpp
+3
-3
libcaf_core/src/error.cpp
libcaf_core/src/error.cpp
+1
-1
libcaf_core/src/hash/sha1.cpp
libcaf_core/src/hash/sha1.cpp
+2
-2
libcaf_core/src/json_reader.cpp
libcaf_core/src/json_reader.cpp
+4
-4
libcaf_core/src/json_writer.cpp
libcaf_core/src/json_writer.cpp
+3
-3
libcaf_core/src/message_builder.cpp
libcaf_core/src/message_builder.cpp
+2
-2
libcaf_core/src/uuid.cpp
libcaf_core/src/uuid.cpp
+15
-15
libcaf_core/test/binary_deserializer.cpp
libcaf_core/test/binary_deserializer.cpp
+15
-15
libcaf_core/test/binary_serializer.cpp
libcaf_core/test/binary_serializer.cpp
+7
-12
libcaf_core/test/byte.cpp
libcaf_core/test/byte.cpp
+0
-106
libcaf_core/test/hash/sha1.cpp
libcaf_core/test/hash/sha1.cpp
+1
-1
libcaf_core/test/load_inspector.cpp
libcaf_core/test/load_inspector.cpp
+7
-7
libcaf_core/test/save_inspector.cpp
libcaf_core/test/save_inspector.cpp
+4
-4
libcaf_core/test/uuid.cpp
libcaf_core/test/uuid.cpp
+3
-2
libcaf_io/caf/io/abstract_broker.hpp
libcaf_io/caf/io/abstract_broker.hpp
+8
-8
libcaf_io/src/io/abstract_broker.cpp
libcaf_io/src/io/abstract_broker.cpp
+5
-5
libcaf_io/src/io/basp/instance.cpp
libcaf_io/src/io/basp/instance.cpp
+1
-1
libcaf_io/src/io/network/datagram_handler.cpp
libcaf_io/src/io/network/datagram_handler.cpp
+1
-1
libcaf_io/src/io/network/stream.cpp
libcaf_io/src/io/network/stream.cpp
+1
-1
libcaf_io/src/io/network/test_multiplexer.cpp
libcaf_io/src/io/network/test_multiplexer.cpp
+16
-14
libcaf_io/test/io/broker.cpp
libcaf_io/test/io/broker.cpp
+1
-1
No files found.
libcaf_core/CMakeLists.txt
View file @
86cdab59
...
@@ -233,7 +233,6 @@ caf_add_component(
...
@@ -233,7 +233,6 @@ caf_add_component(
binary_serializer
binary_serializer
blocking_actor
blocking_actor
broadcast_downstream_manager
broadcast_downstream_manager
byte
composition
composition
config_option
config_option
config_option_set
config_option_set
...
...
libcaf_core/caf/binary_deserializer.hpp
View file @
86cdab59
...
@@ -21,8 +21,8 @@
...
@@ -21,8 +21,8 @@
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
}
}
...
@@ -64,8 +64,8 @@ public:
...
@@ -64,8 +64,8 @@ public:
return
static_cast
<
size_t
>
(
end_
-
current_
);
return
static_cast
<
size_t
>
(
end_
-
current_
);
}
}
/// Returns the remaining bytes.
/// Returns the remaining
std::
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_
;
}
}
...
@@ -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,23 +196,23 @@ public:
...
@@ -196,23 +196,23 @@ 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
);
private:
private:
explicit
binary_deserializer
(
actor_system
&
sys
)
noexcept
;
explicit
binary_deserializer
(
actor_system
&
sys
)
noexcept
;
/// Checks whether we can read `read_size` more bytes.
/// Checks whether we can read `read_size` more
std::
bytes.
bool
range_check
(
size_t
read_size
)
const
noexcept
{
bool
range_check
(
size_t
read_size
)
const
noexcept
{
return
current_
+
read_size
<=
end_
;
return
current_
+
read_size
<=
end_
;
}
}
/// 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_
;
...
...
libcaf_core/caf/binary_serializer.hpp
View file @
86cdab59
...
@@ -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 --------------------
...
@@ -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
);
...
@@ -174,7 +173,7 @@ public:
...
@@ -174,7 +173,7 @@ public:
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
);
...
...
libcaf_core/caf/byte.hpp
View file @
86cdab59
// 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
\ No newline at end of file
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include <cstdint>
#include <type_traits>
#pragma once
namespace
caf
{
/// A C++11/14 drop-in replacement for C++17's `std::byte`.
enum
class
byte
:
uint8_t
{};
template
<
class
IntegerType
,
class
=
std
::
enable_if_t
<
std
::
is_integral
<
IntegerType
>
::
value
>>
constexpr
IntegerType
to_integer
(
byte
x
)
noexcept
{
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
libcaf_core/caf/byte_buffer.hpp
View file @
86cdab59
...
@@ -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
libcaf_core/caf/byte_span.hpp
View file @
86cdab59
...
@@ -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
libcaf_core/caf/config_value_reader.hpp
View file @
86cdab59
...
@@ -122,7 +122,7 @@ public:
...
@@ -122,7 +122,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 +154,7 @@ public:
...
@@ -154,7 +154,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
...
...
libcaf_core/caf/config_value_writer.hpp
View file @
86cdab59
...
@@ -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
;
...
@@ -118,7 +118,7 @@ public:
...
@@ -118,7 +118,7 @@ public:
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
);
...
...
libcaf_core/caf/deserializer.hpp
View file @
86cdab59
...
@@ -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"
...
@@ -127,7 +126,7 @@ public:
...
@@ -127,7 +126,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
;
...
@@ -185,16 +184,16 @@ public:
...
@@ -185,16 +184,16 @@ public:
/// @copydoc value
/// @copydoc value
virtual
bool
value
(
std
::
u32string
&
)
=
0
;
virtual
bool
value
(
std
::
u32string
&
)
=
0
;
/// Reads a byte sequence from the input.
/// Reads a
std::
byte sequence from the input.
/// @param x The byte sequence.
/// @param x The
std::
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.
///
std::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:
...
...
libcaf_core/caf/detail/message_builder_element.hpp
View file @
86cdab59
...
@@ -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"
...
@@ -21,14 +21,16 @@ public:
...
@@ -21,14 +21,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 std::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 std::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
>
...
@@ -38,12 +40,12 @@ public:
...
@@ -38,12 +40,12 @@ public:
// nop
// nop
}
}
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
>
;
}
}
...
...
libcaf_core/caf/detail/message_data.hpp
View file @
86cdab59
...
@@ -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 ------------------------------------------------------
...
...
libcaf_core/caf/detail/serialized_size.hpp
View file @
86cdab59
...
@@ -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
;
...
@@ -74,7 +74,7 @@ public:
...
@@ -74,7 +74,7 @@ public:
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
;
...
...
libcaf_core/caf/detail/stringification_inspector.hpp
View file @
86cdab59
...
@@ -86,7 +86,7 @@ public:
...
@@ -86,7 +86,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
);
...
@@ -114,7 +114,7 @@ public:
...
@@ -114,7 +114,7 @@ public:
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
;
...
...
libcaf_core/caf/detail/type_traits.hpp
View file @
86cdab59
...
@@ -957,9 +957,9 @@ CAF_ADD_TRIVIAL_INSPECTOR_VALUE(long double)
...
@@ -957,9 +957,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
)
...
@@ -995,12 +995,12 @@ struct is_builtin_inspector_type {
...
@@ -995,12 +995,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
;
};
};
...
@@ -1025,7 +1025,7 @@ struct is_builtin_inspector_type<string_view, false> {
...
@@ -1025,7 +1025,7 @@ struct is_builtin_inspector_type<string_view, false> {
};
};
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
;
};
};
...
...
libcaf_core/caf/fwd.hpp
View file @
86cdab59
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#pragma once
#pragma once
#include <cstddef>
#include <cstdint>
#include <cstdint>
#include <memory>
#include <memory>
#include <vector>
#include <vector>
...
@@ -179,7 +180,6 @@ config_option make_config_option(T& storage, string_view category,
...
@@ -179,7 +180,6 @@ config_option make_config_option(T& storage, string_view category,
// -- 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
;
...
@@ -189,9 +189,10 @@ enum class stream_priority : uint8_t;
...
@@ -189,9 +189,10 @@ enum class stream_priority : 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
ip_address
=
ipv6_address
;
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
;
...
...
libcaf_core/caf/hash/fnv.hpp
View file @
86cdab59
...
@@ -4,10 +4,10 @@
...
@@ -4,10 +4,10 @@
#pragma once
#pragma once
#include <cstddef>
#include <cstdint>
#include <cstdint>
#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"
...
@@ -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
));
}
}
...
@@ -135,7 +135,7 @@ public:
...
@@ -135,7 +135,7 @@ public:
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
;
...
...
libcaf_core/caf/hash/sha1.hpp
View file @
86cdab59
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
#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"
...
@@ -13,6 +12,7 @@
...
@@ -13,6 +12,7 @@
#include "caf/type_id.hpp"
#include "caf/type_id.hpp"
#include <array>
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstdint>
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
;
...
@@ -126,7 +126,7 @@ public:
...
@@ -126,7 +126,7 @@ public:
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
;
...
...
libcaf_core/caf/json_reader.hpp
View file @
86cdab59
...
@@ -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
;
...
...
libcaf_core/caf/json_writer.hpp
View file @
86cdab59
...
@@ -143,7 +143,7 @@ public:
...
@@ -143,7 +143,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
;
...
@@ -175,7 +175,7 @@ public:
...
@@ -175,7 +175,7 @@ public:
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 -------------------------------------------------
...
...
libcaf_core/caf/serializer.hpp
View file @
86cdab59
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,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"
...
@@ -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
;
...
@@ -157,16 +156,16 @@ public:
...
@@ -157,16 +156,16 @@ public:
/// @copydoc value
/// @copydoc value
virtual
bool
value
(
const
std
::
u32string
&
x
)
=
0
;
virtual
bool
value
(
const
std
::
u32string
&
x
)
=
0
;
/// Adds `x` as raw byte block to the output.
/// Adds `x` as raw
std::
byte block to the output.
/// @param x The byte sequence.
/// @param x The
std::
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.
///
std::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:
...
...
libcaf_core/caf/span.hpp
View file @
86cdab59
...
@@ -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
...
...
libcaf_core/caf/sum_type.hpp
View file @
86cdab59
...
@@ -38,8 +38,8 @@ struct sum_type_index {
...
@@ -38,8 +38,8 @@ struct sum_type_index {
template
<
class
Trait
,
class
T
>
template
<
class
Trait
,
class
T
>
struct
sum_type_index
<
Trait
,
T
,
true
>
{
struct
sum_type_index
<
Trait
,
T
,
true
>
{
static
constexpr
int
value
=
static
constexpr
int
value
detail
::
tl_index_of
<
typename
Trait
::
types
,
T
>::
value
;
=
detail
::
tl_index_of
<
typename
Trait
::
types
,
T
>::
value
;
};
};
template
<
class
Trait
,
class
T
>
template
<
class
Trait
,
class
T
>
...
@@ -48,7 +48,6 @@ make_sum_type_token() {
...
@@ -48,7 +48,6 @@ make_sum_type_token() {
return
{};
return
{};
}
}
/// Returns a reference to the value of a sum type.
/// Returns a reference to the value of a sum type.
/// @pre `holds_alternative<T>(x)`
/// @pre `holds_alternative<T>(x)`
template
<
class
T
,
class
U
,
class
Trait
=
sum_type_access
<
U
>
>
template
<
class
T
,
class
U
,
class
Trait
=
sum_type_access
<
U
>
>
...
@@ -60,7 +59,7 @@ auto get(U& x) -> decltype(Trait::get(x, make_sum_type_token<Trait, T>())) {
...
@@ -60,7 +59,7 @@ auto get(U& x) -> decltype(Trait::get(x, make_sum_type_token<Trait, T>())) {
/// @pre `holds_alternative<T>(x)`
/// @pre `holds_alternative<T>(x)`
template
<
class
T
,
class
U
,
class
Trait
=
sum_type_access
<
U
>
>
template
<
class
T
,
class
U
,
class
Trait
=
sum_type_access
<
U
>
>
auto
get
(
const
U
&
x
)
auto
get
(
const
U
&
x
)
->
decltype
(
Trait
::
get
(
x
,
make_sum_type_token
<
Trait
,
T
>
()))
{
->
decltype
(
Trait
::
get
(
x
,
make_sum_type_token
<
Trait
,
T
>
()))
{
return
Trait
::
get
(
x
,
make_sum_type_token
<
Trait
,
T
>
());
return
Trait
::
get
(
x
,
make_sum_type_token
<
Trait
,
T
>
());
}
}
...
@@ -68,7 +67,7 @@ auto get(const U& x)
...
@@ -68,7 +67,7 @@ auto get(const U& x)
/// `nullptr` otherwise.
/// `nullptr` otherwise.
template
<
class
T
,
class
U
,
class
Trait
=
sum_type_access
<
U
>
>
template
<
class
T
,
class
U
,
class
Trait
=
sum_type_access
<
U
>
>
auto
get_if
(
U
*
x
)
auto
get_if
(
U
*
x
)
->
decltype
(
Trait
::
get_if
(
x
,
make_sum_type_token
<
Trait
,
T
>
()))
{
->
decltype
(
Trait
::
get_if
(
x
,
make_sum_type_token
<
Trait
,
T
>
()))
{
return
Trait
::
get_if
(
x
,
make_sum_type_token
<
Trait
,
T
>
());
return
Trait
::
get_if
(
x
,
make_sum_type_token
<
Trait
,
T
>
());
}
}
...
@@ -76,7 +75,7 @@ auto get_if(U* x)
...
@@ -76,7 +75,7 @@ auto get_if(U* x)
/// `nullptr` otherwise.
/// `nullptr` otherwise.
template
<
class
T
,
class
U
,
class
Trait
=
sum_type_access
<
U
>
>
template
<
class
T
,
class
U
,
class
Trait
=
sum_type_access
<
U
>
>
auto
get_if
(
const
U
*
x
)
auto
get_if
(
const
U
*
x
)
->
decltype
(
Trait
::
get_if
(
x
,
make_sum_type_token
<
Trait
,
T
>
()))
{
->
decltype
(
Trait
::
get_if
(
x
,
make_sum_type_token
<
Trait
,
T
>
()))
{
return
Trait
::
get_if
(
x
,
make_sum_type_token
<
Trait
,
T
>
());
return
Trait
::
get_if
(
x
,
make_sum_type_token
<
Trait
,
T
>
());
}
}
...
@@ -99,8 +98,8 @@ struct sum_type_visit_result_impl<false, F, Ts...> {};
...
@@ -99,8 +98,8 @@ struct sum_type_visit_result_impl<false, F, Ts...> {};
template
<
class
F
,
class
...
Ts
>
template
<
class
F
,
class
...
Ts
>
struct
sum_type_visit_result
struct
sum_type_visit_result
:
sum_type_visit_result_impl
<
:
sum_type_visit_result_impl
<
detail
::
conjunction
<
SumType
<
Ts
>
()...
>::
value
,
F
,
detail
::
conjunction
<
SumType
<
Ts
>
()...
>::
value
,
F
,
Ts
...
>
{};
Ts
...
>
{};
template
<
class
F
,
class
...
Ts
>
template
<
class
F
,
class
...
Ts
>
using
sum_type_visit_result_t
=
using
sum_type_visit_result_t
=
...
@@ -129,7 +128,6 @@ struct visit_impl<Result, 0> {
...
@@ -129,7 +128,6 @@ struct visit_impl<Result, 0> {
}
}
};
};
template
<
class
Result
,
size_t
I
,
class
Visitor
>
template
<
class
Result
,
size_t
I
,
class
Visitor
>
struct
visit_impl_continuation
{
struct
visit_impl_continuation
{
Visitor
&
f
;
Visitor
&
f
;
...
...
libcaf_core/caf/uuid.hpp
View file @
86cdab59
...
@@ -5,11 +5,11 @@
...
@@ -5,11 +5,11 @@
#pragma once
#pragma once
#include <array>
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstdint>
#include <cstring>
#include <cstring>
#include <string>
#include <string>
#include "caf/byte.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/error.hpp"
#include "caf/error.hpp"
...
@@ -23,7 +23,7 @@ namespace caf {
...
@@ -23,7 +23,7 @@ namespace caf {
/// can read all UUID versions, it can only create random-generated ones.
/// can read all UUID versions, it can only create random-generated ones.
class
CAF_CORE_EXPORT
uuid
:
detail
::
comparable
<
uuid
>
{
class
CAF_CORE_EXPORT
uuid
:
detail
::
comparable
<
uuid
>
{
public:
public:
using
array_type
=
std
::
array
<
byte
,
16
>
;
using
array_type
=
std
::
array
<
std
::
byte
,
16
>
;
/// Creates the nil UUID with all 128 bits set to zero.
/// Creates the nil UUID with all 128 bits set to zero.
uuid
()
noexcept
;
uuid
()
noexcept
;
...
...
libcaf_core/src/binary_deserializer.cpp
View file @
86cdab59
...
@@ -84,7 +84,7 @@ void binary_deserializer::skip(size_t num_bytes) {
...
@@ -84,7 +84,7 @@ void binary_deserializer::skip(size_t num_bytes) {
current_
+=
num_bytes
;
current_
+=
num_bytes
;
}
}
void
binary_deserializer
::
reset
(
span
<
const
byte
>
bytes
)
noexcept
{
void
binary_deserializer
::
reset
(
span
<
const
std
::
byte
>
bytes
)
noexcept
{
current_
=
bytes
.
data
();
current_
=
bytes
.
data
();
end_
=
current_
+
bytes
.
size
();
end_
=
current_
+
bytes
.
size
();
}
}
...
@@ -166,7 +166,7 @@ bool binary_deserializer::value(bool& x) noexcept {
...
@@ -166,7 +166,7 @@ bool binary_deserializer::value(bool& x) noexcept {
return
true
;
return
true
;
}
}
bool
binary_deserializer
::
value
(
byte
&
x
)
noexcept
{
bool
binary_deserializer
::
value
(
std
::
byte
&
x
)
noexcept
{
if
(
range_check
(
1
))
{
if
(
range_check
(
1
))
{
x
=
*
current_
++
;
x
=
*
current_
++
;
return
true
;
return
true
;
...
@@ -240,7 +240,7 @@ bool binary_deserializer::value(long double& x) {
...
@@ -240,7 +240,7 @@ bool binary_deserializer::value(long double& x) {
return
false
;
return
false
;
}
}
bool
binary_deserializer
::
value
(
span
<
byte
>
x
)
noexcept
{
bool
binary_deserializer
::
value
(
span
<
std
::
byte
>
x
)
noexcept
{
if
(
!
range_check
(
x
.
size
()))
{
if
(
!
range_check
(
x
.
size
()))
{
emplace_error
(
sec
::
end_of_stream
);
emplace_error
(
sec
::
end_of_stream
);
return
false
;
return
false
;
...
...
libcaf_core/src/binary_serializer.cpp
View file @
86cdab59
...
@@ -33,7 +33,7 @@ binary_serializer::binary_serializer(actor_system& sys,
...
@@ -33,7 +33,7 @@ binary_serializer::binary_serializer(actor_system& sys,
void
binary_serializer
::
skip
(
size_t
num_bytes
)
{
void
binary_serializer
::
skip
(
size_t
num_bytes
)
{
auto
remaining
=
buf_
.
size
()
-
write_pos_
;
auto
remaining
=
buf_
.
size
()
-
write_pos_
;
if
(
remaining
<
num_bytes
)
if
(
remaining
<
num_bytes
)
buf_
.
insert
(
buf_
.
end
(),
num_bytes
-
remaining
,
byte
{
0
});
buf_
.
insert
(
buf_
.
end
(),
num_bytes
-
remaining
,
std
::
byte
{
0
});
write_pos_
+=
num_bytes
;
write_pos_
+=
num_bytes
;
}
}
...
@@ -103,7 +103,7 @@ bool binary_serializer::begin_field(string_view, bool is_present,
...
@@ -103,7 +103,7 @@ bool binary_serializer::begin_field(string_view, bool is_present,
}
}
}
}
bool
binary_serializer
::
value
(
span
<
const
byte
>
x
)
{
bool
binary_serializer
::
value
(
span
<
const
std
::
byte
>
x
)
{
CAF_ASSERT
(
write_pos_
<=
buf_
.
size
());
CAF_ASSERT
(
write_pos_
<=
buf_
.
size
());
auto
buf_size
=
buf_
.
size
();
auto
buf_size
=
buf_
.
size
();
if
(
write_pos_
==
buf_size
)
{
if
(
write_pos_
==
buf_size
)
{
...
@@ -124,7 +124,7 @@ bool binary_serializer::value(span<const byte> x) {
...
@@ -124,7 +124,7 @@ bool binary_serializer::value(span<const byte> x) {
return
true
;
return
true
;
}
}
bool
binary_serializer
::
value
(
byte
x
)
{
bool
binary_serializer
::
value
(
std
::
byte
x
)
{
if
(
write_pos_
==
buf_
.
size
())
if
(
write_pos_
==
buf_
.
size
())
buf_
.
emplace_back
(
x
);
buf_
.
emplace_back
(
x
);
else
else
...
@@ -138,11 +138,11 @@ bool binary_serializer::value(bool x) {
...
@@ -138,11 +138,11 @@ bool binary_serializer::value(bool x) {
}
}
bool
binary_serializer
::
value
(
int8_t
x
)
{
bool
binary_serializer
::
value
(
int8_t
x
)
{
return
value
(
static_cast
<
byte
>
(
x
));
return
value
(
static_cast
<
std
::
byte
>
(
x
));
}
}
bool
binary_serializer
::
value
(
uint8_t
x
)
{
bool
binary_serializer
::
value
(
uint8_t
x
)
{
return
value
(
static_cast
<
byte
>
(
x
));
return
value
(
static_cast
<
std
::
byte
>
(
x
));
}
}
bool
binary_serializer
::
value
(
int16_t
x
)
{
bool
binary_serializer
::
value
(
int16_t
x
)
{
...
...
libcaf_core/src/config_value_reader.cpp
View file @
86cdab59
...
@@ -459,11 +459,11 @@ bool pull(config_value_reader& reader, T& x) {
...
@@ -459,11 +459,11 @@ bool pull(config_value_reader& reader, T& x) {
}
// namespace
}
// namespace
bool
config_value_reader
::
value
(
byte
&
x
)
{
bool
config_value_reader
::
value
(
std
::
byte
&
x
)
{
CHECK_NOT_EMPTY
();
CHECK_NOT_EMPTY
();
auto
tmp
=
uint8_t
{
0
};
auto
tmp
=
uint8_t
{
0
};
if
(
pull
(
*
this
,
tmp
))
{
if
(
pull
(
*
this
,
tmp
))
{
x
=
static_cast
<
byte
>
(
tmp
);
x
=
static_cast
<
std
::
byte
>
(
tmp
);
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
@@ -545,7 +545,7 @@ bool config_value_reader::value(std::u32string&) {
...
@@ -545,7 +545,7 @@ bool config_value_reader::value(std::u32string&) {
return
false
;
return
false
;
}
}
bool
config_value_reader
::
value
(
span
<
byte
>
bytes
)
{
bool
config_value_reader
::
value
(
span
<
std
::
byte
>
bytes
)
{
CHECK_NOT_EMPTY
();
CHECK_NOT_EMPTY
();
std
::
string
x
;
std
::
string
x
;
if
(
!
pull
(
*
this
,
x
))
if
(
!
pull
(
*
this
,
x
))
...
@@ -566,7 +566,7 @@ bool config_value_reader::value(span<byte> bytes) {
...
@@ -566,7 +566,7 @@ bool config_value_reader::value(span<byte> bytes) {
}
}
detail
::
parser
::
add_ascii
<
16
>
(
value
,
c
);
detail
::
parser
::
add_ascii
<
16
>
(
value
,
c
);
}
}
bytes
[
index
/
2
]
=
static_cast
<
byte
>
(
value
);
bytes
[
index
/
2
]
=
static_cast
<
std
::
byte
>
(
value
);
}
}
return
true
;
return
true
;
}
}
...
...
libcaf_core/src/config_value_writer.cpp
View file @
86cdab59
...
@@ -313,7 +313,7 @@ bool config_value_writer::end_associative_array() {
...
@@ -313,7 +313,7 @@ bool config_value_writer::end_associative_array() {
return
true
;
return
true
;
}
}
bool
config_value_writer
::
value
(
byte
x
)
{
bool
config_value_writer
::
value
(
std
::
byte
x
)
{
return
push
(
config_value
{
static_cast
<
config_value
::
integer
>
(
x
)});
return
push
(
config_value
{
static_cast
<
config_value
::
integer
>
(
x
)});
}
}
...
@@ -384,7 +384,7 @@ bool config_value_writer::value(const std::u32string&) {
...
@@ -384,7 +384,7 @@ bool config_value_writer::value(const std::u32string&) {
return
false
;
return
false
;
}
}
bool
config_value_writer
::
value
(
span
<
const
byte
>
x
)
{
bool
config_value_writer
::
value
(
span
<
const
std
::
byte
>
x
)
{
std
::
string
str
;
std
::
string
str
;
detail
::
append_hex
(
str
,
x
.
data
(),
x
.
size
());
detail
::
append_hex
(
str
,
x
.
data
(),
x
.
size
());
return
push
(
config_value
{
std
::
move
(
str
)});
return
push
(
config_value
{
std
::
move
(
str
)});
...
...
libcaf_core/src/detail/message_data.cpp
View file @
86cdab59
...
@@ -75,7 +75,7 @@ message_data::make_uninitialized(type_id_list types) {
...
@@ -75,7 +75,7 @@ message_data::make_uninitialized(type_id_list types) {
return
{
new
(
vptr
)
message_data
(
types
),
false
};
return
{
new
(
vptr
)
message_data
(
types
),
false
};
}
}
byte
*
message_data
::
at
(
size_t
index
)
noexcept
{
std
::
byte
*
message_data
::
at
(
size_t
index
)
noexcept
{
if
(
index
==
0
)
if
(
index
==
0
)
return
storage
();
return
storage
();
auto
gmos
=
global_meta_objects
();
auto
gmos
=
global_meta_objects
();
...
@@ -85,7 +85,7 @@ byte* message_data::at(size_t index) noexcept {
...
@@ -85,7 +85,7 @@ byte* message_data::at(size_t index) noexcept {
return
ptr
;
return
ptr
;
}
}
const
byte
*
message_data
::
at
(
size_t
index
)
const
noexcept
{
const
std
::
byte
*
message_data
::
at
(
size_t
index
)
const
noexcept
{
if
(
index
==
0
)
if
(
index
==
0
)
return
storage
();
return
storage
();
auto
gmos
=
global_meta_objects
();
auto
gmos
=
global_meta_objects
();
...
@@ -95,11 +95,13 @@ const byte* message_data::at(size_t index) const noexcept {
...
@@ -95,11 +95,13 @@ const byte* message_data::at(size_t index) const noexcept {
return
ptr
;
return
ptr
;
}
}
byte
*
message_data
::
stepwise_init_from
(
byte
*
pos
,
const
message
&
msg
)
{
std
::
byte
*
message_data
::
stepwise_init_from
(
std
::
byte
*
pos
,
const
message
&
msg
)
{
return
stepwise_init_from
(
pos
,
msg
.
cptr
());
return
stepwise_init_from
(
pos
,
msg
.
cptr
());
}
}
byte
*
message_data
::
stepwise_init_from
(
byte
*
pos
,
const
message_data
*
other
)
{
std
::
byte
*
message_data
::
stepwise_init_from
(
std
::
byte
*
pos
,
const
message_data
*
other
)
{
CAF_ASSERT
(
other
!=
nullptr
);
CAF_ASSERT
(
other
!=
nullptr
);
CAF_ASSERT
(
other
!=
this
);
CAF_ASSERT
(
other
!=
this
);
auto
gmos
=
global_meta_objects
();
auto
gmos
=
global_meta_objects
();
...
...
libcaf_core/src/detail/serialized_size.cpp
View file @
86cdab59
...
@@ -89,7 +89,7 @@ bool serialized_size_inspector::end_sequence() {
...
@@ -89,7 +89,7 @@ bool serialized_size_inspector::end_sequence() {
return
true
;
return
true
;
}
}
bool
serialized_size_inspector
::
value
(
byte
x
)
{
bool
serialized_size_inspector
::
value
(
std
::
byte
x
)
{
result
+=
sizeof
(
x
);
result
+=
sizeof
(
x
);
return
true
;
return
true
;
}
}
...
@@ -176,7 +176,7 @@ bool serialized_size_inspector::value(const std::u32string& x) {
...
@@ -176,7 +176,7 @@ bool serialized_size_inspector::value(const std::u32string& x) {
return
end_sequence
();
return
end_sequence
();
}
}
bool
serialized_size_inspector
::
value
(
span
<
const
byte
>
x
)
{
bool
serialized_size_inspector
::
value
(
span
<
const
std
::
byte
>
x
)
{
result
+=
x
.
size
();
result
+=
x
.
size
();
return
true
;
return
true
;
}
}
...
...
libcaf_core/src/detail/stringification_inspector.cpp
View file @
86cdab59
...
@@ -73,8 +73,8 @@ bool stringification_inspector::end_sequence() {
...
@@ -73,8 +73,8 @@ bool stringification_inspector::end_sequence() {
return
true
;
return
true
;
}
}
bool
stringification_inspector
::
value
(
byte
x
)
{
bool
stringification_inspector
::
value
(
std
::
byte
x
)
{
return
value
(
span
<
const
byte
>
(
&
x
,
1
));
return
value
(
span
<
const
std
::
byte
>
(
&
x
,
1
));
}
}
bool
stringification_inspector
::
value
(
bool
x
)
{
bool
stringification_inspector
::
value
(
bool
x
)
{
...
@@ -165,7 +165,7 @@ bool stringification_inspector::int_value(uint64_t x) {
...
@@ -165,7 +165,7 @@ bool stringification_inspector::int_value(uint64_t x) {
return
true
;
return
true
;
}
}
bool
stringification_inspector
::
value
(
span
<
const
byte
>
x
)
{
bool
stringification_inspector
::
value
(
span
<
const
std
::
byte
>
x
)
{
sep
();
sep
();
detail
::
append_hex
(
result_
,
x
.
data
(),
x
.
size
());
detail
::
append_hex
(
result_
,
x
.
data
(),
x
.
size
());
return
true
;
return
true
;
...
...
libcaf_core/src/error.cpp
View file @
86cdab59
...
@@ -72,7 +72,7 @@ std::string to_string(const error& x) {
...
@@ -72,7 +72,7 @@ std::string to_string(const error& x) {
auto
append
=
[
&
result
](
const_void_ptr
ptr
,
auto
append
=
[
&
result
](
const_void_ptr
ptr
,
const_meta_ptr
meta
)
->
const_void_ptr
{
const_meta_ptr
meta
)
->
const_void_ptr
{
meta
->
stringify
(
result
,
ptr
);
meta
->
stringify
(
result
,
ptr
);
return
static_cast
<
const
byte
*>
(
ptr
)
+
meta
->
padded_size
;
return
static_cast
<
const
std
::
byte
*>
(
ptr
)
+
meta
->
padded_size
;
};
};
auto
code
=
x
.
code
();
auto
code
=
x
.
code
();
append
(
&
code
,
detail
::
global_meta_object
(
x
.
category
()));
append
(
&
code
,
detail
::
global_meta_object
(
x
.
category
()));
...
...
libcaf_core/src/hash/sha1.cpp
View file @
86cdab59
...
@@ -27,10 +27,10 @@ sha1::result_type sha1::result() noexcept {
...
@@ -27,10 +27,10 @@ sha1::result_type sha1::result() noexcept {
length_
=
0
;
length_
=
0
;
sealed_
=
true
;
sealed_
=
true
;
}
}
std
::
array
<
byte
,
sha1
::
hash_size
>
buf
;
std
::
array
<
std
::
byte
,
sha1
::
hash_size
>
buf
;
for
(
size_t
i
=
0
;
i
<
hash_size
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
hash_size
;
++
i
)
{
auto
tmp
=
intermediate_
[
i
>>
2
]
>>
8
*
(
3
-
(
i
&
0x03
));
auto
tmp
=
intermediate_
[
i
>>
2
]
>>
8
*
(
3
-
(
i
&
0x03
));
buf
[
i
]
=
static_cast
<
byte
>
(
tmp
);
buf
[
i
]
=
static_cast
<
std
::
byte
>
(
tmp
);
}
}
return
buf
;
return
buf
;
}
}
...
...
libcaf_core/src/json_reader.cpp
View file @
86cdab59
...
@@ -424,10 +424,10 @@ bool json_reader::end_associative_array() {
...
@@ -424,10 +424,10 @@ bool json_reader::end_associative_array() {
}
}
}
}
bool
json_reader
::
value
(
byte
&
x
)
{
bool
json_reader
::
value
(
std
::
byte
&
x
)
{
auto
tmp
=
uint8_t
{
0
};
auto
tmp
=
uint8_t
{
0
};
if
(
value
(
tmp
))
{
if
(
value
(
tmp
))
{
x
=
static_cast
<
byte
>
(
tmp
);
x
=
static_cast
<
std
::
byte
>
(
tmp
);
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
@@ -601,9 +601,9 @@ bool json_reader::value(std::u32string&) {
...
@@ -601,9 +601,9 @@ bool json_reader::value(std::u32string&) {
return
false
;
return
false
;
}
}
bool
json_reader
::
value
(
span
<
byte
>
)
{
bool
json_reader
::
value
(
span
<
std
::
byte
>
)
{
emplace_error
(
sec
::
runtime_error
,
class_name
,
__func__
,
emplace_error
(
sec
::
runtime_error
,
class_name
,
__func__
,
"byte span support not implemented yet"
);
"
std::
byte span support not implemented yet"
);
return
false
;
return
false
;
}
}
...
...
libcaf_core/src/json_writer.cpp
View file @
86cdab59
...
@@ -288,8 +288,8 @@ bool json_writer::end_associative_array() {
...
@@ -288,8 +288,8 @@ bool json_writer::end_associative_array() {
}
}
}
}
bool
json_writer
::
value
(
byte
x
)
{
bool
json_writer
::
value
(
std
::
byte
x
)
{
return
number
(
to_integer
<
uint8_t
>
(
x
));
return
number
(
static_cast
<
uint8_t
>
(
x
));
}
}
bool
json_writer
::
value
(
bool
x
)
{
bool
json_writer
::
value
(
bool
x
)
{
...
@@ -396,7 +396,7 @@ bool json_writer::value(const std::u32string&) {
...
@@ -396,7 +396,7 @@ bool json_writer::value(const std::u32string&) {
return
false
;
return
false
;
}
}
bool
json_writer
::
value
(
span
<
const
byte
>
x
)
{
bool
json_writer
::
value
(
span
<
const
std
::
byte
>
x
)
{
switch
(
top
())
{
switch
(
top
())
{
case
type
:
:
element
:
case
type
:
:
element
:
add
(
'"'
);
add
(
'"'
);
...
...
libcaf_core/src/message_builder.cpp
View file @
86cdab59
...
@@ -48,13 +48,13 @@ public:
...
@@ -48,13 +48,13 @@ public:
// nop
// nop
}
}
byte
*
copy_init
(
byte
*
storage
)
const
override
{
std
::
byte
*
copy_init
(
std
::
byte
*
storage
)
const
override
{
auto
*
meta
=
global_meta_object
(
src_
.
type_at
(
index_
));
auto
*
meta
=
global_meta_object
(
src_
.
type_at
(
index_
));
meta
->
copy_construct
(
storage
,
src_
.
data
().
at
(
index_
));
meta
->
copy_construct
(
storage
,
src_
.
data
().
at
(
index_
));
return
storage
+
meta
->
padded_size
;
return
storage
+
meta
->
padded_size
;
}
}
byte
*
move_init
(
byte
*
storage
)
override
{
std
::
byte
*
move_init
(
std
::
byte
*
storage
)
override
{
return
copy_init
(
storage
);
return
copy_init
(
storage
);
}
}
...
...
libcaf_core/src/uuid.cpp
View file @
86cdab59
...
@@ -20,7 +20,7 @@ namespace caf {
...
@@ -20,7 +20,7 @@ namespace caf {
namespace
{
namespace
{
byte
nil_bytes
[
16
];
std
::
byte
nil_bytes
[
16
];
}
// namespace
}
// namespace
...
@@ -67,40 +67,40 @@ uuid::variant_field variant_table[] = {
...
@@ -67,40 +67,40 @@ uuid::variant_field variant_table[] = {
}
// namespace
}
// namespace
uuid
::
variant_field
uuid
::
variant
()
const
noexcept
{
uuid
::
variant_field
uuid
::
variant
()
const
noexcept
{
return
variant_table
[
to_integer
<
size_t
>
(
bytes_
[
8
])
>>
5
];
return
variant_table
[
static_cast
<
size_t
>
(
bytes_
[
8
])
>>
5
];
}
}
uuid
::
version_field
uuid
::
version
()
const
noexcept
{
uuid
::
version_field
uuid
::
version
()
const
noexcept
{
return
static_cast
<
version_field
>
(
to_integer
<
int
>
(
bytes_
[
6
])
>>
4
);
return
static_cast
<
version_field
>
(
static_cast
<
int
>
(
bytes_
[
6
])
>>
4
);
}
}
uint64_t
uuid
::
timestamp
()
const
noexcept
{
uint64_t
uuid
::
timestamp
()
const
noexcept
{
// Assemble octets like this (L = low, M = mid, H = high):
// Assemble octets like this (L = low, M = mid, H = high):
// 0H HH MM MM LL LL LL LL
// 0H HH MM MM LL LL LL LL
byte
ts
[
8
];
std
::
byte
ts
[
8
];
memcpy
(
ts
+
4
,
bytes_
.
data
()
+
0
,
4
);
memcpy
(
ts
+
4
,
bytes_
.
data
()
+
0
,
4
);
memcpy
(
ts
+
2
,
bytes_
.
data
()
+
4
,
2
);
memcpy
(
ts
+
2
,
bytes_
.
data
()
+
4
,
2
);
memcpy
(
ts
+
0
,
bytes_
.
data
()
+
6
,
2
);
memcpy
(
ts
+
0
,
bytes_
.
data
()
+
6
,
2
);
ts
[
0
]
&=
byte
{
0x0F
};
ts
[
0
]
&=
std
::
byte
{
0x0F
};
uint64_t
result
;
uint64_t
result
;
memcpy
(
&
result
,
ts
,
8
);
memcpy
(
&
result
,
ts
,
8
);
// UUIDs are stored in network byte order.
// UUIDs are stored in network
std::
byte order.
return
detail
::
from_network_order
(
result
);
return
detail
::
from_network_order
(
result
);
}
}
uint16_t
uuid
::
clock_sequence
()
const
noexcept
{
uint16_t
uuid
::
clock_sequence
()
const
noexcept
{
// Read clk_seq_(hi|low) fields and strip the variant bits.
// Read clk_seq_(hi|low) fields and strip the variant bits.
byte
cs
[
2
];
std
::
byte
cs
[
2
];
memcpy
(
cs
,
bytes_
.
data
()
+
8
,
2
);
memcpy
(
cs
,
bytes_
.
data
()
+
8
,
2
);
cs
[
0
]
&=
byte
{
0x3F
};
cs
[
0
]
&=
std
::
byte
{
0x3F
};
uint16_t
result
;
uint16_t
result
;
memcpy
(
&
result
,
cs
,
2
);
memcpy
(
&
result
,
cs
,
2
);
// UUIDs are stored in network byte order.
// UUIDs are stored in network
std::
byte order.
return
detail
::
from_network_order
(
result
);
return
detail
::
from_network_order
(
result
);
}
}
uint64_t
uuid
::
node
()
const
noexcept
{
uint64_t
uuid
::
node
()
const
noexcept
{
byte
n
[
8
];
std
::
byte
n
[
8
];
memset
(
n
,
0
,
2
);
memset
(
n
,
0
,
2
);
memcpy
(
n
+
2
,
bytes_
.
data
()
+
10
,
6
);
memcpy
(
n
+
2
,
bytes_
.
data
()
+
10
,
6
);
uint64_t
result
;
uint64_t
result
;
...
@@ -132,7 +132,7 @@ parse_result parse_impl(string_parser_state& ps, uuid::array_type& x) noexcept {
...
@@ -132,7 +132,7 @@ parse_result parse_impl(string_parser_state& ps, uuid::array_type& x) noexcept {
if
(
!
isxdigit
(
c2
)
||
!
detail
::
parser
::
add_ascii
<
16
>
(
value
,
c2
))
if
(
!
isxdigit
(
c2
)
||
!
detail
::
parser
::
add_ascii
<
16
>
(
value
,
c2
))
return
false
;
return
false
;
ps
.
next
();
ps
.
next
();
*
pos
++
=
static_cast
<
byte
>
(
value
);
*
pos
++
=
static_cast
<
std
::
byte
>
(
value
);
return
true
;
return
true
;
};
};
// Parse the formatted string.
// Parse the formatted string.
...
@@ -153,7 +153,7 @@ parse_result parse_impl(string_parser_state& ps, uuid::array_type& x) noexcept {
...
@@ -153,7 +153,7 @@ parse_result parse_impl(string_parser_state& ps, uuid::array_type& x) noexcept {
// Check whether the bytes form a valid UUID.
// Check whether the bytes form a valid UUID.
if
(
memcmp
(
x
.
data
(),
nil_bytes
,
16
)
==
0
)
if
(
memcmp
(
x
.
data
(),
nil_bytes
,
16
)
==
0
)
return
valid_uuid
;
return
valid_uuid
;
if
(
auto
subtype
=
to_integer
<
long
>
(
x
[
6
])
>>
4
;
subtype
==
0
||
subtype
>
5
)
if
(
auto
subtype
=
static_cast
<
long
>
(
x
[
6
])
>>
4
;
subtype
==
0
||
subtype
>
5
)
return
invalid_version
;
return
invalid_version
;
return
valid_uuid
;
return
valid_uuid
;
}
}
...
@@ -173,9 +173,9 @@ uuid uuid::random(unsigned seed) noexcept {
...
@@ -173,9 +173,9 @@ uuid uuid::random(unsigned seed) noexcept {
std
::
uniform_int_distribution
<>
rng
{
0
,
255
};
std
::
uniform_int_distribution
<>
rng
{
0
,
255
};
uuid
result
;
uuid
result
;
for
(
size_t
index
=
0
;
index
<
16
;
++
index
)
for
(
size_t
index
=
0
;
index
<
16
;
++
index
)
result
.
bytes_
[
index
]
=
static_cast
<
byte
>
(
rng
(
engine
));
result
.
bytes_
[
index
]
=
static_cast
<
std
::
byte
>
(
rng
(
engine
));
result
.
bytes_
[
6
]
=
(
result
.
bytes_
[
6
]
&
byte
{
0x0F
})
|
byte
{
0x50
};
result
.
bytes_
[
6
]
=
(
result
.
bytes_
[
6
]
&
std
::
byte
{
0x0F
})
|
std
::
byte
{
0x50
};
result
.
bytes_
[
8
]
=
(
result
.
bytes_
[
8
]
&
byte
{
0x3F
})
|
byte
{
0x80
};
result
.
bytes_
[
8
]
=
(
result
.
bytes_
[
8
]
&
std
::
byte
{
0x3F
})
|
std
::
byte
{
0x80
};
return
result
;
return
result
;
}
}
...
...
libcaf_core/test/binary_deserializer.cpp
View file @
86cdab59
...
@@ -9,12 +9,12 @@
...
@@ -9,12 +9,12 @@
#include "core-test.hpp"
#include "core-test.hpp"
#include "nasty.hpp"
#include "nasty.hpp"
#include <cstddef>
#include <cstring>
#include <cstring>
#include <vector>
#include <vector>
#include "caf/actor_system.hpp"
#include "caf/actor_system.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/byte.hpp"
#include "caf/byte_buffer.hpp"
#include "caf/byte_buffer.hpp"
#include "caf/timestamp.hpp"
#include "caf/timestamp.hpp"
...
@@ -22,12 +22,12 @@ using namespace caf;
...
@@ -22,12 +22,12 @@ using namespace caf;
namespace
{
namespace
{
byte
operator
""
_b
(
unsigned
long
long
int
x
)
{
std
::
byte
operator
""
_b
(
unsigned
long
long
int
x
)
{
return
static_cast
<
byte
>
(
x
);
return
static_cast
<
std
::
byte
>
(
x
);
}
}
byte
operator
""
_b
(
char
x
)
{
std
::
byte
operator
""
_b
(
char
x
)
{
return
static_cast
<
byte
>
(
x
);
return
static_cast
<
std
::
byte
>
(
x
);
}
}
struct
arr
{
struct
arr
{
...
@@ -44,14 +44,14 @@ bool inspect(Inspector& f, arr& x) {
...
@@ -44,14 +44,14 @@ bool inspect(Inspector& f, arr& x) {
struct
fixture
{
struct
fixture
{
template
<
class
...
Ts
>
template
<
class
...
Ts
>
void
load
(
const
std
::
vector
<
byte
>&
buf
,
Ts
&
...
xs
)
{
void
load
(
const
std
::
vector
<
std
::
byte
>&
buf
,
Ts
&
...
xs
)
{
binary_deserializer
source
{
nullptr
,
buf
};
binary_deserializer
source
{
nullptr
,
buf
};
if
(
!
(
source
.
apply
(
xs
)
&&
...))
if
(
!
(
source
.
apply
(
xs
)
&&
...))
CAF_FAIL
(
"binary_deserializer failed to load: "
<<
source
.
get_error
());
CAF_FAIL
(
"binary_deserializer failed to load: "
<<
source
.
get_error
());
}
}
template
<
class
T
>
template
<
class
T
>
auto
load
(
const
std
::
vector
<
byte
>&
buf
)
{
auto
load
(
const
std
::
vector
<
std
::
byte
>&
buf
)
{
auto
result
=
T
{};
auto
result
=
T
{};
load
(
buf
,
result
);
load
(
buf
,
result
);
return
result
;
return
result
;
...
@@ -166,12 +166,12 @@ CAF_TEST(binary serializer picks up inspect functions) {
...
@@ -166,12 +166,12 @@ CAF_TEST(binary serializer picks up inspect functions) {
10
_b
,
11
_b
,
12
_b
,
13
_b
,
14
_b
,
15
_b
,
16
_b
,
17
_b
,
18
_b
,
19
_b
);
10
_b
,
11
_b
,
12
_b
,
13
_b
,
14
_b
,
15
_b
,
16
_b
,
17
_b
,
18
_b
,
19
_b
);
}
}
SUBTEST
(
"custom struct"
)
{
SUBTEST
(
"custom struct"
)
{
test_data
value
{
test_data
value
{
-
345
,
-
345
,
-
1234567890123456789ll
,
-
1234567890123456789ll
,
3.45
,
3.45
,
54.3
,
54.3
,
caf
::
timestamp
{
caf
::
timestamp
::
duration
{
1478715821
*
1000000000ll
}},
caf
::
timestamp
{
caf
::
timestamp
::
duration
{
1478715821
*
1000000000ll
}},
test_enum
::
b
,
test_enum
::
b
,
"Lorem ipsum dolor sit amet."
};
"Lorem ipsum dolor sit amet."
};
CHECK_LOAD
(
test_data
,
value
,
CHECK_LOAD
(
test_data
,
value
,
...
...
libcaf_core/test/binary_serializer.cpp
View file @
86cdab59
...
@@ -9,12 +9,12 @@
...
@@ -9,12 +9,12 @@
#include "core-test.hpp"
#include "core-test.hpp"
#include "nasty.hpp"
#include "nasty.hpp"
#include <cstddef>
#include <cstring>
#include <cstring>
#include <vector>
#include <vector>
#include "caf/actor_system.hpp"
#include "caf/actor_system.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/byte.hpp"
#include "caf/byte_buffer.hpp"
#include "caf/byte_buffer.hpp"
#include "caf/timestamp.hpp"
#include "caf/timestamp.hpp"
...
@@ -22,12 +22,12 @@ using namespace caf;
...
@@ -22,12 +22,12 @@ using namespace caf;
namespace
{
namespace
{
byte
operator
""
_b
(
unsigned
long
long
int
x
)
{
std
::
byte
operator
""
_b
(
unsigned
long
long
int
x
)
{
return
static_cast
<
byte
>
(
x
);
return
static_cast
<
std
::
byte
>
(
x
);
}
}
byte
operator
""
_b
(
char
x
)
{
std
::
byte
operator
""
_b
(
char
x
)
{
return
static_cast
<
byte
>
(
x
);
return
static_cast
<
std
::
byte
>
(
x
);
}
}
struct
arr
{
struct
arr
{
...
@@ -165,13 +165,8 @@ CAF_TEST(binary serializer picks up inspect functions) {
...
@@ -165,13 +165,8 @@ CAF_TEST(binary serializer picks up inspect functions) {
}
}
SUBTEST
(
"custom struct"
)
{
SUBTEST
(
"custom struct"
)
{
caf
::
timestamp
ts
{
caf
::
timestamp
::
duration
{
1478715821
*
1000000000ll
}};
caf
::
timestamp
ts
{
caf
::
timestamp
::
duration
{
1478715821
*
1000000000ll
}};
test_data
value
{
-
345
,
test_data
value
{
-
345
,
-
1234567890123456789ll
,
3.45
,
54.3
,
ts
,
-
1234567890123456789ll
,
test_enum
::
b
,
"Lorem ipsum dolor sit amet."
};
3.45
,
54.3
,
ts
,
test_enum
::
b
,
"Lorem ipsum dolor sit amet."
};
CHECK_SAVE
(
test_data
,
value
,
CHECK_SAVE
(
test_data
,
value
,
// 32-bit i32_ member: -345
// 32-bit i32_ member: -345
0xFF
_b
,
0xFF
_b
,
0xFE
_b
,
0xA7
_b
,
0xFF
_b
,
0xFF
_b
,
0xFE
_b
,
0xA7
_b
,
...
...
libcaf_core/test/byte.cpp
deleted
100644 → 0
View file @
52914200
// 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.
#define CAF_SUITE byte
#include "caf/byte.hpp"
#include "core-test.hpp"
#include <cstdint>
#include "caf/detail/parser/add_ascii.hpp"
#include "caf/raise_error.hpp"
using
namespace
caf
;
namespace
{
byte
operator
""
_b
(
const
char
*
str
,
size_t
n
)
{
size_t
consumed
=
0
;
uint8_t
result
=
0
;
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
if
(
str
[
i
]
!=
'\''
)
{
if
(
!
detail
::
parser
::
add_ascii
<
2
>
(
result
,
str
[
i
]))
CAF_RAISE_ERROR
(
std
::
logic_error
,
"invalid character or over-/underflow"
);
else
++
consumed
;
}
}
if
(
consumed
!=
8
)
CAF_RAISE_ERROR
(
std
::
logic_error
,
"too few digits, expected exactly 8"
);
return
static_cast
<
byte
>
(
result
);
}
struct
fixture
{
fixture
()
{
// Sanity checks.
if
(
"0001'1100"
_b
!=
static_cast
<
byte
>
(
0x1C
))
CAF_FAIL
(
"operator
\"\"
_b broken"
);
if
(
"1000'0001"
_b
!=
static_cast
<
byte
>
(
0x81
))
CAF_FAIL
(
"operator
\"\"
_b broken"
);
}
};
}
// namespace
CAF_TEST_FIXTURE_SCOPE
(
byte_tests
,
fixture
)
CAF_TEST
(
to
integer
)
{
CAF_CHECK_EQUAL
(
to_integer
<
int
>
(
"0110'1001"
_b
),
0x69
);
}
CAF_TEST
(
left
shift
)
{
auto
x
=
"0000'0001"
_b
;
x
<<=
1
;
CAF_CHECK_EQUAL
(
x
,
"0000'0010"
_b
);
CAF_CHECK_EQUAL
(
"0000'0010"
_b
<<
1
,
"0000'0100"
_b
);
CAF_CHECK_EQUAL
(
"0000'0010"
_b
<<
2
,
"0000'1000"
_b
);
CAF_CHECK_EQUAL
(
"0000'0010"
_b
<<
3
,
"0001'0000"
_b
);
CAF_CHECK_EQUAL
(
"0000'0010"
_b
<<
4
,
"0010'0000"
_b
);
CAF_CHECK_EQUAL
(
"0000'0010"
_b
<<
5
,
"0100'0000"
_b
);
CAF_CHECK_EQUAL
(
"0000'0010"
_b
<<
6
,
"1000'0000"
_b
);
CAF_CHECK_EQUAL
(
"0000'0010"
_b
<<
7
,
"0000'0000"
_b
);
}
CAF_TEST
(
right
shift
)
{
auto
x
=
"0100'0000"
_b
;
x
>>=
1
;
CAF_CHECK_EQUAL
(
x
,
"0010'0000"
_b
);
CAF_CHECK_EQUAL
(
"0100'0000"
_b
>>
1
,
"0010'0000"
_b
);
CAF_CHECK_EQUAL
(
"0100'0000"
_b
>>
2
,
"0001'0000"
_b
);
CAF_CHECK_EQUAL
(
"0100'0000"
_b
>>
3
,
"0000'1000"
_b
);
CAF_CHECK_EQUAL
(
"0100'0000"
_b
>>
4
,
"0000'0100"
_b
);
CAF_CHECK_EQUAL
(
"0100'0000"
_b
>>
5
,
"0000'0010"
_b
);
CAF_CHECK_EQUAL
(
"0100'0000"
_b
>>
6
,
"0000'0001"
_b
);
CAF_CHECK_EQUAL
(
"0100'0000"
_b
>>
7
,
"0000'0000"
_b
);
}
CAF_TEST
(
bitwise
or
)
{
auto
x
=
"0001'1110"
_b
;
x
|=
"0111'1000"
_b
;
CAF_CHECK_EQUAL
(
x
,
"0111'1110"
_b
);
CAF_CHECK_EQUAL
(
"0001'1110"
_b
|
"0111'1000"
_b
,
"0111'1110"
_b
);
}
CAF_TEST
(
bitwise
and
)
{
auto
x
=
"0001'1110"
_b
;
x
&=
"0111'1000"
_b
;
CAF_CHECK_EQUAL
(
x
,
"0001'1000"
_b
);
CAF_CHECK_EQUAL
(
"0001'1110"
_b
&
"0111'1000"
_b
,
"0001'1000"
_b
);
}
CAF_TEST
(
bitwise
xor
)
{
auto
x
=
"0001'1110"
_b
;
x
^=
"0111'1000"
_b
;
CAF_CHECK_EQUAL
(
x
,
"0110'0110"
_b
);
CAF_CHECK_EQUAL
(
"0001'1110"
_b
^
"0111'1000"
_b
,
"0110'0110"
_b
);
}
CAF_TEST
(
bitwise
not
)
{
CAF_CHECK_EQUAL
(
~
"0111'1110"
_b
,
"1000'0001"
_b
);
}
CAF_TEST_FIXTURE_SCOPE_END
()
libcaf_core/test/hash/sha1.cpp
View file @
86cdab59
...
@@ -15,7 +15,7 @@ namespace {
...
@@ -15,7 +15,7 @@ namespace {
template
<
class
...
Ts
>
template
<
class
...
Ts
>
auto
make_hash
(
Ts
...
xs
)
{
auto
make_hash
(
Ts
...
xs
)
{
static_assert
(
sizeof
...(
Ts
)
==
20
);
static_assert
(
sizeof
...(
Ts
)
==
20
);
return
hash
::
sha1
::
result_type
{{
static_cast
<
byte
>
(
xs
)...}};
return
hash
::
sha1
::
result_type
{{
static_cast
<
std
::
byte
>
(
xs
)...}};
}
}
}
// namespace
}
// namespace
...
...
libcaf_core/test/load_inspector.cpp
View file @
86cdab59
...
@@ -187,10 +187,10 @@ struct testee : deserializer {
...
@@ -187,10 +187,10 @@ struct testee : deserializer {
return
true
;
return
true
;
}
}
bool
value
(
byte
&
x
)
override
{
bool
value
(
std
::
byte
&
x
)
override
{
new_line
();
new_line
();
log
+=
"byte value"
;
log
+=
"
std::
byte value"
;
x
=
byte
{};
x
=
std
::
byte
{};
return
true
;
return
true
;
}
}
...
@@ -250,11 +250,11 @@ struct testee : deserializer {
...
@@ -250,11 +250,11 @@ struct testee : deserializer {
return
primitive_value
(
x
);
return
primitive_value
(
x
);
}
}
bool
value
(
span
<
byte
>
xs
)
override
{
bool
value
(
span
<
std
::
byte
>
xs
)
override
{
new_line
();
new_line
();
log
+=
"caf::span<caf::byte> value"
;
log
+=
"caf::span<caf::
std::
byte> value"
;
for
(
auto
&
x
:
xs
)
for
(
auto
&
x
:
xs
)
x
=
byte
{
0
};
x
=
std
::
byte
{
0
};
return
true
;
return
true
;
}
}
};
};
...
@@ -762,7 +762,7 @@ SCENARIO("load inspectors support std::byte") {
...
@@ -762,7 +762,7 @@ SCENARIO("load inspectors support std::byte") {
std
::
string
baseline
=
R"_(
std
::
string
baseline
=
R"_(
begin object anonymous
begin object anonymous
begin field v1
begin field v1
uint8_t
value
std::byte
value
end field
end field
begin optional field v2
begin optional field v2
end field
end field
...
...
libcaf_core/test/save_inspector.cpp
View file @
86cdab59
...
@@ -161,7 +161,7 @@ struct testee : serializer {
...
@@ -161,7 +161,7 @@ struct testee : serializer {
return
true
;
return
true
;
}
}
bool
value
(
byte
)
override
{
bool
value
(
std
::
byte
)
override
{
new_line
();
new_line
();
log
+=
"byte value"
;
log
+=
"byte value"
;
return
true
;
return
true
;
...
@@ -257,7 +257,7 @@ struct testee : serializer {
...
@@ -257,7 +257,7 @@ struct testee : serializer {
return
true
;
return
true
;
}
}
bool
value
(
span
<
const
byte
>
)
override
{
bool
value
(
span
<
const
std
::
byte
>
)
override
{
new_line
();
new_line
();
log
+=
"byte_span value"
;
log
+=
"byte_span value"
;
return
true
;
return
true
;
...
@@ -799,10 +799,10 @@ SCENARIO("save inspectors support std::byte") {
...
@@ -799,10 +799,10 @@ SCENARIO("save inspectors support std::byte") {
std
::
string
baseline
=
R"_(
std
::
string
baseline
=
R"_(
begin object anonymous
begin object anonymous
begin field v1
begin field v1
uint8_t
value
byte
value
end field
end field
begin optional field v2
begin optional field v2
uint8_t
value
byte
value
end field
end field
end object)_"
;
end object)_"
;
CHECK_EQ
(
f
.
log
,
baseline
);
CHECK_EQ
(
f
.
log
,
baseline
);
...
...
libcaf_core/test/uuid.cpp
View file @
86cdab59
...
@@ -28,7 +28,8 @@ uuid operator"" _uuid(const char* cstr, size_t cstr_len) {
...
@@ -28,7 +28,8 @@ uuid operator"" _uuid(const char* cstr, size_t cstr_len) {
for
(
size_t
index
=
0
;
index
<
16
;
++
index
)
{
for
(
size_t
index
=
0
;
index
<
16
;
++
index
)
{
auto
input_index
=
index
*
2
;
auto
input_index
=
index
*
2
;
char
buf
[]
=
{
str
[
input_index
],
str
[
input_index
+
1
],
'\0'
};
char
buf
[]
=
{
str
[
input_index
],
str
[
input_index
+
1
],
'\0'
};
result
.
bytes
().
at
(
index
)
=
static_cast
<
byte
>
(
std
::
stoi
(
buf
,
nullptr
,
16
));
result
.
bytes
().
at
(
index
)
=
static_cast
<
std
::
byte
>
(
std
::
stoi
(
buf
,
nullptr
,
16
));
}
}
return
result
;
return
result
;
}
}
...
@@ -58,7 +59,7 @@ CAF_TEST_FIXTURE_SCOPE(uuid_tests, fixture)
...
@@ -58,7 +59,7 @@ CAF_TEST_FIXTURE_SCOPE(uuid_tests, fixture)
CAF_TEST
(
default
generated
UUIDs
have
all
128
bits
set
to
zero
)
{
CAF_TEST
(
default
generated
UUIDs
have
all
128
bits
set
to
zero
)
{
uuid
nil
;
uuid
nil
;
CAF_CHECK
(
!
nil
);
CAF_CHECK
(
!
nil
);
auto
zero
=
[](
byte
x
)
{
return
to_integer
<
int
>
(
x
)
==
0
;
};
auto
zero
=
[](
std
::
byte
x
)
{
return
static_cast
<
int
>
(
x
)
==
0
;
};
CAF_CHECK
(
std
::
all_of
(
nil
.
bytes
().
begin
(),
nil
.
bytes
().
end
(),
zero
));
CAF_CHECK
(
std
::
all_of
(
nil
.
bytes
().
begin
(),
nil
.
bytes
().
end
(),
zero
));
CAF_CHECK
(
nil
==
uuid
::
nil
());
CAF_CHECK
(
nil
==
uuid
::
nil
());
}
}
...
...
libcaf_io/caf/io/abstract_broker.hpp
View file @
86cdab59
...
@@ -38,7 +38,7 @@ class middleman;
...
@@ -38,7 +38,7 @@ class middleman;
///
///
/// Brokers do *not* operate on sockets or other platform-dependent
/// Brokers do *not* operate on sockets or other platform-dependent
/// communication primitives. Instead, brokers use a `connection_handle`
/// communication primitives. Instead, brokers use a `connection_handle`
/// to identify a reliable, end-to-end byte stream (e.g. a TCP connection)
/// to identify a reliable, end-to-end
std::
byte stream (e.g. a TCP connection)
/// and `accept_handle` to identify a communication endpoint others can
/// and `accept_handle` to identify a communication endpoint others can
/// connect to via its port.
/// connect to via its port.
///
///
...
@@ -145,7 +145,7 @@ public:
...
@@ -145,7 +145,7 @@ public:
void
write
(
connection_handle
hdl
,
size_t
bs
,
const
void
*
buf
);
void
write
(
connection_handle
hdl
,
size_t
bs
,
const
void
*
buf
);
/// Writes `buf` into the buffer for a given connection.
/// Writes `buf` into the buffer for a given connection.
void
write
(
connection_handle
hdl
,
span
<
const
byte
>
buf
);
void
write
(
connection_handle
hdl
,
span
<
const
std
::
byte
>
buf
);
/// Sends the content of the buffer for a given connection.
/// Sends the content of the buffer for a given connection.
void
flush
(
connection_handle
hdl
);
void
flush
(
connection_handle
hdl
);
...
@@ -179,8 +179,8 @@ public:
...
@@ -179,8 +179,8 @@ public:
/// Tries to connect to `host` on given `port` and creates
/// Tries to connect to `host` on given `port` and creates
/// a new scribe describing the connection afterwards.
/// a new scribe describing the connection afterwards.
/// @returns The handle of the new `scribe` on success.
/// @returns The handle of the new `scribe` on success.
expected
<
connection_handle
>
expected
<
connection_handle
>
add_tcp_scribe
(
const
std
::
string
&
host
,
add_tcp_scribe
(
const
std
::
string
&
host
,
uint16_t
port
);
uint16_t
port
);
/// Moves the initialized `scribe` instance `ptr` from another broker to this
/// Moves the initialized `scribe` instance `ptr` from another broker to this
/// broker.
/// broker.
...
@@ -207,8 +207,8 @@ public:
...
@@ -207,8 +207,8 @@ public:
void
add_datagram_servant
(
datagram_servant_ptr
ptr
);
void
add_datagram_servant
(
datagram_servant_ptr
ptr
);
/// Adds the `datagram_servant` under an additional `hdl`.
/// Adds the `datagram_servant` under an additional `hdl`.
void
void
add_hdl_for_datagram_servant
(
datagram_servant_ptr
ptr
,
add_hdl_for_datagram_servant
(
datagram_servant_ptr
ptr
,
datagram_handle
hdl
);
datagram_handle
hdl
);
/// Creates and assigns a new `datagram_servant` from a given socket `fd`.
/// Creates and assigns a new `datagram_servant` from a given socket `fd`.
datagram_handle
add_datagram_servant
(
network
::
native_socket
fd
);
datagram_handle
add_datagram_servant
(
network
::
native_socket
fd
);
...
@@ -222,8 +222,8 @@ public:
...
@@ -222,8 +222,8 @@ public:
/// Creates a new `datagram_servant` for the remote endpoint `host` and
/// Creates a new `datagram_servant` for the remote endpoint `host` and
/// `port`.
/// `port`.
/// @returns The handle to the new `datagram_servant`.
/// @returns The handle to the new `datagram_servant`.
expected
<
datagram_handle
>
expected
<
datagram_handle
>
add_udp_datagram_servant
(
const
std
::
string
&
host
,
add_udp_datagram_servant
(
const
std
::
string
&
host
,
uint16_t
port
);
uint16_t
port
);
/// Tries to open a local port and creates a `datagram_servant` managing it on
/// Tries to open a local port and creates a `datagram_servant` managing it on
/// success. If `port == 0`, then the broker will ask the operating system to
/// success. If `port == 0`, then the broker will ask the operating system to
...
...
libcaf_io/src/io/abstract_broker.cpp
View file @
86cdab59
...
@@ -81,12 +81,12 @@ byte_buffer& abstract_broker::wr_buf(connection_handle hdl) {
...
@@ -81,12 +81,12 @@ byte_buffer& abstract_broker::wr_buf(connection_handle hdl) {
void
abstract_broker
::
write
(
connection_handle
hdl
,
size_t
bs
,
const
void
*
buf
)
{
void
abstract_broker
::
write
(
connection_handle
hdl
,
size_t
bs
,
const
void
*
buf
)
{
auto
&
out
=
wr_buf
(
hdl
);
auto
&
out
=
wr_buf
(
hdl
);
auto
first
=
reinterpret_cast
<
const
byte
*>
(
buf
);
auto
first
=
reinterpret_cast
<
const
std
::
byte
*>
(
buf
);
auto
last
=
first
+
bs
;
auto
last
=
first
+
bs
;
out
.
insert
(
out
.
end
(),
first
,
last
);
out
.
insert
(
out
.
end
(),
first
,
last
);
}
}
void
abstract_broker
::
write
(
connection_handle
hdl
,
span
<
const
byte
>
buf
)
{
void
abstract_broker
::
write
(
connection_handle
hdl
,
span
<
const
std
::
byte
>
buf
)
{
write
(
hdl
,
buf
.
size
(),
buf
.
data
());
write
(
hdl
,
buf
.
size
(),
buf
.
data
());
}
}
...
@@ -121,7 +121,7 @@ void abstract_broker::enqueue_datagram(datagram_handle hdl, byte_buffer buf) {
...
@@ -121,7 +121,7 @@ void abstract_broker::enqueue_datagram(datagram_handle hdl, byte_buffer buf) {
void
abstract_broker
::
write
(
datagram_handle
hdl
,
size_t
bs
,
const
void
*
buf
)
{
void
abstract_broker
::
write
(
datagram_handle
hdl
,
size_t
bs
,
const
void
*
buf
)
{
auto
&
out
=
wr_buf
(
hdl
);
auto
&
out
=
wr_buf
(
hdl
);
auto
first
=
reinterpret_cast
<
const
byte
*>
(
buf
);
auto
first
=
reinterpret_cast
<
const
std
::
byte
*>
(
buf
);
auto
last
=
first
+
bs
;
auto
last
=
first
+
bs
;
out
.
insert
(
out
.
end
(),
first
,
last
);
out
.
insert
(
out
.
end
(),
first
,
last
);
}
}
...
@@ -339,8 +339,8 @@ resumable::subtype_t abstract_broker::subtype() const {
...
@@ -339,8 +339,8 @@ resumable::subtype_t abstract_broker::subtype() const {
return
io_actor
;
return
io_actor
;
}
}
resumable
::
resume_result
resumable
::
resume_result
abstract_broker
::
resume
(
execution_unit
*
ctx
,
abstract_broker
::
resume
(
execution_unit
*
ctx
,
size_t
mt
)
{
size_t
mt
)
{
CAF_ASSERT
(
ctx
!=
nullptr
);
CAF_ASSERT
(
ctx
!=
nullptr
);
CAF_ASSERT
(
ctx
==
backend_
);
CAF_ASSERT
(
ctx
==
backend_
);
return
scheduled_actor
::
resume
(
ctx
,
mt
);
return
scheduled_actor
::
resume
(
ctx
,
mt
);
...
...
libcaf_io/src/io/basp/instance.cpp
View file @
86cdab59
...
@@ -521,7 +521,7 @@ void instance::forward(execution_unit* ctx, const node_id& dest_node,
...
@@ -521,7 +521,7 @@ void instance::forward(execution_unit* ctx, const node_id& dest_node,
CAF_LOG_ERROR
(
"unable to serialize BASP header:"
<<
sink
.
get_error
());
CAF_LOG_ERROR
(
"unable to serialize BASP header:"
<<
sink
.
get_error
());
return
;
return
;
}
}
sink
.
value
(
span
<
const
byte
>
{
payload
.
data
(),
payload
.
size
()});
sink
.
value
(
span
<
const
std
::
byte
>
{
payload
.
data
(),
payload
.
size
()});
flush
(
*
path
);
flush
(
*
path
);
}
else
{
}
else
{
CAF_LOG_WARNING
(
"cannot forward message, no route to destination"
);
CAF_LOG_WARNING
(
"cannot forward message, no route to destination"
);
...
...
libcaf_io/src/io/network/datagram_handler.cpp
View file @
86cdab59
...
@@ -56,7 +56,7 @@ void datagram_handler::write(datagram_handle hdl, const void* buf,
...
@@ -56,7 +56,7 @@ void datagram_handler::write(datagram_handle hdl, const void* buf,
size_t
num_bytes
)
{
size_t
num_bytes
)
{
wr_offline_buf_
.
emplace_back
();
wr_offline_buf_
.
emplace_back
();
wr_offline_buf_
.
back
().
first
=
hdl
;
wr_offline_buf_
.
back
().
first
=
hdl
;
auto
cbuf
=
reinterpret_cast
<
const
byte
*>
(
buf
);
auto
cbuf
=
reinterpret_cast
<
const
std
::
byte
*>
(
buf
);
wr_offline_buf_
.
back
().
second
.
assign
(
wr_offline_buf_
.
back
().
second
.
assign
(
cbuf
,
cbuf
+
static_cast
<
ptrdiff_t
>
(
num_bytes
));
cbuf
,
cbuf
+
static_cast
<
ptrdiff_t
>
(
num_bytes
));
}
}
...
...
libcaf_io/src/io/network/stream.cpp
View file @
86cdab59
...
@@ -46,7 +46,7 @@ void stream::configure_read(receive_policy::config config) {
...
@@ -46,7 +46,7 @@ void stream::configure_read(receive_policy::config config) {
void
stream
::
write
(
const
void
*
buf
,
size_t
num_bytes
)
{
void
stream
::
write
(
const
void
*
buf
,
size_t
num_bytes
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
num_bytes
));
CAF_LOG_TRACE
(
CAF_ARG
(
num_bytes
));
auto
first
=
reinterpret_cast
<
const
byte
*>
(
buf
);
auto
first
=
reinterpret_cast
<
const
std
::
byte
*>
(
buf
);
auto
last
=
first
+
num_bytes
;
auto
last
=
first
+
num_bytes
;
wr_offline_buf_
.
insert
(
wr_offline_buf_
.
end
(),
first
,
last
);
wr_offline_buf_
.
insert
(
wr_offline_buf_
.
end
(),
first
,
last
);
}
}
...
...
libcaf_io/src/io/network/test_multiplexer.cpp
View file @
86cdab59
...
@@ -119,8 +119,8 @@ scribe_ptr test_multiplexer::new_scribe(connection_handle hdl) {
...
@@ -119,8 +119,8 @@ scribe_ptr test_multiplexer::new_scribe(connection_handle hdl) {
return
sptr
;
return
sptr
;
}
}
expected
<
scribe_ptr
>
expected
<
scribe_ptr
>
test_multiplexer
::
new_tcp_scribe
(
const
std
::
string
&
host
,
test_multiplexer
::
new_tcp_scribe
(
const
std
::
string
&
host
,
uint16_t
port
)
{
uint16_t
port
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
host
)
<<
CAF_ARG
(
port
));
CAF_LOG_TRACE
(
CAF_ARG
(
host
)
<<
CAF_ARG
(
port
));
connection_handle
hdl
;
connection_handle
hdl
;
{
// lifetime scope of guard
{
// lifetime scope of guard
...
@@ -198,8 +198,8 @@ doorman_ptr test_multiplexer::new_doorman(accept_handle hdl, uint16_t port) {
...
@@ -198,8 +198,8 @@ doorman_ptr test_multiplexer::new_doorman(accept_handle hdl, uint16_t port) {
return
dptr
;
return
dptr
;
}
}
expected
<
doorman_ptr
>
expected
<
doorman_ptr
>
test_multiplexer
::
new_tcp_doorman
(
uint16_t
desired_port
,
test_multiplexer
::
new_tcp_doorman
(
uint16_t
desired_port
,
const
char
*
,
bool
)
{
const
char
*
,
bool
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
desired_port
));
CAF_LOG_TRACE
(
CAF_ARG
(
desired_port
));
accept_handle
hdl
;
accept_handle
hdl
;
uint16_t
port
=
0
;
uint16_t
port
=
0
;
...
@@ -304,8 +304,8 @@ test_multiplexer::new_local_udp_endpoint(uint16_t desired_port, const char*,
...
@@ -304,8 +304,8 @@ test_multiplexer::new_local_udp_endpoint(uint16_t desired_port, const char*,
return
new_datagram_servant
(
hdl
,
port
);
return
new_datagram_servant
(
hdl
,
port
);
}
}
datagram_servant_ptr
datagram_servant_ptr
test_multiplexer
::
new_datagram_servant
(
datagram_handle
hdl
,
test_multiplexer
::
new_datagram_servant
(
datagram_handle
hdl
,
uint16_t
port
)
{
uint16_t
port
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
));
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
));
class
impl
:
public
datagram_servant
{
class
impl
:
public
datagram_servant
{
public:
public:
...
@@ -416,8 +416,8 @@ test_multiplexer::new_datagram_servant(datagram_handle hdl, uint16_t port) {
...
@@ -416,8 +416,8 @@ test_multiplexer::new_datagram_servant(datagram_handle hdl, uint16_t port) {
return
dptr
;
return
dptr
;
}
}
datagram_servant_ptr
datagram_servant_ptr
test_multiplexer
::
new_datagram_servant
(
datagram_handle
,
test_multiplexer
::
new_datagram_servant
(
datagram_handle
,
const
std
::
string
&
,
const
std
::
string
&
,
uint16_t
)
{
uint16_t
)
{
CAF_CRITICAL
(
"This has no implementation in the test multiplexer"
);
CAF_CRITICAL
(
"This has no implementation in the test multiplexer"
);
}
}
...
@@ -427,8 +427,9 @@ int64_t test_multiplexer::next_endpoint_id() {
...
@@ -427,8 +427,9 @@ int64_t test_multiplexer::next_endpoint_id() {
}
}
bool
test_multiplexer
::
is_known_port
(
uint16_t
x
)
const
{
bool
test_multiplexer
::
is_known_port
(
uint16_t
x
)
const
{
auto
pred1
auto
pred1
=
[
&
](
const
doorman_data_map
::
value_type
&
y
)
{
=
[
&
](
const
doorman_data_map
::
value_type
&
y
)
{
return
x
==
y
.
second
.
port
;
};
return
x
==
y
.
second
.
port
;
};
auto
pred2
=
[
&
](
const
datagram_data_map
::
value_type
&
y
)
{
auto
pred2
=
[
&
](
const
datagram_data_map
::
value_type
&
y
)
{
return
x
==
y
.
second
->
port
;
return
x
==
y
.
second
->
port
;
};
};
...
@@ -438,8 +439,9 @@ bool test_multiplexer::is_known_port(uint16_t x) const {
...
@@ -438,8 +439,9 @@ bool test_multiplexer::is_known_port(uint16_t x) const {
}
}
bool
test_multiplexer
::
is_known_handle
(
accept_handle
x
)
const
{
bool
test_multiplexer
::
is_known_handle
(
accept_handle
x
)
const
{
auto
pred
auto
pred
=
[
&
](
const
pending_doorman_map
::
value_type
&
y
)
{
=
[
&
](
const
pending_doorman_map
::
value_type
&
y
)
{
return
x
==
y
.
second
;
};
return
x
==
y
.
second
;
};
return
doorman_data_
.
count
(
x
)
>
0
return
doorman_data_
.
count
(
x
)
>
0
||
std
::
any_of
(
doormen_
.
begin
(),
doormen_
.
end
(),
pred
);
||
std
::
any_of
(
doormen_
.
begin
(),
doormen_
.
end
(),
pred
);
}
}
...
@@ -887,7 +889,7 @@ bool test_multiplexer::read_data(datagram_handle hdl) {
...
@@ -887,7 +889,7 @@ bool test_multiplexer::read_data(datagram_handle hdl) {
CAF_ASSERT
(
to
.
second
.
capacity
()
>
from
.
second
.
size
());
CAF_ASSERT
(
to
.
second
.
capacity
()
>
from
.
second
.
size
());
to
.
second
.
resize
(
from
.
second
.
size
());
to
.
second
.
resize
(
from
.
second
.
size
());
std
::
transform
(
from
.
second
.
begin
(),
from
.
second
.
end
(),
to
.
second
.
begin
(),
std
::
transform
(
from
.
second
.
begin
(),
from
.
second
.
end
(),
to
.
second
.
begin
(),
[](
byte
x
)
{
return
caf
::
to_integer
<
char
>
(
x
);
});
[](
std
::
byte
x
)
{
return
static_cast
<
char
>
(
x
);
});
data
->
vn_buf
.
pop_front
();
data
->
vn_buf
.
pop_front
();
auto
sitr
=
datagram_data_
.
find
(
data
->
rd_buf
.
first
);
auto
sitr
=
datagram_data_
.
find
(
data
->
rd_buf
.
first
);
if
(
sitr
==
datagram_data_
.
end
())
{
if
(
sitr
==
datagram_data_
.
end
())
{
...
...
libcaf_io/test/io/broker.cpp
View file @
86cdab59
...
@@ -76,7 +76,7 @@ behavior peer_fun(broker* self, connection_handle hdl, const actor& buddy) {
...
@@ -76,7 +76,7 @@ behavior peer_fun(broker* self, connection_handle hdl, const actor& buddy) {
self
->
configure_read
(
hdl
,
receive_policy
::
exactly
(
sizeof
(
type_id_t
)));
self
->
configure_read
(
hdl
,
receive_policy
::
exactly
(
sizeof
(
type_id_t
)));
auto
write
=
[
=
](
type_id_t
type
)
{
auto
write
=
[
=
](
type_id_t
type
)
{
auto
&
buf
=
self
->
wr_buf
(
hdl
);
auto
&
buf
=
self
->
wr_buf
(
hdl
);
auto
first
=
reinterpret_cast
<
byte
*>
(
&
type
);
auto
first
=
reinterpret_cast
<
std
::
byte
*>
(
&
type
);
buf
.
insert
(
buf
.
end
(),
first
,
first
+
sizeof
(
type_id_t
));
buf
.
insert
(
buf
.
end
(),
first
,
first
+
sizeof
(
type_id_t
));
self
->
flush
(
hdl
);
self
->
flush
(
hdl
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment