-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add utility for forward declaring codecs
Add a simple macro which forward declares the full specialization for a `codec<T>`. These forward declarations add a lot of noise while being very similar and C++ doesn't really offer the tools to avoid these.
- Loading branch information
1 parent
2035d9a
commit 260292d
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
// Copyright Henrik Steffen Gaßmann 2021. | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE or copy at | ||
// https://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#pragma once | ||
|
||
#include <dplx/dp/fwd.hpp> | ||
|
||
// NOLINTBEGIN(modernize-macro-to-enum) | ||
// NOLINTBEGIN(cppcoreguidelines-macro-usage) | ||
|
||
#define DPLX_DP_DECLARE_CODEC_SIMPLE(_fq_type) \ | ||
template <> \ | ||
class dplx::dp::codec<_fq_type> \ | ||
{ \ | ||
using value_type = _fq_type; \ | ||
\ | ||
public: \ | ||
static auto size_of(emit_context &ctx, _fq_type const &value) noexcept \ | ||
-> std::uint64_t; \ | ||
static auto encode(emit_context &ctx, _fq_type const &value) noexcept \ | ||
-> result<void>; \ | ||
static auto decode(parse_context &ctx, _fq_type &outValue) noexcept \ | ||
-> result<void>; \ | ||
} | ||
|
||
// NOLINTEND(cppcoreguidelines-macro-usage) | ||
// NOLINTEND(modernize-macro-to-enum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
// Copyright Henrik Steffen Gaßmann 2021. | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE or copy at | ||
// https://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <dplx/dp/macros.hpp> | ||
|
||
namespace dp_tests | ||
{ | ||
|
||
namespace | ||
{ | ||
|
||
class custom_type | ||
{ | ||
}; | ||
|
||
} // namespace | ||
|
||
} // namespace dp_tests | ||
|
||
DPLX_DP_DECLARE_CODEC_SIMPLE(dp_tests::custom_type); |