Skip to content

Commit 30386f3

Browse files
committed
clang-format portable-archive
1 parent 453bba4 commit 30386f3

File tree

5 files changed

+470
-495
lines changed

5 files changed

+470
-495
lines changed

src/portable_archive/portable_archive_exception.hpp

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,66 +17,59 @@
1717

1818
namespace eos {
1919

20-
// this value is written to the top of the stream
21-
const signed char magic_byte = 'e' | 'o' | 's';
20+
// this value is written to the top of the stream
21+
const signed char magic_byte = 'e' | 'o' | 's';
2222

23-
// flag for fp serialization
24-
const unsigned no_infnan = 64;
23+
// flag for fp serialization
24+
const unsigned no_infnan = 64;
2525

26-
// integral type for the archive version
27-
using archive_version_type = lslboost::archive::library_version_type;
26+
// integral type for the archive version
27+
using archive_version_type = lslboost::archive::library_version_type;
2828

29-
// version of the linked lslboost archive library
30-
const archive_version_type archive_version(
31-
lslboost::archive::BOOST_ARCHIVE_VERSION()
32-
);
29+
// version of the linked lslboost archive library
30+
const archive_version_type archive_version(lslboost::archive::BOOST_ARCHIVE_VERSION());
3331

34-
/**
35-
* \brief Exception being thrown when serialization cannot proceed.
36-
*
37-
* There are several situations in which the portable archives may fail and
38-
* hence throw an exception:
39-
* -# deserialization of an integer value that exceeds the range of the type
40-
* -# (de)serialization of inf/nan through an archive with no_infnan flag set
41-
* -# deserialization of a denormalized value without the floating point type
42-
* supporting denormalized numbers
43-
*
44-
* Note that this exception will also be thrown if you mixed up your stream
45-
* position and accidentially interpret some value for size data (in this case
46-
* the reported size will be totally amiss most of the time).
47-
*/
48-
class portable_archive_exception : public lslboost::archive::archive_exception
49-
{
50-
std::string msg;
32+
/**
33+
* \brief Exception being thrown when serialization cannot proceed.
34+
*
35+
* There are several situations in which the portable archives may fail and
36+
* hence throw an exception:
37+
* -# deserialization of an integer value that exceeds the range of the type
38+
* -# (de)serialization of inf/nan through an archive with no_infnan flag set
39+
* -# deserialization of a denormalized value without the floating point type
40+
* supporting denormalized numbers
41+
*
42+
* Note that this exception will also be thrown if you mixed up your stream
43+
* position and accidentially interpret some value for size data (in this case
44+
* the reported size will be totally amiss most of the time).
45+
*/
46+
class portable_archive_exception : public lslboost::archive::archive_exception {
47+
std::string msg;
5148

52-
public:
53-
//! type size is not large enough for deserialized number
54-
portable_archive_exception(signed char invalid_size)
55-
: lslboost::archive::archive_exception(other_exception)
56-
, msg("requested integer size exceeds type size: ")
57-
{
58-
msg += std::to_string(invalid_size);
59-
}
49+
public:
50+
//! type size is not large enough for deserialized number
51+
portable_archive_exception(signed char invalid_size)
52+
: lslboost::archive::archive_exception(other_exception),
53+
msg("requested integer size exceeds type size: ") {
54+
msg += std::to_string(invalid_size);
55+
}
6056

61-
//! negative number in unsigned type
62-
portable_archive_exception()
63-
: lslboost::archive::archive_exception(other_exception)
64-
, msg("cannot read a negative number into an unsigned type")
65-
{
66-
}
57+
//! negative number in unsigned type
58+
portable_archive_exception()
59+
: lslboost::archive::archive_exception(other_exception),
60+
msg("cannot read a negative number into an unsigned type") {}
6761

68-
//! serialization of inf, nan and denormals
69-
template <typename T>
70-
portable_archive_exception(const T& abnormal)
71-
: lslboost::archive::archive_exception(other_exception)
72-
, msg("serialization of illegal floating point value: ")
73-
{
74-
msg += std::to_string(abnormal);
75-
}
62+
//! serialization of inf, nan and denormals
63+
template <typename T>
64+
portable_archive_exception(const T &abnormal)
65+
: lslboost::archive::archive_exception(other_exception),
66+
msg("serialization of illegal floating point value: ") {
67+
msg += std::to_string(abnormal);
68+
}
7669

77-
//! override the base class function with our message
78-
const char *what() const noexcept override { return msg.c_str(); }
79-
~portable_archive_exception() noexcept override = default;
80-
};
70+
//! override the base class function with our message
71+
const char *what() const noexcept override { return msg.c_str(); }
72+
~portable_archive_exception() noexcept override = default;
73+
};
8174

8275
} // namespace eos

src/portable_archive/portable_archive_includes.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* Based on the portable archive example by Robert Ramey this implementation
1515
* uses Beman Dawes endian library and fp_utilities from Johan Rade, both being
1616
* in boost since 1.36. Prior to that you need to add them both (header only)
17-
* to your boost directory before you're able to use the archives provided.
17+
* to your boost directory before you're able to use the archives provided.
1818
* Our archives have been tested successfully for boost versions 1.33 to 1.49!
1919
*
20-
* \note This version adds support for the USE_SHRINKWRAPPED_BOOST define,
21-
* which allows to toggle between a vanilla boost distribution and one with
20+
* \note This version adds support for the USE_SHRINKWRAPPED_BOOST define,
21+
* which allows to toggle between a vanilla boost distribution and one with
2222
* mangled names (custom to LSL).
2323
*
2424
* \note Correct behaviour has so far been confirmed using PowerPC-32, x86-32
@@ -34,7 +34,7 @@
3434
* Arash Abghari for this suggestion). With that all unit tests from the
3535
* serialization library pass again with the notable exception of user
3636
* defined primitive types. Those are not supported and as a result any
37-
* user defined type to be used with the portable archives are required
37+
* user defined type to be used with the portable archives are required
3838
* to be at least object_serializable.
3939
*
4040
* \note Oliver Putz pointed out that -0.0 was not serialized correctly, so
@@ -100,8 +100,7 @@
100100
#include <type_traits>
101101

102102
namespace lsl {
103-
template<typename T>
104-
int fpclassify(T val) { return std::fpclassify(val); }
103+
template <typename T> int fpclassify(T val) { return std::fpclassify(val); }
105104
using std::isfinite;
106105
namespace detail {
107106

@@ -112,7 +111,6 @@ template <> struct fp_traits_consts<double> {
112111
significand = ((0x000fffffll) << 32) + (0xfffffffful);
113112
static void get_bits(double src, bits &dst) { std::memcpy(&dst, &src, sizeof(src)); }
114113
static void set_bits(double &dst, bits src) { std::memcpy(&dst, &src, sizeof(src)); }
115-
116114
};
117115
template <> struct fp_traits_consts<float> {
118116
using bits = uint32_t;

0 commit comments

Comments
 (0)