-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced "prorocol_traits_fwd.hpp" / "prorocol_traits.hpp" headers with some expected values for Binary Log Protocol V4 constants. Introduced 'binsrv::event::reader_context' class that is expected to be used for storing information about the sequence of encountered events as well as data that may affect parsing / analyzing subsequent events in the stream. 'binsrv::event::event' constructor now accepts an reference to an instance of the 'reader_context' class where the information about the most recently encountered format description event is kept. After some bugs were fixed in 'clang-tidy-17', 'bugprone-exception-escape' NOLINT suppressions are no longer needed and were removed.
- Loading branch information
1 parent
19bafd4
commit a385fee
Showing
16 changed files
with
216 additions
and
83 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
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
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
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,28 @@ | ||
#include "binsrv/event/protocol_traits.hpp" | ||
|
||
#include <cstddef> | ||
|
||
#include "binsrv/event/code_type.hpp" | ||
|
||
#include "util/conversion_helpers.hpp" | ||
|
||
namespace binsrv::event { | ||
|
||
[[nodiscard]] std::size_t | ||
get_post_header_length_for_code(const post_header_length_container &storage, | ||
code_type code) noexcept { | ||
static_assert(default_number_of_events == | ||
util::enum_to_index(code_type::delimiter), | ||
"mismatch between number_of_events and code_type enum"); | ||
|
||
// here the very first "unknown" code is not included in the array by the | ||
// spec | ||
const auto index{util::enum_to_index(code)}; | ||
if (index == 0U || index >= default_number_of_events) { | ||
return 0U; | ||
} | ||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) | ||
return static_cast<std::size_t>(storage[index - 1U]); | ||
} | ||
|
||
} // namespace binsrv::event |
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 @@ | ||
#ifndef BINSRV_EVENT_PROTOCOL_TRAITS_HPP | ||
#define BINSRV_EVENT_PROTOCOL_TRAITS_HPP | ||
|
||
#include "binsrv/event/protocol_traits_fwd.hpp" // IWYU pragma: export | ||
|
||
#include <array> | ||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
#include "binsrv/event/code_type_fwd.hpp" | ||
|
||
namespace binsrv::event { | ||
|
||
// we do not store length for the first element which is the "unknown" event | ||
using post_header_length_container = | ||
std::array<std::uint8_t, default_number_of_events - 1U>; | ||
|
||
[[nodiscard]] std::size_t | ||
get_post_header_length_for_code(const post_header_length_container &storage, | ||
code_type code) noexcept; | ||
|
||
} // namespace binsrv::event | ||
|
||
#endif // BINSRV_EVENT_PROTOCOL_TRAITS_HPP |
Oops, something went wrong.