denigma 4.0.0
Loading...
Searching...
No Matches
svg.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 <vector>
22
23#include "denigma/conversion.h"
24
25namespace denigma {
26namespace formats {
27
30namespace svg {
31
34enum class Unit
35{
36 None,
37 Pixels,
38 Points,
39 Picas,
40 Centimeters,
41 Millimeters,
42 Inches
43};
44
47struct Options final : public IOptions
48{
52 Unit unit{ Unit::Points };
54 double scale{ 1.0 };
56 std::vector<int> shapeDefs;
58 bool usePageScale{ false };
59};
60
64{
65public:
66 [[nodiscard]] FormatId sourceFormat() const override { return FormatId::EnigmaXml; }
67 [[nodiscard]] FormatId targetFormat() const override { return FormatId::Svg; }
68
70 ConversionResult convert(std::span<const std::byte> input,
71 const MultiOutputCallback& outputCallback,
72 const Options& options = {}) const;
73
75 ConversionResult convert(std::span<const std::byte> input,
76 const MultiOutputCallback& outputCallback,
77 const ConversionRequest& request = {}) const override;
78};
79
83{
84public:
85 [[nodiscard]] FormatId sourceFormat() const override { return FormatId::Musx; }
86 [[nodiscard]] FormatId targetFormat() const override { return FormatId::Svg; }
87
90 const MultiOutputCallback& outputCallback,
91 const Options& options = {}) const;
92
95 const MultiOutputCallback& outputCallback,
96 const ConversionRequest& request = {}) const override;
97};
98
101
102} // namespace svg
103} // namespace formats
104} // namespace denigma
Result metadata returned after a conversion completes.
Definition conversion.h:109
Lightweight registry for locating converters by source and target format.
Definition conversion.h:241
Public interface implemented by adapters that may produce multiple output documents.
Definition conversion.h:205
Base class for adapter-specific option structs.
Definition conversion.h:93
Random-access byte reader used for container formats such as MUSX.
Definition random_access_reader.h:32
Public interface implemented by reader-backed adapters that may produce multiple output documents.
Definition conversion.h:223
Converter adapter for Enigma XML input to zero or more SVG documents.
Definition svg.h:64
FormatId targetFormat() const override
Returns the target format produced by this converter.
Definition svg.h:67
ConversionResult convert(std::span< const std::byte > input, const MultiOutputCallback &outputCallback, const Options &options={}) const
Converts Enigma XML from memory and invokes outputCallback for each SVG document.
FormatId sourceFormat() const override
Returns the source format accepted by this converter.
Definition svg.h:66
ConversionResult convert(std::span< const std::byte > input, const MultiOutputCallback &outputCallback, const ConversionRequest &request={}) const override
Converts Enigma XML using type-erased registry options.
Converter adapter for MUSX archive input to zero or more SVG documents.
Definition svg.h:83
FormatId targetFormat() const override
Returns the target format produced by this converter.
Definition svg.h:86
ConversionResult convert(const IRandomAccessReader &input, const MultiOutputCallback &outputCallback, const Options &options={}) const
Extracts a MUSX archive and invokes outputCallback for each SVG document.
FormatId sourceFormat() const override
Returns the source format accepted by this converter.
Definition svg.h:85
ConversionResult convert(const IRandomAccessReader &input, const MultiOutputCallback &outputCallback, const ConversionRequest &request={}) const override
Extracts a MUSX archive using type-erased registry options.
Unit
Unit suffix used by SVG output dimensions.
Definition svg.h:35
void registerConverters(ConverterRegistry &registry)
Registers all SVG format converters with the supplied registry.
Core public API for the Denigma conversion libraries.
Definition articulations.h:32
FormatId
Stable identifiers for converter input and output formats.
Definition conversion.h:45
@ EnigmaXml
Finale Enigma XML.
@ Svg
Scalable Vector Graphics XML.
@ Musx
Finale MUSX archive.
std::function< void(std::string_view suggestedName, std::span< const std::byte > data)> MultiOutputCallback
Callback used by converters that may emit zero, one, or many output buffers.
Definition conversion.h:200
Options common to all public converter adapters.
Definition conversion.h:75
Type-erased request used by registry-based converter calls.
Definition conversion.h:101
Options for SVG converters.
Definition svg.h:48
std::vector< int > shapeDefs
Optional ShapeDef identifiers for SVG conversion.
Definition svg.h:56
CommonOptions common
Options common to all converters.
Definition svg.h:50
Unit unit
Unit suffix for SVG width and height output.
Definition svg.h:52
double scale
Extra scale multiplier for SVG output when page scaling is not active.
Definition svg.h:54
bool usePageScale
Use Finale page-format scaling.
Definition svg.h:58