| Coverage Report |
 |
|
|
 |
: /*
: Copyright (c) 2025 Giuseppe Roberti.
: All rights reserved.
:
: Redistribution and use in source and binary forms, with or without modification,
: are permitted provided that the following conditions are met:
:
: 1. Redistributions of source code must retain the above copyright notice, this
: list of conditions and the following disclaimer.
:
: 2. Redistributions in binary form must reproduce the above copyright notice,
: this list of conditions and the following disclaimer in the documentation and/or
: other materials provided with the distribution.
:
: 3. Neither the name of the copyright holder nor the names of its contributors
: may be used to endorse or promote products derived from this software without
: specific prior written permission.
:
: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
: ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
: ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
: */
: #pragma once
:
: #include <spdlog/spdlog.h>
:
: #include <format>
:
: namespace pars
: {
:
: enum class lf
: {
: app = 1,
: comp = 2,
: event = 4,
: net = 8,
: user = 1073741824,
: };
:
: constexpr static int operator|(const lf& a, const lf& b)
: {
0 / 1 : return static_cast<int>(a) | static_cast<int>(b);
: }
:
: constexpr static int operator|(const int& a, const lf& b)
: {
0 / 1 : return a | static_cast<int>(b);
: }
:
: constexpr static int operator|(const lf& a, const int& b)
: {
0 / 1 : return static_cast<int>(a) | b;
: }
:
: constexpr static int operator&(const lf& a, const int& b)
: {
0 / 1 : return static_cast<int>(a) & b;
: }
:
: constexpr static int operator&(const int& a, const lf& b)
: {
0 / 1 : return a & static_cast<int>(b);
: }
:
: constexpr static int operator&(const lf& a, const lf& b)
: {
0 / 1 : return static_cast<int>(a) & static_cast<int>(b);
: }
:
: namespace f
: {
:
: struct lf
: {
: lf(::pars::lf flags)
: : val{static_cast<int>(flags)}
: {
: }
:
: lf(int flags)
: : val{flags}
: {
: }
:
: int val;
: };
:
: } // namespace f
:
: } // namespace pars
:
: template<>
: struct std::formatter<::pars::lf> : formatter<std::string>
: {
: auto format(const ::pars::lf& flag, format_context& ctx) const
: -> decltype(ctx.out())
: {
0 / 1 : switch (flag)
: {
0 / 1 : case ::pars::lf::app:
0 / 1 : return std::format_to(ctx.out(), "app");
0 / 1 : case ::pars::lf::comp:
0 / 1 : return std::format_to(ctx.out(), "comp");
0 / 1 : case ::pars::lf::event:
0 / 1 : return std::format_to(ctx.out(), "event");
0 / 1 : case ::pars::lf::net:
0 / 1 : return std::format_to(ctx.out(), "net");
0 / 1 : case ::pars::lf::user:
0 / 1 : return std::format_to(ctx.out(), "user");
0 / 1 : default:
0 / 1 : return std::format_to(ctx.out(), "<lf-{}>", static_cast<int>(flag));
: }
: }
: };
:
: template<>
: struct std::formatter<::pars::f::lf> : formatter<std::string>
: {
: auto format(const ::pars::f::lf& flags, format_context& ctx) const
: -> decltype(ctx.out())
: {
0 / 1 : auto it = ctx.out();
:
0 / 1 : for (const auto& f : {::pars::lf::app, ::pars::lf::comp, ::pars::lf::event,
0 / 1 : ::pars::lf::net, ::pars::lf::user})
: {
0 / 1 : if (!(flags.val & f))
0 / 1 : continue;
:
0 / 1 : it = std::format_to(it, " {}", f);
: }
:
0 / 1 : return it;
: }
: };
 |
| Generated by: llvmcov2html |