denigma 4.0.0
Loading...
Searching...
No Matches
gap_report.h
1/*
2 * Copyright (C) 2026, Robert Patterson
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17 * THE SOFTWARE.
18 */
19#pragma once
20
21#include <string>
22#include <utility>
23
24#include "denigma/classify/gaps.h"
25#include "musx/util/SvgConvert.h"
26
27namespace denigma {
28
32{
33 std::string name;
34 std::string version;
35 std::string commit;
36};
37
40using GlyphMetricsFn = musx::util::SvgConvert::GlyphMetricsFn;
41
51
52#if DENIGMA_HAS_GAP_REPORT
54inline constexpr bool GAP_REPORT_AVAILABLE = true;
55
57std::string serializeGapReport(const classify::GapCollector& collector, const GapReportOptions& options);
58
62{
63public:
65 explicit GapReportWriter(const classify::GapCollector& collector)
66 : m_collector(collector)
67 {}
68
70 [[nodiscard]] std::string serialize(const GapReportOptions& options) const { return serializeGapReport(m_collector, options); }
71
72private:
73 const classify::GapCollector& m_collector;
74};
75#else
76inline constexpr bool GAP_REPORT_AVAILABLE = false;
77
81{
82public:
83 explicit GapReportWriter(const classify::GapCollector&) {}
84};
85#endif // DENIGMA_HAS_GAP_REPORT
86
92template <typename Callback>
93bool withGapReport(const classify::GapCollector& collector, Callback&& callback)
94{
95 if constexpr (GAP_REPORT_AVAILABLE) {
96 GapReportWriter writer(collector);
97 std::forward<Callback>(callback)(writer);
98 }
99 return GAP_REPORT_AVAILABLE;
100}
101
102} // namespace denigma
Placeholder in builds without the serializer.
Definition gap_report.h:81
Collects typed conversion gaps for inspection or later serialization.
Definition gaps.h:103
Core public API for the Denigma conversion libraries.
Definition articulations.h:33
musx::util::SvgConvert::GlyphMetricsFn GlyphMetricsFn
Measures text for the SVG images a report embeds: given a font and the glyphs to measure,...
Definition gap_report.h:40
bool withGapReport(const classify::GapCollector &collector, Callback &&callback)
Invokes a generic serialization callback synchronously, only in builds that include the gap report se...
Definition gap_report.h:93
What a gap report serialization needs beyond the gaps.
Definition gap_report.h:45
GlyphMetricsFn glyphMetrics
Measures glyphs for the SVG images the report embeds (custom arrowheads).
Definition gap_report.h:49
Identifies the software that serialized a gap report.
Definition gap_report.h:32