MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
FlowParser.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project.
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5
6#include <cstddef>
7#include <array>
8#include <string>
9#include <uuid.h>
10#include <picojson/wrapper.h>
11#include <mxl/dataformat.h>
12#include <mxl/flowinfo.h>
13#include <mxl/platform.h>
14#include <mxl/rational.h>
15
16namespace mxl::lib
17{
22 {
23 public:
30 FlowParser(std::string const& in_flowDef);
31
37 [[nodiscard]]
38 uuids::uuid const& getId() const;
39
47 [[nodiscard]]
49
55 [[nodiscard]]
57
62 [[nodiscard]]
63 std::size_t getPayloadSize() const;
64
69 [[nodiscard]]
70 std::array<std::uint32_t, MXL_MAX_PLANES_PER_GRAIN> getPayloadSliceLengths() const;
71
76 [[nodiscard]]
77 std::size_t getTotalPayloadSlices() const;
78
84 [[nodiscard]]
85 std::size_t getChannelCount() const;
86
94 template<typename T>
95 [[nodiscard]]
96 T get(std::string const& field) const;
97
98 private:
100 uuids::uuid _id;
108 picojson::object _root;
109 };
110
111 /**************************************************************************/
112 /* Inline implementation. */
113 /**************************************************************************/
114
115 template<typename T>
116 inline T FlowParser::get(std::string const& field) const
117 {
118 if (auto const it = _root.find(field); it != _root.end())
119 {
120 return it->second.get<T>();
121 }
122 else
123 {
124 auto msg = std::string{"Required '"} + field + "' not found.";
125 throw std::invalid_argument{std::move(msg)};
126 }
127 }
128
129}
std::array< std::uint32_t, MXL_MAX_PLANES_PER_GRAIN > getPayloadSliceLengths() const
mxlDataFormat getFormat() const
FlowParser(std::string const &in_flowDef)
std::size_t getTotalPayloadSlices() const
picojson::object _root
T get(std::string const &field) const
mxlRational getGrainRate() const
std::size_t getChannelCount() const
mxlDataFormat _format
std::size_t getPayloadSize() const
uuids::uuid const & getId() const
Public flow format identifiers and format classification helpers.
mxlDataFormat
Definition dataformat.h:25
Public configuration and runtime metadata for MXL flows.
#define MXL_EXPORT
Definition platform.h:9
struct mxlRational_t mxlRational