Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
dawproject_import.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <cstddef>
7#include <cstdint>
8#include <functional>
9#include <optional>
10#include <span>
11#include <string>
12#include <string_view>
13#include <vector>
14
15namespace pulp::timeline {
16
20
37
52
62
69 std::function<std::optional<std::vector<std::uint8_t>>(std::string_view package_path)>;
70
71namespace detail {
73 // The returned view is consumed synchronously and is never retained.
74 using Function = std::optional<std::span<const std::uint8_t>> (*)(void*, std::string_view);
75 void* context = nullptr;
76 Function function = nullptr;
77 explicit operator bool() const noexcept { return function != nullptr; }
78 std::optional<std::span<const std::uint8_t>> operator()(std::string_view path) const {
79 return function(context, path);
80 }
81};
82}
83
96 std::size_t max_xml_bytes = 64u * 1024u * 1024u;
98 std::size_t max_tracks = 16'384;
100 std::size_t max_clips = 1'000'000;
102 std::size_t max_notes = 5'000'000;
104 std::size_t max_media_assets = 16'384;
106 std::size_t max_media_resolver_calls = 1'000'000;
108 std::size_t max_package_path_bytes = 4'096;
110 std::uint64_t max_media_bytes_per_resolver_call = 2ull * 1024ull * 1024ull * 1024ull;
112 std::uint64_t max_total_media_bytes = 16ull * 1024ull * 1024ull * 1024ull;
113};
114
123
134import_dawproject_xml(std::string_view project_xml, DawProjectMediaResolver media_resolver);
135
148import_dawproject_xml(std::string_view project_xml, DawProjectMediaResolver media_resolver,
149 const DawProjectImportLimits& limits);
150
151namespace detail {
153import_dawproject_xml_view(std::string_view project_xml,
154 DawProjectMediaViewResolver media_resolver,
155 const DawProjectImportLimits& limits);
156}
157
159
160} // namespace pulp::timeline
Result<T, E> — either holds a T or an E, never both.
Definition result.hpp:76
runtime::Result< Project, DawProjectImportError > import_dawproject_xml(std::string_view project_xml)
Parses a DAWproject project.xml document without resolving audio media.
DawProjectImportErrorCode
Stable category for a DAWproject import failure.
Definition dawproject_import.hpp:39
std::function< std::optional< std::vector< std::uint8_t > >(std::string_view package_path)> DawProjectMediaResolver
Resolves a safe package-relative path to complete media bytes.
Definition dawproject_import.hpp:68
@ UnsupportedVersion
The Project major version is unsupported.
Definition dawproject_import.hpp:42
@ MissingRoot
No Project document element exists.
Definition dawproject_import.hpp:41
@ InvalidValue
An attribute is unparseable or out of range.
Definition dawproject_import.hpp:45
@ LimitExceeded
A configured import resource limit was exceeded.
Definition dawproject_import.hpp:50
@ ModelRejected
The assembled Project violates a model invariant.
Definition dawproject_import.hpp:49
@ DanglingTrackReference
An arrangement lane names an unknown track.
Definition dawproject_import.hpp:48
@ UnsupportedFeature
A construct lies outside the accepted subset.
Definition dawproject_import.hpp:43
@ MissingAttribute
A required attribute is absent.
Definition dawproject_import.hpp:44
@ ParseError
The XML text is not well-formed.
Definition dawproject_import.hpp:40
@ MissingMediaBytes
The resolver did not supply referenced media.
Definition dawproject_import.hpp:46
@ DuplicateTrackId
Two Track elements share an identity.
Definition dawproject_import.hpp:47
Definition clip_launch.hpp:30
runtime::Result< Project, DawProjectImportError > import_dawproject_xml_view(std::string_view project_xml, DawProjectMediaViewResolver media_resolver, const DawProjectImportLimits &limits)
Definition program_compiler.hpp:18
Result<T, E> — success / failure union for fallible operations.
Diagnostic returned when an import rejects the whole document.
Definition dawproject_import.hpp:54
ModelError model_error
Underlying model failure when code is ModelRejected.
Definition dawproject_import.hpp:60
DawProjectImportErrorCode code
Failure category.
Definition dawproject_import.hpp:56
std::string message
Human-readable detail naming the offending element, attribute, or value.
Definition dawproject_import.hpp:58
Hard resource ceilings for one import.
Definition dawproject_import.hpp:94
std::size_t max_media_resolver_calls
Maximum resolver calls, including repeated paths or content.
Definition dawproject_import.hpp:106
std::size_t max_tracks
Maximum tracks across the whole document.
Definition dawproject_import.hpp:98
std::size_t max_notes
Maximum notes across the whole document.
Definition dawproject_import.hpp:102
std::size_t max_clips
Maximum clips across the whole document.
Definition dawproject_import.hpp:100
std::size_t max_package_path_bytes
Maximum UTF-8 bytes in one package-relative path.
Definition dawproject_import.hpp:108
std::uint64_t max_media_bytes_per_resolver_call
Maximum bytes returned by one successful resolver call.
Definition dawproject_import.hpp:110
std::size_t max_xml_bytes
Raw project.xml bytes, checked before constructing the XML DOM.
Definition dawproject_import.hpp:96
std::uint64_t max_total_media_bytes
Maximum bytes returned by all successful calls, including duplicates.
Definition dawproject_import.hpp:112
std::size_t max_media_assets
Maximum unique retained assets after content-hash deduplication.
Definition dawproject_import.hpp:104
Model failure with the offending and, when relevant, conflicting identity.
Definition clip.hpp:95
Definition dawproject_import.hpp:72
Function function
Definition dawproject_import.hpp:76
std::optional< std::span< const std::uint8_t > > operator()(std::string_view path) const
Definition dawproject_import.hpp:78
std::optional< std::span< const std::uint8_t > >(*)(void *, std::string_view) Function
Definition dawproject_import.hpp:74
void * context
Definition dawproject_import.hpp:75