denigma 4.0.0
Loading...
Searching...
No Matches
mnx.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 above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22#pragma once
23
24#include <optional>
25#include <string>
26
27#include "denigma/conversion.h"
28
29namespace denigma {
30namespace formats {
31
34namespace mnx {
35
38struct Options final : public IOptions
39{
43 std::optional<int> indentSpaces{4};
45 std::optional<int> cueLayer;
47 std::optional<std::string> schema;
49 bool includeTempoTool{false};
51 bool splitInstruments{false};
52};
53
57{
58public:
59 [[nodiscard]] FormatId sourceFormat() const override { return FormatId::EnigmaXml; }
60 [[nodiscard]] FormatId targetFormat() const override { return FormatId::MnxJson; }
61
63 ConversionResult convert(std::span<const std::byte> input, std::ostream& output, const Options& options = {}) const;
64
66 ConversionResult convert(std::span<const std::byte> input, std::ostream& output, const ConversionRequest& request = {}) const override;
67};
68
72{
73public:
74 [[nodiscard]] FormatId sourceFormat() const override { return FormatId::Musx; }
75 [[nodiscard]] FormatId targetFormat() const override { return FormatId::MnxJson; }
76
78 ConversionResult convert(const IRandomAccessReader& input, std::ostream& output, const Options& options = {}) const;
79
81 ConversionResult convert(const IRandomAccessReader& input, std::ostream& output, const ConversionRequest& request = {}) const override;
82};
83
86
87} // namespace mnx
88} // namespace formats
89} // 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 each conversion adapter.
Definition conversion.h:198
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 adapters whose input is a random-access container.
Definition conversion.h:214
Converter adapter for Enigma XML input to MNX JSON output.
Definition mnx.h:57
FormatId targetFormat() const override
Returns the target format produced by this converter.
Definition mnx.h:60
ConversionResult convert(std::span< const std::byte > input, std::ostream &output, const ConversionRequest &request={}) const override
Converts Enigma XML using type-erased registry options.
ConversionResult convert(std::span< const std::byte > input, std::ostream &output, const Options &options={}) const
Converts Enigma XML from memory and writes MNX JSON to the provided stream.
FormatId sourceFormat() const override
Returns the source format accepted by this converter.
Definition mnx.h:59
Converter adapter for MUSX archive input to MNX JSON output.
Definition mnx.h:72
FormatId targetFormat() const override
Returns the target format produced by this converter.
Definition mnx.h:75
ConversionResult convert(const IRandomAccessReader &input, std::ostream &output, const ConversionRequest &request={}) const override
Extracts a MUSX archive using type-erased registry options.
ConversionResult convert(const IRandomAccessReader &input, std::ostream &output, const Options &options={}) const
Extracts a MUSX archive and writes MNX JSON to the provided stream.
FormatId sourceFormat() const override
Returns the source format accepted by this converter.
Definition mnx.h:74
void registerConverters(ConverterRegistry &registry)
Registers all MNX 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.
@ MnxJson
MNX JSON as produced by mnxdom.
@ Musx
Finale MUSX archive.
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 MNX JSON converters.
Definition mnx.h:39
bool includeTempoTool
Include Finale Tempo Tool changes.
Definition mnx.h:49
std::optional< int > indentSpaces
Number of spaces used for formatted JSON output, or std::nullopt for compact output.
Definition mnx.h:43
CommonOptions common
Options common to all converters.
Definition mnx.h:41
std::optional< int > cueLayer
Optional cue layer to omit because MNX does not currently support cues.
Definition mnx.h:45
bool splitInstruments
Split Finale instruments into separate MNX parts.
Definition mnx.h:51
std::optional< std::string > schema
Optional MNX JSON schema contents used for validation.
Definition mnx.h:47