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 None,
36 Pixels,
37 Points,
38 Picas,
39 Centimeters,
40 Millimeters,
41 Inches
42};
43
46struct Options final : public IOptions
47{
51 Unit unit{Unit::Points};
53 double scale{1.0};
55 std::vector<int> shapeDefs;
57 bool usePageScale{false};
58};
59
63{
64public:
65 [[nodiscard]] FormatId sourceFormat() const override { return FormatId::EnigmaXml; }
66 [[nodiscard]] FormatId targetFormat() const override { return FormatId::Svg; }
67
69 ConversionResult convert(std::span<const std::byte> input, const MultiOutputCallback& outputCallback, const Options& options = {}) const;
70
73 std::span<const std::byte> input, const MultiOutputCallback& outputCallback, const ConversionRequest& request = {}) const override;
74};
75
79{
80public:
81 [[nodiscard]] FormatId sourceFormat() const override { return FormatId::Musx; }
82 [[nodiscard]] FormatId targetFormat() const override { return FormatId::Svg; }
83
85 ConversionResult convert(const IRandomAccessReader& input, const MultiOutputCallback& outputCallback, const Options& options = {}) const;
86
89 const IRandomAccessReader& input, const MultiOutputCallback& outputCallback, const ConversionRequest& request = {}) const override;
90};
91
94
95} // namespace svg
96} // namespace formats
97} // namespace denigma
Result metadata returned after a conversion completes.
Definition conversion.h:116
Lightweight registry for locating converters by source and target format.
Definition conversion.h:267
Public interface implemented by adapters that may produce multiple output documents.
Definition conversion.h:233
Base class for adapter-specific option structs.
Definition conversion.h:100
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:250
Converter adapter for Enigma XML input to zero or more SVG documents.
Definition svg.h:63
FormatId targetFormat() const override
Returns the target format produced by this converter.
Definition svg.h:66
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:65
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:79
FormatId targetFormat() const override
Returns the target format produced by this converter.
Definition svg.h:82
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:81
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:34
void registerConverters(ConverterRegistry &registry)
Registers all SVG format converters with the supplied registry.
Core public API for the Denigma conversion libraries.
Definition articulations.h:33
FormatId
Stable identifiers for converter input and output formats.
Definition conversion.h:51
@ 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:228
Options common to all public converter adapters.
Definition conversion.h:80
Type-erased request used by registry-based converter calls.
Definition conversion.h:108
Options for SVG converters.
Definition svg.h:47
std::vector< int > shapeDefs
Optional ShapeDef identifiers for SVG conversion.
Definition svg.h:55
CommonOptions common
Options common to all converters.
Definition svg.h:49
Unit unit
Unit suffix for SVG width and height output.
Definition svg.h:51
double scale
Extra scale multiplier for SVG output when page scaling is not active.
Definition svg.h:53
bool usePageScale
Use Finale page-format scaling.
Definition svg.h:57