diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/array_list.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/array_list.hpp index 27f77189f4..cd7d41e0a4 100644 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/array_list.hpp +++ b/crypto3/libs/marshalling/core/include/nil/marshalling/types/array_list.hpp @@ -250,56 +250,6 @@ namespace nil::crypto3 { return base_impl_type::max_length(); } - /// @brief Force number of elements that must be read in the next read() - /// invocation. - /// @details Exists only if nil::crypto3::marshalling::option::sequence_size_forcing_enabled option has been - /// used. - /// @param[in] count Number of elements to read during following read operation. - void force_read_elem_count(std::size_t count) { - return base_impl_type::force_read_elem_count(count); - } - - /// @brief Clear forcing of the number of elements that must be read in the next read() - /// invocation. - /// @details Exists only if nil::crypto3::marshalling::option::sequence_size_forcing_enabled option has been - /// used. - void clear_read_elem_count() { - return base_impl_type::clear_read_elem_count(); - } - - /// @brief Force available length for the next read() invocation. - /// @details Exists only if @ref nil::crypto3::marshalling::option::sequence_length_forcing_enabled option has been - /// used. - /// @param[in] count Number of elements to read during following read operation. - void force_read_length(std::size_t count) { - return base_impl_type::force_read_length(count); - } - - /// @brief Clear forcing of the available length in the next read() - /// invocation. - /// @details Exists only if @ref nil::crypto3::marshalling::option::sequence_length_forcing_enabled option has been - /// used. - void clear_read_length_forcing() { - return base_impl_type::clear_read_length_forcing(); - } - - /// @brief Force serialization length of a single element. - /// @details The function can be used to force a serialization length of a - /// single element within the array_list. - /// Exists only if @ref nil::crypto3::marshalling::option::SequenceElemLengthForcingEnabled option has been - /// used. - /// @param[in] count Number of elements to read during following read operation. - void force_read_elem_length(std::size_t count) { - return base_impl_type::force_read_elem_length(count); - } - - /// @brief Clear forcing the serialization length of the single element. - /// @details Exists only if nil::crypto3::marshalling::option::SequenceElemLengthForcingEnabled option has been - /// used. - void clear_read_elem_length_forcing() { - return base_impl_type::clear_read_elem_length_forcing(); - } - /// @brief Compile time check if this class is version dependent static constexpr bool is_version_dependent() { return parsed_options_type::has_custom_version_update || base_impl_type::is_version_dependent(); diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/array_list/basic_type.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/array_list/basic_type.hpp index 7ac6dcdac3..1abdeb4d3e 100644 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/array_list/basic_type.hpp +++ b/crypto3/libs/marshalling/core/include/nil/marshalling/types/array_list/basic_type.hpp @@ -291,7 +291,7 @@ namespace nil::crypto3 { return sum + e.length(); }); } - + constexpr std::size_t bit_length_internal(field_elem_tag) const { return bit_field_length(field_elem_tag()); } diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitfield.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitfield.hpp deleted file mode 100644 index 83ddbd6c99..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitfield.hpp +++ /dev/null @@ -1,332 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef MARSHALLING_BITFIELD_HPP -#define MARSHALLING_BITFIELD_HPP - -#include -#include -#include -#include - -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - - /// @brief bitfield field. - /// @details Sometimes one or several bytes can be logically split into two - /// or more independent values, which are packed together to save some - /// space. For example, one enum type that has only 4 possible values, i.e - /// only two bits are needed to encode such value. It would be a waste to - /// allocate full byte for it. Instead, it is packed with some other, say - /// unsigned counter that requires up to 6 bits to encode its valid - /// range of values. The following code defines such field: - /// @code - /// enum class MyEnumType : std::uint8_t - /// { - /// Value1, - /// Value2, - /// Value3, - /// Value4 - /// }; - /// - /// using MyFieldBase = nil::crypto3::marshalling::field_type; - /// using MyField = - /// nil::crypto3::marshalling::types::bitfield< - /// MyFieldBase, - /// std::tuple< - /// nil::crypto3::marshalling::types::enumeration< - /// MyFieldBase, - /// MyEnumType, - /// nil::crypto3::marshalling::option::fixed_bit_length<2> - /// >, - /// nil::crypto3::marshalling::types::integral< - /// MyFieldBase, - /// std::uint8_t, - /// nil::crypto3::marshalling::option::fixed_bit_length<6> - /// > - /// > - /// >; - /// @endcode - /// Note, that bitfield members fields specify their length in bits using - /// nil::crypto3::marshalling::option::fixed_bit_length option. - /// Also note, that all bitfield member's lengths in bits combined create - /// a round number of bytes, i.e all the bits must sum up to 8, 16, 24, 32, ... - /// bits. - /// - /// Refer to @ref sec_field_tutorial_bitfield for tutorial and usage examples. - /// @tparam TFieldBase Base class for this field, expected to be a variant of - /// nil::crypto3::marshalling::field_type. - /// @tparam TMembers All member fields bundled together in - /// std::tuple. - /// @tparam TOptions Zero or more options that modify/refine default behaviour - /// of the field.@n - /// Supported options are: - /// @li @ref nil::crypto3::marshalling::option::contents_validator - All field members may specify - /// their independent validators. The bitfield field considered to - /// be valid if all the field members are valid. This option though, - /// provides an ability to add extra validation logic that can - /// observe value of more than one bitfield member. For example, - /// protocol specifies that if one specific member has value X, than - /// other member is NOT allowed to have value Y. - /// @li @ref nil::crypto3::marshalling::option::contents_refresher - The default refreshing - /// behaviour is to call the @b refresh() member function of every - /// member field. This option provides an ability to set a custom - /// "refreshing" logic. - /// @li @ref nil::crypto3::marshalling::option::has_custom_read - /// @li @ref nil::crypto3::marshalling::option::has_custom_refresh - /// @li @ref nil::crypto3::marshalling::option::empty_serialization - /// @li @ref nil::crypto3::marshalling::option::version_storage - /// @pre TMember is a variant of std::tuple, that contains other fields. - /// @pre Every field member specifies its length in bits using - /// nil::crypto3::marshalling::option::fixed_bit_length option. - /// @extends nil::crypto3::marshalling::field_type - /// @headerfile nil/marshalling/types/bitfield.hpp - /// @see @ref MARSHALLING_FIELD_MEMBERS_ACCESS() - /// @see @ref MARSHALLING_FIELD_MEMBERS_ACCESS_NOTEMPLATE() - template - class bitfield - : private detail::adapt_basic_field_type, TOptions...> { - using base_impl_type - = detail::adapt_basic_field_type, TOptions...>; - - public: - /// @brief endian_type used for serialization. - using endian_type = typename base_impl_type::endian_type; - - /// @brief Version type - using version_type = typename base_impl_type::version_type; - - /// @brief All the options provided to this class bundled into struct. - using parsed_options_type = detail::options_parser; - - /// @brief Tag indicating type of the field - using tag = tag::bitfield; - - /// @brief Value type. - /// @details Same as TMemebers template argument, i.e. it is std::tuple - /// of all the member fields. - using value_type = typename base_impl_type::value_type; - - /// @brief Default constructor - /// @details All field members are initialised using their default constructors. - bitfield() = default; - - /// @brief Constructor - /// @param[in] val Value of the field to initialise it with. - explicit bitfield(const value_type &val) : base_impl_type(val) { - } - - /// @brief Constructor - /// @param[in] val Value of the field to initialise it with. - explicit bitfield(value_type &&val) : base_impl_type(std::move(val)) { - } - - /// @brief Retrieve number of bits specified member field consumes. - /// @tparam TIdx Index of the member field. - /// @return Number of bits, specified with nil::crypto3::marshalling::option::fixed_bit_length option - /// used with the requested member. - template - static constexpr std::size_t member_bit_length() { - return base_impl_type::template member_bit_length(); - } - - /// @brief Get access to the stored tuple of fields. - /// @return Const reference to the underlying stored value. - const value_type &value() const { - return base_impl_type::value(); - } - - /// @brief Get access to the stored tuple of fields. - /// @return Reference to the underlying stored value. - value_type &value() { - return base_impl_type::value(); - } - - /// @brief Get length required to serialise the current field value. - /// @return Number of bytes it will take to serialise the field value. - constexpr std::size_t length() const { - return base_impl_type::length(); - } - - /// @brief Get minimal length that is required to serialise field of this type. - /// @return Minimal number of bytes required serialise the field value. - static constexpr std::size_t min_length() { - return base_impl_type::min_length(); - } - - /// @brief Get maximal length that is required to serialise field of this type. - /// @return Maximal number of bytes required serialise the field value. - static constexpr std::size_t max_length() { - return base_impl_type::max_length(); - } - - /// @brief Read field value from input data sequence - /// @param[in, out] iter Iterator to read the data. - /// @param[in] size Number of bytes available for reading. - /// @return Status of read operation. - /// @post Iterator is advanced. - template - status_type read(TIter &iter, std::size_t size) { - return base_impl_type::read(iter, size); - } - - /// @brief Read field value from input data sequence without error check and status report. - /// @details Similar to @ref read(), but doesn't perform any correctness - /// checks and doesn't report any failures. - /// @param[in, out] iter Iterator to read the data. - /// @post Iterator is advanced. - template - void read_no_status(TIter &iter) { - base_impl_type::read_no_status(iter); - } - - /// @brief Write current field value to output data sequence - /// @param[in, out] iter Iterator to write the data. - /// @param[in] size Maximal number of bytes that can be written. - /// @return Status of write operation. - /// @post Iterator is advanced. - template - status_type write(TIter &iter, std::size_t size) const { - return base_impl_type::write(iter, size); - } - - /// @brief Write current field value to output data sequence without error check and status report. - /// @details Similar to @ref write(), but doesn't perform any correctness - /// checks and doesn't report any failures. - /// @param[in, out] iter Iterator to write the data. - /// @post Iterator is advanced. - template - void write_no_status(TIter &iter) const { - base_impl_type::write_no_status(iter); - } - - /// @brief Check validity of the field value. - bool valid() const { - return base_impl_type::valid(); - } - - /// @brief Refresh the field's contents - /// @details Calls refresh() member function on every member field, will - /// return @b true if any of the calls returns @b true. - bool refresh() { - return base_impl_type::refresh(); - } - - /// @brief Compile time check if this class is version dependent - static constexpr bool is_version_dependent() { - return parsed_options_type::has_custom_version_update || base_impl_type::is_version_dependent(); - } - - /// @brief Get version of the field. - /// @details Exists only if @ref nil::crypto3::marshalling::option::version_storage option has been provided. - version_type get_version() const { - return base_impl_type::get_version(); - } - - /// @brief Default implementation of version update. - /// @return @b true in case the field contents have changed, @b false otherwise - bool set_version(version_type version) { - return base_impl_type::set_version(version); - } - - protected: - using base_impl_type::read_data; - using base_impl_type::write_data; - - private: - static_assert(!parsed_options_type::has_sequence_fixed_size_use_fixed_size_storage, - "nil::crypto3::marshalling::option::SequenceFixedSizeUseFixedSizeStorage option is not applicable " - "to bitfield field"); - static_assert( - !parsed_options_type::has_sequence_size_field_prefix, - "nil::crypto3::marshalling::option::sequence_size_field_prefix option is not applicable to bitfield field"); - static_assert( - !parsed_options_type::has_fixed_size_storage, - "nil::crypto3::marshalling::option::fixed_size_storage option is not applicable to bitfield field"); - static_assert( - !parsed_options_type::has_custom_storage_type, - "nil::crypto3::marshalling::option::custom_storage_type option is not applicable to bitfield field"); - static_assert(!parsed_options_type::has_orig_data_view, - "nil::crypto3::marshalling::option::orig_data_view option is not applicable to bitfield field"); - }; - - /// @brief Equality comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return true in case fields are equal, false otherwise. - /// @related bitfield - template - bool operator==(const bitfield &field1, - const bitfield &field2) { - return field1.value() == field2.value(); - } - - /// @brief Non-equality comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return true in case fields are NOT equal, false otherwise. - /// @related bitfield - template - bool operator!=(const bitfield &field1, - const bitfield &field2) { - return field1.value() != field2.value(); - } - - /// @brief Equivalence comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return true in case value of the first field is lower than than the value of the second. - /// @related bitfield - template - bool operator<(const bitfield &field1, - const bitfield &field2) { - return field1.value() < field2.value(); - } - - /// @brief Upcast type of the field definition to its parent nil::crypto3::marshalling::types::bitfield type - /// in order to have access to its internal types. - /// @related nil::crypto3::marshalling::types::bitfield - template - inline bitfield & - to_field_base(bitfield &field) { - return field; - } - - /// @brief Upcast type of the field definition to its parent nil::crypto3::marshalling::types::bitfield type - /// in order to have access to its internal types. - /// @related nil::crypto3::marshalling::types::bitfield - template - inline const bitfield & - to_field_base(const bitfield &field) { - return field; - } - - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_BITFIELD_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitfield/basic_type.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitfield/basic_type.hpp deleted file mode 100644 index 8b19ecfc00..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitfield/basic_type.hpp +++ /dev/null @@ -1,356 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef MARSHALLING_BASIC_BITFIELD_HPP -#define MARSHALLING_BASIC_BITFIELD_HPP - -#include -#include - -#include - -// #include -//#include -#include -#include -#include - -#include -#include -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - namespace detail { - - template - class basic_bitfield : public TFieldBase { - using base_impl_type = TFieldBase; - - static_assert(marshalling::detail::is_tuple::value, - "TMembers is expected to be a tuple of BitfieldMember<...>"); - - static_assert(1U < std::tuple_size::value, - "Number of members is expected to be at least 2."); - - static const std::size_t total_bits = detail::calc_bit_length(); - static_assert((total_bits % std::numeric_limits::digits) == 0, - "Wrong number of total bits"); - - static const std::size_t length_ = total_bits / std::numeric_limits::digits; - static_assert(0U < length_, "Serialised length is expected to be greater than 0"); - using serialized_type = typename processing::size_to_type::type; - - using fixed_integral_type = types::integral>; - - using simple_integral_type = types::integral; - - using integral_type = typename std::conditional<((length_ & (length_ - 1)) == 0), - simple_integral_type, - fixed_integral_type>::type; - - public: - using endian_type = typename base_impl_type::endian_type; - using version_type = typename base_impl_type::version_type; - using value_type = TMembers; - - basic_bitfield() = default; - - explicit basic_bitfield(const value_type &val) : members_(val) { - } - - explicit basic_bitfield(value_type &&val) : members_(std::move(val)) { - } - - const value_type &value() const { - return members_; - } - - value_type &value() { - return members_; - } - - static constexpr std::size_t length() { - return length_; - } - - static constexpr std::size_t min_length() { - return length(); - } - - static constexpr std::size_t max_length() { - return length(); - } - - template - status_type read(TIter &iter, std::size_t size) { - if (size < length()) { - return status_type::not_enough_data; - } - - auto serValue = base_impl_type::template read_data(iter); - status_type es = status_type::success; - processing::tuple_for_each_with_template_param_idx(members_, - read_helper(serValue, es)); - return es; - } - - template - void read_no_status(TIter &iter) { - auto serValue = base_impl_type::template read_data(iter); - processing::tuple_for_each_with_template_param_idx( - members_, read_no_status_helper(serValue)); - } - - template - status_type write(TIter &iter, std::size_t size) const { - if (size < length()) { - return status_type::buffer_overflow; - } - - serialized_type serValue = 0; - status_type es = status_type::success; - processing::tuple_for_each_with_template_param_idx( - members_, write_helper(serValue, es)); - if (es == status_type::success) { - processing::write_data(serValue, iter, endian_type()); - } - return es; - } - - template - void write_no_status(TIter &iter) const { - serialized_type serValue = 0; - processing::tuple_for_each_with_template_param_idx( - members_, write_no_status_helper(serValue)); - processing::write_data(serValue, iter, endian_type()); - } - - constexpr bool valid() const { - return processing::tuple_accumulate(members_, true, valid_helper()); - } - - bool refresh() { - return processing::tuple_accumulate(members_, false, refresh_helper()); - } - - template - static constexpr std::size_t member_bit_length() { - static_assert(TIdx < std::tuple_size::value, "Index exceeds number of fields"); - - using field_type = typename std::tuple_element::type; - return detail::bitfield_member_length_retriever::value; - } - - static constexpr bool is_version_dependent() { - return common_funcs::are_members_version_dependent(); - } - - bool set_version(version_type version) { - return common_funcs::set_version_for_members(value(), version); - } - - private: - class read_helper { - public: - read_helper(serialized_type val, status_type &es) : value_(val), es_(es) { - } - - template - void operator()(TFieldParam &&field) { - if (es_ != status_type::success) { - return; - } - - using field_type = typename std::decay::type; - static const auto Pos = detail::get_member_shift_pos(); - static const auto Mask = (static_cast(1) - << detail::bitfield_member_length_retriever::value) - - 1; - - auto fieldSerValue = static_cast((value_ >> Pos) & Mask); - - static_assert(field_type::min_length() == field_type::max_length(), - "basic_bitfield doesn't support members with variable length"); - - static const std::size_t max_length = field_type::max_length(); - std::uint8_t buf[max_length]; - auto *writeIter = &buf[0]; - using FieldEndian = typename field_type::endian_type; - processing::write_data( - fieldSerValue, writeIter, FieldEndian()); - - const auto *readIter = &buf[0]; - es_ = field.read(readIter, max_length); - } - - private: - serialized_type value_; - status_type &es_; - }; - - class read_no_status_helper { - public: - read_no_status_helper(serialized_type val) : value_(val) { - } - - template - void operator()(TFieldParam &&field) { - using field_type = typename std::decay::type; - using FieldOptions = typename field_type::parsed_options_type; - static const auto Pos = detail::get_member_shift_pos(); - static const auto Mask - = (static_cast(1) << FieldOptions::fixed_bit_length) - 1; - - auto fieldSerValue = static_cast((value_ >> Pos) & Mask); - - static_assert(field_type::min_length() == field_type::max_length(), - "basic_bitfield doesn't support members with variable length"); - - static const std::size_t max_length = field_type::max_length(); - std::uint8_t buf[max_length]; - auto *writeIter = &buf[0]; - using FieldEndian = typename field_type::endian_type; - processing::write_data( - fieldSerValue, writeIter, FieldEndian()); - - const auto *readIter = &buf[0]; - field.read_no_status(readIter); - } - - private: - serialized_type value_; - }; - - class write_helper { - public: - write_helper(serialized_type &val, status_type &es) : value_(val), es_(es) { - } - - template - void operator()(TFieldParam &&field) { - if (es_ != status_type::success) { - return; - } - - using field_type = typename std::decay::type; - - static_assert(field_type::min_length() == field_type::max_length(), - "basic_bitfield supports fixed length members only."); - - static const std::size_t max_length = field_type::max_length(); - std::uint8_t buf[max_length]; - auto *writeIter = &buf[0]; - es_ = field.write(writeIter, max_length); - if (es_ != status_type::success) { - return; - } - - using FieldEndian = typename field_type::endian_type; - const auto *readIter = &buf[0]; - auto fieldSerValue = processing::read_data( - readIter, FieldEndian()); - - static const auto Pos = detail::get_member_shift_pos(); - static const auto Mask = (static_cast(1) - << detail::bitfield_member_length_retriever::value) - - 1; - - static const auto ClearMask = ~(Mask << Pos); - - auto valueMask = (static_cast(fieldSerValue) & Mask) << Pos; - - value_ &= ClearMask; - value_ |= valueMask; - } - - private: - serialized_type &value_; - status_type &es_; - }; - - class write_no_status_helper { - public: - write_no_status_helper(serialized_type &val) : value_(val) { - } - - template - void operator()(TFieldParam &&field) { - - using field_type = typename std::decay::type; - - static_assert(field_type::min_length() == field_type::max_length(), - "basic_bitfield supports fixed length members only."); - - static const std::size_t max_length = field_type::max_length(); - std::uint8_t buf[max_length]; - auto *writeIter = &buf[0]; - field.write_no_status(writeIter); - - using FieldEndian = typename field_type::endian_type; - const auto *readIter = &buf[0]; - auto fieldSerValue = processing::read_data( - readIter, FieldEndian()); - - using FieldOptions = typename field_type::parsed_options_type; - static const auto Pos = detail::get_member_shift_pos(); - static const auto Mask - = (static_cast(1) << FieldOptions::fixed_bit_length) - 1; - - static const auto ClearMask = ~(Mask << Pos); - - auto valueMask = (static_cast(fieldSerValue) & Mask) << Pos; - - value_ &= ClearMask; - value_ |= valueMask; - } - - private: - serialized_type &value_; - }; - - struct valid_helper { - template - bool operator()(bool soFar, const TFieldParam &field) { - return soFar && field.valid(); - } - }; - - struct refresh_helper { - template - bool operator()(bool soFar, TFieldParam &field) { - return field.refresh() || soFar; - } - }; - - value_type members_; - }; - - } // namespace detail - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_BASIC_BITFIELD_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitfield/type_traits.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitfield/type_traits.hpp deleted file mode 100644 index 1f136ac757..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitfield/type_traits.hpp +++ /dev/null @@ -1,115 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef MARSHALLING_BASIC_BITFIELD_TYPE_TRAITS_HPP -#define MARSHALLING_BASIC_BITFIELD_TYPE_TRAITS_HPP - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - namespace detail { - - template - struct bitfield_member_length_retrieve_helper; - - template - struct bitfield_member_length_retrieve_helper { - static const std::size_t value = TField::parsed_options_type::fixed_bit_length; - }; - - template - struct bitfield_member_length_retrieve_helper { - static const std::size_t value = std::numeric_limits::digits; - }; - - template - struct bitfield_member_length_retriever { - static const std::size_t value = bitfield_member_length_retrieve_helper< - TField, - TField::parsed_options_type::has_fixed_bit_length_limit>::value; - }; - - template - class bitfield_bit_length_calc_helper { - static const std::size_t Idx = std::tuple_size::value - TRem; - using field_type = typename std::tuple_element::type; - - public: - static const std::size_t value = bitfield_bit_length_calc_helper::value - + bitfield_member_length_retriever::value; - }; - - template - class bitfield_bit_length_calc_helper<0, TMembers> { - public: - static const std::size_t value = 0; - }; - - template - constexpr std::size_t calc_bit_length() { - return bitfield_bit_length_calc_helper::value, TMembers>::value; - } - - template - struct bitfield_pos_retrieve_helper { - static_assert(TIdx < std::tuple_size::value, "Invalid tuple element"); - using field_type = typename std::tuple_element::type; - - static const std::size_t PrevFieldSize = bitfield_member_length_retriever::value; - - public: - static const std::size_t value - = bitfield_pos_retrieve_helper::value + PrevFieldSize; - }; - - template - struct bitfield_pos_retrieve_helper<0, TMembers> { - public: - static const std::size_t value = 0; - }; - - template - constexpr std::size_t get_member_shift_pos() { - return bitfield_pos_retrieve_helper::value; - } - - } // namespace detail - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_BASIC_BITFIELD_TYPE_TRAITS_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitmask_value/behaviour.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitmask_value/behaviour.hpp deleted file mode 100644 index 053c93f66e..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/bitmask_value/behaviour.hpp +++ /dev/null @@ -1,60 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef MARSHALLING_BITMASK_VALUE_BEHAVIOUR_HPP -#define MARSHALLING_BITMASK_VALUE_BEHAVIOUR_HPP - -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - namespace detail { - - template - struct bitmask_undertlying_type; - - template<> - struct bitmask_undertlying_type { - template - using type = - typename processing::size_to_type::type; - }; - - template<> - struct bitmask_undertlying_type { - template - using type = unsigned; - }; - - template - using bitmask_undertlying_type_type = typename bitmask_undertlying_type< - ParsedOptions::has_fixed_length_limit>::template type; - - } // namespace detail - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_BITMASK_VALUE_BEHAVIOUR_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/detail/adapt_basic_field.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/detail/adapt_basic_field.hpp index c6ae3c5890..f650732613 100644 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/detail/adapt_basic_field.hpp +++ b/crypto3/libs/marshalling/core/include/nil/marshalling/types/detail/adapt_basic_field.hpp @@ -45,245 +45,7 @@ namespace nil::crypto3 { + static_cast(T3) + static_cast(T4) + static_cast(T5) + static_cast(T6); }; -#if 0 - template - struct adapt_field_version_storage; -/* - template<> - struct adapt_field_version_storage { - template - using type = types::adapter::version_storage; - }; -*/ - template<> - struct adapt_field_version_storage { - template - using type = TField; - }; - - template - using adapt_field_version_storage_type = - typename adapt_field_version_storage::template type; - - template - struct adapt_field_invalid_by_default; -/* - template<> - struct adapt_field_invalid_by_default { - template - using type = types::adapter::invalid_by_default; - }; -*/ - template<> - struct adapt_field_invalid_by_default { - template - using type = TField; - }; - - template - using adapt_field_invalid_by_default_type = - typename adapt_field_invalid_by_default::template type; - - template - struct adapt_field_custom_value_reader; -/* - template<> - struct adapt_field_custom_value_reader { - template - using type - = types::adapter::custom_value_reader; - }; -*/ - template<> - struct adapt_field_custom_value_reader { - template - using type = TField; - }; - - template - using adapt_field_custom_value_reader_type = - typename adapt_field_custom_value_reader::template type; - - template - struct adapt_field_ser_offset; - -/* - template<> - struct adapt_field_ser_offset { - template - using type = types::adapter::ser_offset; - }; -*/ - template<> - struct adapt_field_ser_offset { - template - using type = TField; - }; - - template - using adapt_field_ser_offset_type = - typename adapt_field_ser_offset::template type; - - template - struct adapt_field_versions_range; -/* - template<> - struct adapt_field_versions_range { - template - using type = types::adapter:: - exists_between_versions; - }; -*/ - template<> - struct adapt_field_versions_range { - template - using type = TField; - }; - - template - using adapt_field_versions_range_type = - typename adapt_field_versions_range::template type; - template - struct adapt_field_fixed_length; -/* - template<> - struct adapt_field_fixed_length { - template - using type = types::adapter:: - fixed_length; - }; -*/ - template<> - struct adapt_field_fixed_length { - template - using type = TField; - }; - - template - using adapt_field_fixed_length_type = - typename adapt_field_fixed_length::template type; - - template - struct adapt_field_fixed_bit_length; -/* - template<> - struct adapt_field_fixed_bit_length { - template - using type = types::adapter::fixed_bit_length; - }; -*/ - template<> - struct adapt_field_fixed_bit_length { - template - using type = TField; - }; - - template - using adapt_field_fixed_bit_length_type = - typename adapt_field_fixed_bit_length::template type; - - template - struct adapt_field_var_length; -/* - template<> - struct adapt_field_var_length { - template - using type = types::adapter:: - var_length; - }; -*/ - template<> - struct adapt_field_var_length { - template - using type = TField; - }; - - template - using adapt_field_var_length_type = - typename adapt_field_var_length::template type; - - template - struct adapt_field_sequence_elem_length_forcing; -/* - template<> - struct adapt_field_sequence_elem_length_forcing { - template - using type = types::adapter::sequence_elem_length_forcing; - }; -*/ - template<> - struct adapt_field_sequence_elem_length_forcing { - template - using type = TField; - }; - - template - using adapt_field_sequence_elem_length_forcing_type = typename adapt_field_sequence_elem_length_forcing< - TOpts::has_sequence_elem_length_forcing>::template type; - - template - struct adapt_field_sequence_size_forcing; -/* - template<> - struct adapt_field_sequence_size_forcing { - template - using type = types::adapter::sequence_size_forcing; - }; -*/ - template<> - struct adapt_field_sequence_size_forcing { - template - using type = TField; - }; - - template - using adapt_field_sequence_size_forcing_type = - typename adapt_field_sequence_size_forcing::template type; - - template - struct adapt_field_sequence_length_forcing; -/* - template<> - struct adapt_field_sequence_length_forcing { - template - using type = types::adapter::sequence_length_forcing; - }; -*/ - template<> - struct adapt_field_sequence_length_forcing { - template - using type = TField; - }; - - template - using adapt_field_sequence_length_forcing_type = typename adapt_field_sequence_length_forcing< - TOpts::has_sequence_length_forcing>::template type; - - template - struct adapt_field_sequence_fixed_size; -/* - template<> - struct adapt_field_sequence_fixed_size { - template - using type - = types::adapter::sequence_fixed_size; - }; -*/ - template<> - struct adapt_field_sequence_fixed_size { - template - using type = TField; - }; - - template - using adapt_field_sequence_fixed_size_type = - typename adapt_field_sequence_fixed_size::template type; -#endif /* This specialization is important */ template struct adapt_field_sequence_size_field_prefix; @@ -304,407 +66,9 @@ namespace nil::crypto3 { using adapt_field_sequence_size_field_prefix_type = typename adapt_field_sequence_size_field_prefix< TOpts::has_sequence_size_field_prefix>::template type; -#if 0 - //-- - template - struct adapt_field_sequence_ser_length_field_prefix; -/* - template<> - struct adapt_field_sequence_ser_length_field_prefix { - template - using type = types::adapter::sequence_ser_length_field_prefix< - typename TOpts::sequence_ser_length_field_prefix, - TOpts::sequence_ser_length_field_read_error_status, - TField>; - }; -*/ - template<> - struct adapt_field_sequence_ser_length_field_prefix { - template - using type = TField; - }; - - template - using adapt_field_sequence_ser_length_field_prefix_type = - typename adapt_field_sequence_ser_length_field_prefix< - TOpts::has_sequence_ser_length_field_prefix>::template type; - - //-- - - template - struct adapt_field_sequence_elem_ser_length_field_prefix; -/* - template<> - struct adapt_field_sequence_elem_ser_length_field_prefix { - template - using type = types::adapter::sequence_elem_ser_length_field_prefix< - typename TOpts::sequence_elem_ser_length_field_prefix, - TOpts::sequence_elem_ser_length_field_read_error_status, - TField>; - }; -*/ - template<> - struct adapt_field_sequence_elem_ser_length_field_prefix { - template - using type = TField; - }; - - template - using adapt_field_sequence_elem_ser_length_field_prefix_type = - typename adapt_field_sequence_elem_ser_length_field_prefix< - TOpts::has_sequence_elem_ser_length_field_prefix>::template type; - - //-- - - template - struct adapt_field_sequence_elem_fixed_ser_length_field_prefix; -/* - template<> - struct adapt_field_sequence_elem_fixed_ser_length_field_prefix { - template - using type = types::adapter::sequence_elem_fixed_ser_length_field_prefix< - typename TOpts::sequence_elem_fixed_ser_length_field_prefix, - TOpts::sequence_elem_fixed_ser_length_field_read_error_status, - TField>; - }; -*/ - template<> - struct adapt_field_sequence_elem_fixed_ser_length_field_prefix { - template - using type = TField; - }; - - template - using adapt_field_sequence_elem_fixed_ser_length_field_prefix_type = - typename adapt_field_sequence_elem_fixed_ser_length_field_prefix< - TOpts::has_sequence_elem_fixed_ser_length_field_prefix>::template type; - - //-- - - template - struct adapt_field_sequence_trailing_field_suffix; -/* - template<> - struct adapt_field_sequence_trailing_field_suffix { - template - using type = types::adapter:: - sequence_trailing_field_suffix; - }; -*/ - template<> - struct adapt_field_sequence_trailing_field_suffix { - template - using type = TField; - }; - - template - using adapt_field_sequence_trailing_field_suffix_type = - typename adapt_field_sequence_trailing_field_suffix< - TOpts::has_sequence_trailing_field_suffix>::template type; - - template - struct adapt_field_sequence_termination_field_suffix; -/* - template<> - struct adapt_field_sequence_termination_field_suffix { - template - using type = types::adapter:: - sequence_termination_field_suffix; - }; -*/ - template<> - struct adapt_field_sequence_termination_field_suffix { - template - using type = TField; - }; - - template - using adapt_field_sequence_termination_field_suffix_type = - typename adapt_field_sequence_termination_field_suffix< - TOpts::has_sequence_termination_field_suffix>::template type; - - template - struct adapt_field_default_value_initializer; -/* - template<> - struct adapt_field_default_value_initializer { - template - using type = types::adapter:: - default_value_initializer; - }; -*/ - template<> - struct adapt_field_default_value_initializer { - template - using type = TField; - }; - - template - using adapt_field_default_value_initializer_type = typename adapt_field_default_value_initializer< - TOpts::has_default_value_initializer>::template type; - - template - struct adapt_field_num_value_multi_range_validator; -/* - template<> - struct adapt_field_num_value_multi_range_validator { - template - using type = types::adapter:: - num_value_multi_range_validator; - }; -*/ - template<> - struct adapt_field_num_value_multi_range_validator { - template - using type = TField; - }; - - template - using adapt_field_num_value_multi_range_validator_type = - typename adapt_field_num_value_multi_range_validator< - TOpts::has_multi_range_validation>::template type; - - template - struct adapt_field_custom_validator; -/* - template<> - struct adapt_field_custom_validator { - template - using type - = types::adapter::custom_validator; - }; -*/ - template<> - struct adapt_field_custom_validator { - template - using type = TField; - }; - - template - using adapt_field_custom_validator_type = - typename adapt_field_custom_validator::template type; - - template - struct adapt_field_custom_refresher; -/* - template<> - struct adapt_field_custom_refresher { - template - using type - = types::adapter::custom_refresher; - }; -*/ - template<> - struct adapt_field_custom_refresher { - template - using type = TField; - }; - - template - using adapt_field_custom_refresher_type = - typename adapt_field_custom_refresher::template type; - - template - struct adapt_field_fail_on_invalid; -/* - template<> - struct adapt_field_fail_on_invalid { - template - using type - = types::adapter::fail_on_invalid; - }; -*/ - template<> - struct adapt_field_fail_on_invalid { - template - using type = TField; - }; - - template - using adapt_field_fail_on_invalid_type = - typename adapt_field_fail_on_invalid::template type; - - template - struct adapt_field_ignore_invalid; -/* - template<> - struct adapt_field_ignore_invalid { - template - using type = types::adapter::ignore_invalid; - }; -*/ - template<> - struct adapt_field_ignore_invalid { - template - using type = TField; - }; - - template - using adapt_field_ignore_invalid_type = - typename adapt_field_ignore_invalid::template type; - - template - struct adapt_field_empty_serialization; -/* - template<> - struct adapt_field_empty_serialization { - template - using type = types::adapter::empty_serialization; - }; -*/ - template<> - struct adapt_field_empty_serialization { - template - using type = TField; - }; - - template - using adapt_field_empty_serialization_type = - typename adapt_field_empty_serialization::template type; -#endif template class adapt_basic_field { using parsed_options_type = options_parser; -#if 0 - - static const bool custom_reader_incompatible = - parsed_options_type::has_ser_offset - || parsed_options_type::has_fixed_length_limit - || parsed_options_type::has_fixed_bit_length_limit - || parsed_options_type::has_var_length_limits - || parsed_options_type::has_sequence_elem_length_forcing - || parsed_options_type::has_sequence_size_forcing - || parsed_options_type::has_sequence_length_forcing - || parsed_options_type::has_sequence_fixed_size - || parsed_options_type::has_sequence_size_field_prefix - || parsed_options_type::has_sequence_ser_length_field_prefix - || parsed_options_type::has_sequence_elem_ser_length_field_prefix - || parsed_options_type::has_sequence_elem_fixed_ser_length_field_prefix - || parsed_options_type::has_sequence_trailing_field_suffix - || parsed_options_type::has_sequence_termination_field_suffix - || parsed_options_type::has_empty_serialization; - - static_assert((!parsed_options_type::has_custom_value_reader) || (!custom_reader_incompatible), - "custom_value_reader option is incompatible with following options: " - "num_value_ser_offset, fixed_length, fixed_bit_length, var_length, " - "has_sequence_elem_length_forcing, " - "sequence_size_forcing_enabled, sequence_length_forcing_enabled, sequence_fixed_size, " - "sequence_size_field_prefix, " - "sequence_ser_length_field_prefix, sequence_elem_ser_length_field_prefix, " - "sequence_elem_fixed_ser_length_field_prefix, sequence_trailing_field_suffix, " - "sequence_termination_field_suffix, empty_serialization"); - - static const bool var_length_incompatible = parsed_options_type::has_fixed_length_limit - || parsed_options_type::has_fixed_bit_length_limit; - - static_assert((!parsed_options_type::has_var_length_limits) || (!var_length_incompatible), - "var_length option is incompatible with fixed_length and fixed_bit_length"); - - static_assert(1U >= fields_options_compatibility_calc< - parsed_options_type::has_sequence_size_field_prefix, - parsed_options_type::has_sequence_ser_length_field_prefix, - parsed_options_type::has_sequence_fixed_size, - parsed_options_type::has_sequence_size_forcing, - parsed_options_type::has_sequence_length_forcing, - parsed_options_type::has_sequence_termination_field_suffix>::value, - "The following options are incompatible, cannot be used together: " - "sequence_size_field_prefix, sequence_ser_length_field_prefix, " - "sequence_fixed_size, sequence_size_forcing_enabled, sequence_length_forcing_enabled, " - "sequence_termination_field_suffix"); - - static_assert(1U >= fields_options_compatibility_calc< - parsed_options_type::has_sequence_elem_ser_length_field_prefix, - parsed_options_type::has_sequence_elem_fixed_ser_length_field_prefix, - parsed_options_type::has_sequence_termination_field_suffix>::value, - "The following options are incompatible, cannot be used together: " - "sequence_elem_ser_length_field_prefix, sequence_elem_fixed_ser_length_field_prefix " - "sequence_termination_field_suffix"); - - static_assert((!parsed_options_type::has_sequence_trailing_field_suffix) - || (!parsed_options_type::has_sequence_termination_field_suffix), - "The following options are incompatible, cannot be used together: " - "sequence_trailing_field_suffix, sequence_termination_field_suffix"); - - static_assert((!parsed_options_type::has_fail_on_invalid) - || (!parsed_options_type::has_ignore_invalid), - "The following options are incompatible, cannot be used together: " - "fail_on_invalid, ignore_invalid"); - - static_assert( - 1U >= fields_options_compatibility_calc::value, - "The following options are incompatible, cannot be used together: " - "custom_storage_type, fixed_size_storage, orig_data_view"); - - static_assert( - (!parsed_options_type::has_sequence_fixed_size_use_fixed_size_storage) - || (parsed_options_type::has_sequence_fixed_size), - "The option SequenceFixedSizeUseFixedSizeStorage cannot be used without sequence_fixed_size."); - - static_assert((!parsed_options_type::has_sequence_fixed_size_use_fixed_size_storage) - || (!parsed_options_type::has_fixed_size_storage), - "The following options are incompatible, cannot be used together: " - "SequenceFixedSizeUseFixedSizeStorage, fixed_size_storage"); -/* - using invalid_by_default_adapted = adapt_field_invalid_by_default_type; - using version_storage_adapted - = adapt_field_version_storage_type; - using custom_reader_adapted - = adapt_field_custom_value_reader_type; - using ser_offset_adapted = adapt_field_ser_offset_type; - using versions_range_adapted - = adapt_field_versions_range_type; - using fixed_length_adapted - = adapt_field_fixed_length_type; - using fixed_bit_length_adapted - = adapt_field_fixed_bit_length_type; - using var_length_adapted - = adapt_field_var_length_type; - using sequence_elem_length_forcing_adapted - = adapt_field_sequence_elem_length_forcing_type; - using sequence_elem_ser_length_field_prefix_adapted - = adapt_field_sequence_elem_ser_length_field_prefix_type; - using sequence_elem_fixed_ser_length_field_prefix_adapted - = adapt_field_sequence_elem_fixed_ser_length_field_prefix_type< - sequence_elem_ser_length_field_prefix_adapted, - parsed_options_type>; - using sequence_size_forcing_adapted - = adapt_field_sequence_size_forcing_type; - using sequence_length_forcing_adapted - = adapt_field_sequence_length_forcing_type; - using sequence_fixed_size_adapted - = adapt_field_sequence_fixed_size_type; - using sequence_ser_length_field_prefix_adapted - = adapt_field_sequence_ser_length_field_prefix_type; - using sequence_trailing_field_suffix_adapted - = adapt_field_sequence_trailing_field_suffix_type; - using sequence_termination_field_suffix_adapted - = adapt_field_sequence_termination_field_suffix_type; - using default_value_initializer_adapted - = adapt_field_default_value_initializer_type; - using num_value_multi_range_validator_adapted - = adapt_field_num_value_multi_range_validator_type; - using custom_validator_adapted - = adapt_field_custom_validator_type; - using custom_refresher_adapted - = adapt_field_custom_refresher_type; - using fail_on_invalid_adapted - = adapt_field_fail_on_invalid_type; - using ignore_invalid_adapted - = adapt_field_ignore_invalid_type; - using empty_serialization_adapted - = adapt_field_empty_serialization_type; -*/ -#endif using sequence_size_field_prefix_adapted = adapt_field_sequence_size_field_prefix_type; public: diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/detail/options_parser.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/detail/options_parser.hpp index a9c41eb085..25f55801b3 100644 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/detail/options_parser.hpp +++ b/crypto3/libs/marshalling/core/include/nil/marshalling/types/detail/options_parser.hpp @@ -27,7 +27,6 @@ #define MARSHALLING_OPTIONS_PARSER_HPP #include -#include #include #include diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/enumeration.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/enumeration.hpp deleted file mode 100644 index 81efe73e77..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/enumeration.hpp +++ /dev/null @@ -1,306 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -/// @file -/// Contains definition of nil::crypto3::marshalling::types::enumeration - -#ifndef MARSHALLING_ENUM_VALUE_HPP -#define MARSHALLING_ENUM_VALUE_HPP - -#include - -#include -#include -#include -#include -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - - /// @brief Enumerator value field. - /// @details Sometimes dealing with enum values is much more convenient that - /// using integral values. nil::crypto3::marshalling::types::enumeration is very similar to - /// nil::crypto3::marshalling::types::integral, but receives underlying enum type in its - /// template parameters instead of integral one. - /// @tparam TFieldBase Base class for this field, expected to be a variant of - /// nil::crypto3::marshalling::field_type. - /// @tparam TEnum Enderlying enum type, can be either unscoped or scoped (enum class). - /// @tparam TOptions Zero or more options that modify/refine default behaviour - /// of the field. If no option is provided, the field's value is serialized as is, - /// where the length of the field is equal to the length of the underlying - /// enum type. For example: - /// @code - /// enum class MyEnum : std::uint16_t - /// { - /// Value1, - /// Value2, - /// Value3 - /// } - /// using MyFieldBase = nil::crypto3::marshalling::field_type; - /// using MyField =nil::crypto3::marshalling::types::enumeration; - /// @endcode - /// The serialized value of the field in the example above will consume - /// 2 bytes, because the underlying type of MyEnum is - /// defined to be std::uint16_t. The value is serialized using big endian - /// notation because base field class receives nil::crypto3::marshalling::option::BigEndian option.@n - /// Supported options are: - /// @li @ref nil::crypto3::marshalling::option::fixed_length - /// @li @ref nil::crypto3::marshalling::option::fixed_bit_length - /// @li @ref nil::crypto3::marshalling::option::var_length - /// @li @ref nil::crypto3::marshalling::num_value_ser_offset - /// @li @ref nil::crypto3::marshalling::option::default_value_initializer or - /// nil::crypto3::marshalling::option::default_num_value. - /// @li @ref nil::crypto3::marshalling::option::contents_validator - /// @li @ref nil::crypto3::marshalling::option::valid_num_value_range, @ref nil::crypto3::marshalling::option::valid_num_value, - /// @ref nil::crypto3::marshalling::option::valid_big_unsigned_num_value_range, @ref - /// nil::crypto3::marshalling::option::valid_big_unsigned_num_value_range - /// @li @ref nil::crypto3::marshalling::option::valid_ranges_clear - /// @li @ref nil::crypto3::marshalling::option::contents_refresher - /// @li @ref nil::crypto3::marshalling::option::has_custom_read - /// @li @ref nil::crypto3::marshalling::option::has_custom_refresh - /// @li @ref nil::crypto3::marshalling::option::fail_on_invalid - /// @li @ref nil::crypto3::marshalling::option::ignore_invalid - /// @li @ref nil::crypto3::marshalling::option::empty_serialization - /// @li @ref nil::crypto3::marshalling::option::invalid_by_default - /// @li @ref nil::crypto3::marshalling::option::version_storage - /// @extends nil::crypto3::marshalling::field_type - /// @headerfile nil/marshalling/types/enumeration.hpp - template - class enumeration - : private detail::adapt_basic_field_type, TOptions...> { - using base_impl_type - = detail::adapt_basic_field_type, TOptions...>; - static_assert(std::is_enum::value, "TEnum must be enum type"); - - public: - /// @brief endian_type used for serialization. - using endian_type = typename base_impl_type::endian_type; - - /// @brief Version type - using version_type = typename base_impl_type::version_type; - - /// @brief All the options provided to this class bundled into struct. - using parsed_options_type = detail::options_parser; - - /// @brief Tag indicating type of the field - using tag = tag::enumeration; - - /// @brief Type of underlying enum value. - /// @details Same as template parameter TEnum to this class. - using value_type = typename base_impl_type::value_type; - - /// @brief Default constructor. - enumeration() = default; - - /// @brief Constructor - explicit enumeration(const value_type &val) : base_impl_type(val) { - } - - /// @brief Copy constructor - enumeration(const enumeration &) = default; - - /// @brief Destructor - ~enumeration() noexcept = default; - - /// @brief Copy assignment - enumeration &operator=(const enumeration &) = default; - - /// @brief Get access to enum value storage. - const value_type &value() const { - return base_impl_type::value(); - } - - /// @brief Get access to enum value storage. - value_type &value() { - return base_impl_type::value(); - } - - /// @brief Get length required to serialise the current field value. - /// @return Number of bytes it will take to serialise the field value. - constexpr std::size_t length() const { - return base_impl_type::length(); - } - - /// @brief Get minimal length that is required to serialise field of this type. - /// @return Minimal number of bytes required serialise the field value. - static constexpr std::size_t min_length() { - return base_impl_type::min_length(); - } - - /// @brief Get maximal length that is required to serialise field of this type. - /// @return Maximal number of bytes required serialise the field value. - static constexpr std::size_t max_length() { - return base_impl_type::max_length(); - } - - /// @brief Read field value from input data sequence - /// @param[in, out] iter Iterator to read the data. - /// @param[in] size Number of bytes available for reading. - /// @return Status of read operation. - /// @post Iterator is advanced. - template - status_type read(TIter &iter, std::size_t size) { - return base_impl_type::read(iter, size); - } - - /// @brief Read field value from input data sequence without error check and status report. - /// @details Similar to @ref read(), but doesn't perform any correctness - /// checks and doesn't report any failures. - /// @param[in, out] iter Iterator to read the data. - /// @post Iterator is advanced. - template - void read_no_status(TIter &iter) { - base_impl_type::read_no_status(iter); - } - - /// @brief Write current field value to output data sequence - /// @param[in, out] iter Iterator to write the data. - /// @param[in] size Maximal number of bytes that can be written. - /// @return Status of write operation. - /// @post Iterator is advanced. - template - status_type write(TIter &iter, std::size_t size) const { - return base_impl_type::write(iter, size); - } - - /// @brief Write current field value to output data sequence without error check and status report. - /// @details Similar to @ref write(), but doesn't perform any correctness - /// checks and doesn't report any failures. - /// @param[in, out] iter Iterator to write the data. - /// @post Iterator is advanced. - template - void write_no_status(TIter &iter) const { - base_impl_type::write_no_status(iter); - } - - /// @brief Check validity of the field value. - bool valid() const { - return base_impl_type::valid(); - } - - /// @brief Refresh the field's value - /// @return @b true if the value has been updated, @b false otherwise - bool refresh() { - return base_impl_type::refresh(); - } - - /// @brief Compile time check if this class is version dependent - static constexpr bool is_version_dependent() { - return parsed_options_type::has_custom_version_update || base_impl_type::is_version_dependent(); - } - - /// @brief Get version of the field. - /// @details Exists only if @ref nil::crypto3::marshalling::option::version_storage option has been provided. - version_type get_version() const { - return base_impl_type::get_version(); - } - - /// @brief Default implementation of version update. - /// @return @b true in case the field contents have changed, @b false otherwise - bool set_version(version_type version) { - return base_impl_type::set_version(version); - } - - protected: - using base_impl_type::read_data; - using base_impl_type::write_data; - - private: - static_assert( - !parsed_options_type::has_sequence_fixed_size_use_fixed_size_storage, - "nil::crypto3::marshalling::option::SequenceFixedSizeUseFixedSizeStorage option is not applicable to " - "enumeration field"); - static_assert(!parsed_options_type::has_sequence_size_field_prefix, - "nil::crypto3::marshalling::option::sequence_size_field_prefix option is not applicable to " - "enumeration field"); - static_assert( - !parsed_options_type::has_fixed_size_storage, - "nil::crypto3::marshalling::option::fixed_size_storage option is not applicable to enumeration field"); - static_assert( - !parsed_options_type::has_custom_storage_type, - "nil::crypto3::marshalling::option::custom_storage_type option is not applicable to enumeration field"); - static_assert(!parsed_options_type::has_orig_data_view, - "nil::crypto3::marshalling::option::orig_data_view option is not applicable to enumeration field"); - }; - - // Implementation - - /// @brief Equality comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return true in case fields are equal, false otherwise. - /// @related enumeration - template - bool operator==(const enumeration &field1, - const enumeration &field2) { - return field1.value() == field2.value(); - } - - /// @brief Non-equality comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return true in case fields are NOT equal, false otherwise. - /// @related enumeration - template - bool operator!=(const enumeration &field1, - const enumeration &field2) { - return field1.value() != field2.value(); - } - - /// @brief Equivalence comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return true in case value of the first field is lower than than the value of the second. - /// @related enumeration - template - bool operator<(const enumeration &field1, - const enumeration &field2) { - return field1.value() < field2.value(); - } - - /// @brief Upcast type of the field definition to its parent nil::crypto3::marshalling::types::enumeration type - /// in order to have access to its internal types. - /// @related nil::crypto3::marshalling::types::enumeration - template - inline enumeration & - to_field_base(enumeration &field) { - return field; - } - - /// @brief Upcast type of the field definition to its parent nil::crypto3::marshalling::types::enumeration type - /// in order to have access to its internal types. - /// @related nil::crypto3::marshalling::types::enumeration - template - inline const enumeration & - to_field_base(const enumeration &field) { - return field; - } - - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_ENUM_VALUE_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/enumeration/basic_type.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/enumeration/basic_type.hpp deleted file mode 100644 index dd64f4601f..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/enumeration/basic_type.hpp +++ /dev/null @@ -1,137 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef MARSHALLING_BASIC_ENUMERATION_HPP -#define MARSHALLING_BASIC_ENUMERATION_HPP - -#include - -#include - -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - namespace detail { - - template - class basic_enumeration : public TFieldBase { - static_assert(std::is_enum::value, "T must be enum"); - - using underlying_type = typename std::underlying_type::type; - - using base_impl_type = TFieldBase; - - using integral_type = basic_integral; - - using integral_value_type = typename integral_type::value_type; - - public: - using value_type = T; - - using serialized_type = typename integral_type::value_type; - - using scaling_ratio_type = typename integral_type::scaling_ratio_type; - - basic_enumeration() = default; - - explicit basic_enumeration(value_type val) : value_(val) { - } - - basic_enumeration(const basic_enumeration &) = default; - - basic_enumeration(basic_enumeration &&) = default; - - ~basic_enumeration() noexcept = default; - - basic_enumeration &operator=(const basic_enumeration &) = default; - - basic_enumeration &operator=(basic_enumeration &&) = default; - - const value_type &value() const { - return value_; - } - - value_type &value() { - return value_; - } - - static constexpr std::size_t length() { - return integral_type::length(); - } - - static constexpr std::size_t min_length() { - return length(); - } - - static constexpr std::size_t max_length() { - return length(); - } - - static constexpr serialized_type to_serialized(value_type val) { - return integral_type::to_serialized(static_cast(val)); - } - - static constexpr value_type from_serialized(serialized_type val) { - return static_cast(integral_type::from_serialized(val)); - } - - template - status_type read(TIter &iter, std::size_t size) { - integral_type intField; - status_type es = intField.read(iter, size); - if (es == status_type::success) { - value_ = static_cast(intField.value()); - } - return es; - } - - template - void read_no_status(TIter &iter) { - integral_type intField; - intField.read_no_status(iter); - value_ = static_cast(intField.value()); - } - - template - status_type write(TIter &iter, std::size_t size) const { - return integral_type(static_cast(value_)).write(iter, size); - } - - template - void write_no_status(TIter &iter) const { - integral_type(static_cast(value_)).write_no_status(iter); - } - - private: - value_type value_; - }; - - } // namespace detail - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_BASIC_ENUMERATION_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/no_value.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/no_value.hpp deleted file mode 100644 index a501d11508..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/no_value.hpp +++ /dev/null @@ -1,226 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef MARSHALLING_NO_VALUE_HPP -#define MARSHALLING_NO_VALUE_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - - /// @brief Dummy field with "do-nothing" read/write operations. - /// @details Can be used with other classes that require field types. - /// @tparam TFieldBase Base class for this field, expected to be a variant of - /// nil::crypto3::marshalling::field_type. - /// @extends nil::crypto3::marshalling::field_type - /// @headerfile nil/marshalling/types/no_value.hpp - template - class no_value : private detail::adapt_basic_field_type> { - using base_impl_type = detail::adapt_basic_field_type>; - - public: - /// @brief endian_type used for serialization. - using endian_type = typename base_impl_type::endian_type; - - /// @brief Version type - using version_type = typename base_impl_type::version_type; - - /// @brief All the options provided to this class bundled into struct. - using parsed_options_type = detail::options_parser<>; - - /// @brief Tag indicating type of the field - using tag = tag::no_value; - - /// @brief Type of underlying value. - /// @details Defined to be "unsigned", not really used - using value_type = typename base_impl_type::value_type; - - /// @brief Default constructor - /// @details Initialises internal value to 0. - no_value() = default; - - /// @brief Constructor - explicit no_value(value_type val) { - base_impl_type::value() = val; - } - - /// @brief Copy constructor - no_value(const no_value &) = default; - - /// @brief Copy assignment - no_value &operator=(const no_value &) = default; - - /// @brief Get access to the value storage. - /// @details Should not really be used. - /// @return Reference to a static value. All the independent get/set - /// operations on the different @ref no_value fields access the same - /// static value. - static value_type &value() { - return base_impl_type::value(); - } - - /// @brief Get length required to serialise the current field value. - /// @return Always 0. - static constexpr std::size_t length() { - return base_impl_type::length(); - } - - /// @brief Get minimal length that is required to serialise field of this type. - /// @return Always 0. - static constexpr std::size_t min_length() { - return base_impl_type::min_length(); - } - - /// @brief Get maximal length that is required to serialise field of this type. - /// @return Always 0. - static constexpr std::size_t max_length() { - return base_impl_type::max_length(); - } - - /// @brief Check validity of the field value. - bool valid() const { - return base_impl_type::valid(); - } - - /// @brief Refresh the field's value - /// @return @b true if the value has been updated, @b false otherwise - bool refresh() { - return base_impl_type::refresh(); - } - - /// @brief Read field value from input data sequence. - /// @details The function does nothing, always reporting success. - /// @param[in, out] iter Iterator to read the data. - /// @param[in] size Number of bytes available for reading. - /// @return Status of read operation. - template - static status_type read(TIter &iter, std::size_t size) { - return base_impl_type::read(iter, size); - } - - /// @brief Read field value from input data sequence without error check and status report. - /// @details Similar to @ref read(), but doesn't perform any correctness - /// checks and doesn't report any failures. - /// @param[in, out] iter Iterator to read the data. - /// @post Iterator is advanced. - template - void read_no_status(TIter &iter) { - base_impl_type::read_no_status(iter); - } - - /// @brief Write current field value to output data sequence - /// @details The function does nothing, always reporting success. - /// @param[in, out] iter Iterator to write the data. - /// @param[in] size Maximal number of bytes that can be written. - /// @return Status of write operation. - template - static status_type write(TIter &iter, std::size_t size) { - return base_impl_type::write(iter, size); - } - - /// @brief Write current field value to output data sequence without error check and status report. - /// @details Similar to @ref write(), but doesn't perform any correctness - /// checks and doesn't report any failures. - /// @param[in, out] iter Iterator to write the data. - /// @post Iterator is advanced. - template - void write_no_status(TIter &iter) const { - base_impl_type::write_no_status(iter); - } - - /// @brief Compile time check if this class is version dependent - static constexpr bool is_version_dependent() { - return parsed_options_type::has_custom_version_update || base_impl_type::is_version_dependent(); - } - - /// @brief Default implementation of version update. - /// @return @b true in case the field contents have changed, @b false otherwise - bool set_version(version_type version) { - return base_impl_type::set_version(version); - } - - protected: - using base_impl_type::read_data; - using base_impl_type::write_data; - - private: -#ifdef _MSC_VER - // VS compiler has problems having 0 size objects in tuple. - int dummy_ = 0; -#endif - }; - - /// @brief Equality comparison operator. - /// @details To @ref no_value fields are always equal. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return Always true. - /// @related no_value - template - bool operator==(const no_value &field1, const no_value &field2) { - static_cast(field1); - static_cast(field2); - return true; - } - - /// @brief Non-equality comparison operator. - /// @details To @ref no_value fields are always equal. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return Always false. - /// @related no_value - template - bool operator!=(const no_value &field1, const no_value &field2) { - return !(field1 == field2); - } - - /// @brief Equivalence comparison operator. - /// @details To @ref no_value fields are always equal. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return Always false. - /// @related no_value - template - bool operator<(const no_value &field1, const no_value &field2) { - static_cast(field1); - static_cast(field2); - return false; - } - - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_NO_VALUE_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/no_value/basic_type.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/no_value/basic_type.hpp deleted file mode 100644 index 6c9bfe7ef0..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/no_value/basic_type.hpp +++ /dev/null @@ -1,112 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef MARSHALLING_BASIC_NO_VALUE_HPP -#define MARSHALLING_BASIC_NO_VALUE_HPP - -#include - -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - namespace detail { - - template - class basic_no_value : public TFieldBase { - using base_impl_type = TFieldBase; - - public: - using value_type = unsigned; - using serialized_type = value_type; - - basic_no_value() = default; - - basic_no_value(const basic_no_value &) = default; - - basic_no_value(basic_no_value &&) = default; - - ~basic_no_value() noexcept = default; - - basic_no_value &operator=(const basic_no_value &) = default; - - basic_no_value &operator=(basic_no_value &&) = default; - - static value_type &value() { - static value_type value = value_type(); - return value; - } - - static constexpr std::size_t length() { - return 0U; - } - - static constexpr std::size_t min_length() { - return length(); - } - - static constexpr std::size_t max_length() { - return length(); - } - - static constexpr serialized_type to_serialized(value_type val) { - return static_cast(val); - } - - static constexpr value_type from_serialized(serialized_type val) { - return static_cast(val); - } - - template - static status_type read(TIter &iter, std::size_t size) { - static_cast(iter); - static_cast(size); - return status_type::success; - } - - template - static void read_no_status(TIter &iter) { - static_cast(iter); - } - - template - static status_type write(TIter &iter, std::size_t size) { - static_cast(iter); - static_cast(size); - return status_type::success; - } - - template - static void write_no_status(TIter &iter) { - static_cast(iter); - } - }; - - } // namespace detail - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_BASIC_NO_VALUE_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/optional.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/optional.hpp deleted file mode 100644 index d0cea911da..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/optional.hpp +++ /dev/null @@ -1,406 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef MARSHALLING_OPTIONAL_HPP -#define MARSHALLING_OPTIONAL_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - - /// @brief Adaptor class to any other field, that makes the field optional. - /// @details When field is optional, it may either exist or not. The behaviour - /// of length(), read() and write() operations depends on the current field's mode. - /// @tparam TField Proper type of the field that needs to be optional. - /// @tparam TOptions Zero or more options that modify/refine default behaviour - /// of the field.@n - /// Supported options are: - /// @li @ref nil::crypto3::marshalling::option::default_value_initializer, @ref - /// nil::crypto3::marshalling::option::default_optional_mode, - /// @ref nil::crypto3::marshalling::option::optional_missing_by_default, or @ref - /// nil::crypto3::marshalling::option::optional_exists_by_default. - /// @li @ref nil::crypto3::marshalling::option::contents_validator. - /// @li @ref nil::crypto3::marshalling::option::contents_refresher - /// @li @ref nil::crypto3::marshalling::option::has_custom_read - /// @li @ref nil::crypto3::marshalling::option::has_custom_refresh - /// @li @ref nil::crypto3::marshalling::option::version_storage - /// @extends nil::crypto3::marshalling::field_type - /// @headerfile nil/marshalling/types/optional.hpp - template - class optional : private detail::adapt_basic_field_type, TOptions...> { - using base_impl_type = detail::adapt_basic_field_type, TOptions...>; - - public: - /// @brief endian_type used for serialization. - using endian_type = typename base_impl_type::endian_type; - - /// @brief Version type - using version_type = typename base_impl_type::version_type; - - /// @brief All the options provided to this class bundled into struct. - using parsed_options_type = detail::options_parser; - - /// @brief Tag indicating type of the field - using tag = tag::optional; - - /// @brief Type of the field. - using field_type = TField; - - /// @brief Value type of this field, equal to @ref field_type - using value_type = field_type; - - /// @brief Mode of the field. - /// @see optional_mode - using Mode = optional_mode; - - /// @brief Default constructor - /// @details The mode it is created in is optional_mode::tentative. - optional() = default; - - /// @brief Construct the field. - /// @param[in] fieldSrc field_type to be copied from during construction. - explicit optional(const field_type &fieldSrc) : base_impl_type(fieldSrc) { - } - - /// @brief Construct the field. - /// @param[in] fieldSrc field_type to be moved from during construction. - explicit optional(field_type &&fieldSrc) : base_impl_type(std::move(fieldSrc)) { - } - - /// @brief Copy constructor - optional(const optional &) = default; - - /// @brief Move constructor - optional(optional &&) = default; - - /// @brief Destructor - ~optional() noexcept = default; - - /// @brief Copy assignment - optional &operator=(const optional &) = default; - - /// @brief Move assignment - optional &operator=(optional &&) = default; - - /// @brief Check whether mode is equivalent to Mode::tentative - /// @details Convenience wrapper for get_mode(), equivalent to - /// @code return get_mode() == Mode::tentative; @endcode - bool is_tentative() const { - return base_impl_type::get_mode() == Mode::tentative; - } - - /// @brief Set mode to Mode::tentative - /// @details Convenience wrapper for set_mode(), equivalent to - /// @code set_mode(Mode::tentative); @endcode - void set_tentative() { - base_impl_type::set_mode(Mode::tentative); - } - - /// @brief Check whether mode is equivalent to Mode::missing - /// @details Convenience wrapper for get_mode(), equivalent to - /// @code return get_mode() == Mode::missing; @endcode - bool is_missing() const { - return base_impl_type::get_mode() == Mode::missing; - } - - /// @brief Set mode to Mode::missing - /// @details Convenience wrapper for set_mode(), equivalent to - /// @code set_mode(Mode::missing); @endcode - void set_missing() { - base_impl_type::set_mode(Mode::missing); - } - - /// @brief Check whether mode is equivalent to Mode::exists - /// @details Convenience wrapper for get_mode(), equivalent to - /// @code return get_mode() == Mode::exists; @endcode - bool does_exist() const { - return base_impl_type::get_mode() == Mode::exists; - } - - /// @brief Set mode to Mode::exists - /// @details Convenience wrapper for set_mode(), equivalent to - /// @code set_mode(Mode::exists); @endcode - void set_exists() { - base_impl_type::set_mode(Mode::exists); - } - - /// @brief Get an access to the wrapped field object - field_type &field() { - return base_impl_type::field(); - } - - /// @brief Get an access to the wrapped field object - const field_type &field() const { - return base_impl_type::field(); - } - - /// @brief Get an access to the wrapped field object - value_type &value() { - return base_impl_type::value(); - } - - /// @brief Get an access to the wrapped field object - const value_type &value() const { - return base_impl_type::value(); - } - - /// @brief Get current optional mode - Mode get_mode() const { - return base_impl_type::get_mode(); - } - - /// @brief Get optional mode - void set_mode(Mode val) { - base_impl_type::set_mode(val); - } - - /// @brief Get length required to serialise the current field value. - /// @return If current mode is optional_mode::exists, then the function - /// returns whatever length() member function of the wrapped field - /// returns. Otherwise (for both optional_mode::missing and - /// optional_mode::tentative) 0 is returned. - std::size_t length() const { - return base_impl_type::length(); - } - - /// @brief Get minimal length that is required to serialise field of this type. - /// @return Same as field_type::min_length() - static constexpr std::size_t min_length() { - return base_impl_type::min_length(); - } - - /// @brief Get maximal length that is required to serialise field of this type. - /// @return Same as field_type::max_length() - static constexpr std::size_t max_length() { - return base_impl_type::max_length(); - } - - /// @brief Check validity of the field value. - /// @return If field is marked to be missing (mode is optional_mode::missing), - /// "true" is returned, otherwise valid() member function of the wrapped - /// field is called. - bool valid() const { - return base_impl_type::valid(); - } - - /// @brief Refresh the field's value - /// @details Will invoke the refresh() member function of the contained - /// field, only if it is marked as "exists", otherwise @b false will be - /// returned. - /// @return @b true if the value has been updated, @b false otherwise - bool refresh() { - return base_impl_type::refresh(); - } - - /// @brief Read field value from input data sequence - /// @details If field is marked as missing (mode is optional_mode::missing), - /// function returns nil::crypto3::marshalling::ErrorStatus::Success without advancing iterator.@n - /// If field is marked as existing (mode is optional_mode::exists) the - /// read() member function of the wrapped field object is invoked.@n - /// If field is marked to be tentative (mode is optional_mode::tentative), - /// the call redirected to wrapped field's read() member function if - /// value of the "len" parameter is greater than 0, i.e. there are - /// still bytes available for reading, and field itself is marked as - /// existing.@n Otherwise, field is marked as missing and - /// nil::crypto3::marshalling::ErrorStatus::Success is returned. - /// @param[in, out] iter Iterator to read the data. - /// @param[in] len Number of bytes available for reading. - /// @return Status of read operation. - /// @post Iterator is advanced. - template - status_type read(TIter &iter, std::size_t len) { - return base_impl_type::read(iter, len); - } - - /// @brief Read field value from input data sequence without error check and status report. - /// @details Similar to @ref read(), but doesn't perform any correctness - /// checks and doesn't report any failures. - /// @param[in, out] iter Iterator to read the data. - /// @post Iterator is advanced. - template - void read_no_status(TIter &iter) { - base_impl_type::read_no_status(iter); - } - - /// @brief Write current field value to output data sequence - /// @details If field is marked as missing (mode is optional_mode::missing), - /// function returns nil::crypto3::marshalling::ErrorStatus::Success without advancing iterator.@n - /// If field is marked as existing (mode is optional_mode::exists) the - /// write() member function of the wrapped field object is invoked.@n - /// If field is marked to be tentative (mode is optional_mode::tentative), - /// the call redirected to wrapped field's write() member function if - /// value of the "len" parameter is greater than 0, i.e. there is - /// space available for writing.@n Otherwise, nil::crypto3::marshalling::ErrorStatus::Success - /// is returned. - /// @param[in, out] iter Iterator to write the data. - /// @param[in] len Maximal number of bytes that can be written. - /// @return Status of write operation. - /// @post Iterator is advanced. - template - status_type write(TIter &iter, std::size_t len) const { - return base_impl_type::write(iter, len); - } - - /// @brief Write current field value to output data sequence without error check and status report. - /// @details Similar to @ref write(), but doesn't perform any correctness - /// checks and doesn't report any failures. - /// @param[in, out] iter Iterator to write the data. - /// @post Iterator is advanced. - template - void write_no_status(TIter &iter) const { - base_impl_type::write_no_status(iter); - } - - /// @brief Compile time check if this class is version dependent - static constexpr bool is_version_dependent() { - return parsed_options_type::has_custom_version_update || base_impl_type::is_version_dependent(); - } - - /// @brief Get version of the field. - /// @details Exists only if @ref nil::crypto3::marshalling::option::version_storage option has been provided. - version_type get_version() const { - return base_impl_type::get_version(); - } - - /// @brief Default implementation of version update. - /// @return @b true in case the field contents have changed, @b false otherwise - bool set_version(version_type version) { - return base_impl_type::set_version(version); - } - - protected: - using base_impl_type::read_data; - using base_impl_type::write_data; - - private: - static_assert( - !parsed_options_type::has_invalid_by_default, - "nil::crypto3::marshalling::option::invalid_by_default option is not applicable to optional field"); - }; - - /// @brief Equality comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return Result of the equality comparison of the contained fields. - /// @related optional - template - bool operator==(const optional &field1, const optional &field2) { - if (field1.get_mode() != field2.get_mode()) { - return false; - } - - if (field1.is_missing()) { - return true; - } - - return field1.field() == field2.field(); - } - - /// @brief Non-equality comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return Result of the non-equality comparison of the contained fields. - /// @related optional - template - bool operator!=(const optional &field1, const optional &field2) { - return !(field1 == field2); - } - - /// @brief Equivalence comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return Result of the equivalence comparison of the contained fields. - /// @related optional - template - bool operator<(const optional &field1, const optional &field2) { - if (field1.is_missing()) { - return !field2.is_missing(); - } - - if (field2.is_missing()) { - return false; - } - - return false; - } - - /// @brief Equivalence comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return Result of the equivalence comparison of the contained fields. - /// @related optional - template - bool operator>(const optional &field1, const optional &field2) { - return (field2 < field1); - } - - /// @brief Equivalence comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return Result of the equivalence comparison of the contained fields. - /// @related optional - template - bool operator<=(const optional &field1, const optional &field2) { - return (field1 < field2) || (field1 == field2); - } - - /// @brief Equivalence comparison operator. - /// @param[in] field1 First field. - /// @param[in] field2 Second field. - /// @return Result of the equivalence comparison of the contained fields. - /// @related optional - template - bool operator>=(const optional &field1, const optional &field2) { - return field2 <= field1; - } - - /// @brief Upcast type of the field definition to its parent nil::crypto3::marshalling::types::optional type - /// in order to have access to its internal types. - /// @related nil::crypto3::marshalling::types::optional - template - inline optional &to_field_base(optional &field) { - return field; - } - - /// @brief Upcast type of the field definition to its parent nil::crypto3::marshalling::types::optional type - /// in order to have access to its internal types. - /// @related nil::crypto3::marshalling::types::optional - template - inline const optional &to_field_base(const optional &field) { - return field; - } - - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_OPTIONAL_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/optional/basic_type.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/optional/basic_type.hpp deleted file mode 100644 index f1f7215193..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/optional/basic_type.hpp +++ /dev/null @@ -1,197 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef MARSHALLING_BASIC_OPTIONAL_HPP -#define MARSHALLING_BASIC_OPTIONAL_HPP - -#include -#include -#include -#include - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - namespace detail { - - template - class basic_optional : public nil::crypto3::marshalling::field_type< - nil::crypto3::marshalling::option::endian, - nil::crypto3::marshalling::option::version_type> { - using base_impl_type = nil::crypto3::marshalling::field_type< - nil::crypto3::marshalling::option::endian, - nil::crypto3::marshalling::option::version_type>; - - public: - using field_type = TField; - using value_type = TField; - using mode_type = types::optional_mode; - using version_type = typename base_impl_type::version_type; - - basic_optional() = default; - - explicit basic_optional(const field_type &fieldSrc, mode_type mode = mode_type::tentative) : - field_(fieldSrc), mode_(mode) { - } - - explicit basic_optional(field_type &&fieldSrc, mode_type mode = mode_type::tentative) : - field_(std::move(fieldSrc)), mode_(mode) { - } - - basic_optional(const basic_optional &) = default; - - basic_optional(basic_optional &&) = default; - - ~basic_optional() noexcept = default; - - basic_optional &operator=(const basic_optional &) = default; - - basic_optional &operator=(basic_optional &&) = default; - - field_type &field() { - return field_; - } - - const field_type &field() const { - return field_; - } - - value_type &value() { - return field(); - } - - const value_type &value() const { - return field(); - } - - mode_type get_mode() const { - return mode_; - } - - void set_mode(mode_type val) { - MARSHALLING_ASSERT(val < mode_type::modes_amount); - mode_ = val; - } - - std::size_t length() const { - if (mode_ != mode_type::exists) { - return 0U; - } - - return field_.length(); - } - - static constexpr std::size_t min_length() { - return 0U; - } - - static constexpr std::size_t max_length() { - return field_type::max_length(); - } - - bool valid() const { - if (mode_ == mode_type::missing) { - return true; - } - - return field_.valid(); - } - - bool refresh() { - if (mode_ != mode_type::exists) { - return false; - } - return field_.refresh(); - } - - template - status_type read(TIter &iter, std::size_t len) { - if (mode_ == mode_type::missing) { - return status_type::success; - } - - if ((mode_ == mode_type::tentative) && (0U == len)) { - mode_ = mode_type::missing; - return status_type::success; - } - - status_type es = field_.read(iter, len); - if (es == status_type::success) { - mode_ = mode_type::exists; - } - return es; - } - - template - void read_no_status(TIter &iter) { - if (mode_ != mode_type::exists) { - mode_ = mode_type::missing; - return; - } - - mode_ = mode_type::exists; - field_.read_no_status(iter); - } - - template - status_type write(TIter &iter, std::size_t len) const { - if (mode_ == mode_type::missing) { - return status_type::success; - } - - if ((mode_ == mode_type::tentative) && (0U == len)) { - return status_type::success; - } - - return field_.write(iter, len); - } - - template - void write_no_status(TIter &iter) const { - if (mode_ != mode_type::exists) { - return; - } - - field_.write_no_status(iter); - } - - static constexpr bool is_version_dependent() { - return field_type::is_version_dependent(); - } - - bool set_version(version_type version) { - return field_.set_version(static_cast(version)); - } - - private: - field_type field_; - mode_type mode_ = mode_type::tentative; - }; - - } // namespace detail - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_BASIC_OPTIONAL_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/optional_mode.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/optional_mode.hpp deleted file mode 100644 index 5c597f1524..0000000000 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/optional_mode.hpp +++ /dev/null @@ -1,50 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -/// @file nil/marshalling/types/optional_mode.hpp -/// Contains definition of the mode used for nil::crypto3::marshalling::types::optional fields. - -#ifndef MARSHALLING_OPTIONAL_MODE_HPP -#define MARSHALLING_OPTIONAL_MODE_HPP - -namespace nil::crypto3 { - namespace marshalling { - namespace types { - - /// @brief Mode to be used by nil::crypto3::marshalling::types::optional - /// @headerfile nil/marshalling/types/optional_mode.hpp - enum class optional_mode { - tentative, ///< The field existence is tentative, i.e. If there is enough bytes - /// to read the field's value, than field exists, if not - /// then it doesn't exist. - exists, ///< field_type must exist - missing, ///< field_type doesn't exist - modes_amount ///< Number of possible modes, must be last - }; - - } // namespace types - } // namespace marshalling -} // namespace nil -#endif // MARSHALLING_OPTIONAL_MODE_HPP diff --git a/crypto3/libs/marshalling/core/include/nil/marshalling/types/tag.hpp b/crypto3/libs/marshalling/core/include/nil/marshalling/types/tag.hpp index 81cb9660cb..56b3e9d944 100644 --- a/crypto3/libs/marshalling/core/include/nil/marshalling/types/tag.hpp +++ b/crypto3/libs/marshalling/core/include/nil/marshalling/types/tag.hpp @@ -35,26 +35,12 @@ namespace nil::crypto3 { struct array_list { }; - struct bitfield { }; - - struct bitmask { }; - struct bundle { }; - struct enumeration { }; - - struct floating_point { }; - struct integral { }; - struct no_value { }; - - struct optional { }; - struct string { }; - struct variant { }; - } // namespace tag } // namespace types } // namespace marshalling diff --git a/crypto3/libs/marshalling/core/test/interfaces.cpp b/crypto3/libs/marshalling/core/test/interfaces.cpp index ef3593f051..160091d53c 100644 --- a/crypto3/libs/marshalling/core/test/interfaces.cpp +++ b/crypto3/libs/marshalling/core/test/interfaces.cpp @@ -35,13 +35,9 @@ #include #include -#include #include #include -#include -#include #include -#include #include diff --git a/crypto3/libs/marshalling/core/test/pack.cpp b/crypto3/libs/marshalling/core/test/pack.cpp index 5f61eec3e8..deac7bcce7 100644 --- a/crypto3/libs/marshalling/core/test/pack.cpp +++ b/crypto3/libs/marshalling/core/test/pack.cpp @@ -35,13 +35,9 @@ #include #include -#include #include #include -#include -#include #include -#include #include