25#include <unordered_map>
35#if defined(NLOHMANN_JSON_HPP) && !defined(JSON_DISABLE_ENUM_SERIALIZATION)
36#error "nlohmann/json.hpp included before mnxdom without JSON_DISABLE_ENUM_SERIALIZATION=1"
39#ifndef JSON_DISABLE_ENUM_SERIALIZATION
40#define JSON_DISABLE_ENUM_SERIALIZATION 1
43#ifdef NLOHMANN_JSON_SYSTEM
44#include <nlohmann/json.hpp>
46#include "nlohmann/json.hpp"
48#include "BoilerplateMacros.h"
67using json = nlohmann::json;
73template <
typename T>
class Array;
84class SemanticValidator;
87#ifndef DOXYGEN_SHOULD_IGNOR_THIS
100template <
typename T, auto MakeFunc>
104template <
typename T,
typename R,
typename... Args, R(*MakeFunc)(Args...)>
113 return static_cast<Array<T>&
>(*this).template appendImpl<T>(std::forward<Args>(args)...);
118template <
typename Derived,
typename T>
125 template <
typename U = T,
typename... Args,
126 std::enable_if_t<std::is_base_of_v<Base, U>,
int> = 0>
129 return static_cast<Derived&
>(*this).template appendImpl<U>(std::forward<Args>(args)...);
133template <
typename Derived,
typename T,
typename =
void>
136template <
typename Derived,
typename T>
146template <
typename T, auto MakeFunc>
150template <
typename T,
typename R,
typename... Args, R(*MakeFunc)(Args...)>
157 T
append(std::string_view key, Args... args)
159 return static_cast<Dictionary<T>&
>(*this).template appendImpl<T>(key, std::forward<Args>(args)...);
164template <
typename Derived,
typename T>
171 template <
typename U = T,
typename... Args,
172 std::enable_if_t<std::is_base_of_v<Base, U>,
int> = 0>
173 U
append(std::string_view key, Args&&... args)
175 return static_cast<Derived&
>(*this).template appendImpl<U>(key, std::forward<Args>(args)...);
179template <
typename Derived,
typename T,
typename =
void>
182template <
typename Derived,
typename T>
200 virtual ~Base() =
default;
203 Base(
const Base& src) : m_root(src.m_root), m_pointer(src.m_pointer)
208 m_pointer(std::move(src.m_pointer))
215 if (m_root != src.m_root) {
216 throw std::logic_error(
"Assignment from a different JSON document is not allowed.");
218 m_pointer = src.m_pointer;
227 if (m_root != src.m_root) {
228 throw std::logic_error(
"Assignment from a different JSON document is not allowed.");
230 m_pointer = std::move(src.m_pointer);
237 [[nodiscard]] std::string
dump(
int indents = -1)
const
239 return ref().dump(indents);
245 template <
typename T>
248 static_assert(std::is_base_of_v<Base, T>,
"Template type mush be derived from Base.");
249 return T(m_root, m_pointer.parent_pointer());
256 template <
typename T,
typename Scope = scope::Default>
266 [[nodiscard]]
bool empty()
const {
return ref().empty(); }
274 [[nodiscard]]
json&
ref()
const {
return resolve_pointer(); }
280 [[nodiscard]]
json&
ref() {
return resolve_pointer(); }
283 [[nodiscard]]
const std::shared_ptr<json>&
root()
const {
return m_root; }
300 : m_root(
parent.m_root), m_pointer(
parent.m_pointer / std::string(key))
302 (*m_root)[m_pointer] = std::move(jsonRef);
312 template <
typename T>
313 [[nodiscard]] T
getChild(std::string_view key)
const
315 static_assert(std::is_base_of_v<Base, T>,
"template type must be derived from Base");
317 json_pointer childPointer = m_pointer / std::string(key);
318 if (!checkKeyIsValid<T>(childPointer)) {
319 throw std::out_of_range(
"Child node not found: " + std::string(key));
322 return T(m_root, childPointer);
332 template <
typename T>
335 static_assert(std::is_base_of_v<Base, T>,
"template type must be derived from Base");
337 json_pointer childPointer = m_pointer / std::string(key);
338 (*m_root)[childPointer] = value.ref();
339 return T(m_root, childPointer);
349 template <
typename T>
352 static_assert(std::is_base_of_v<Base, T>,
"template type must be derived from Base");
354 json_pointer childPointer = m_pointer / std::string(key);
355 if (!checkKeyIsValid<T>(childPointer)) {
359 return T(m_root, childPointer);
370 template <
typename T>
373 if (!(*m_root).contains(
pointer)) {
379 if constexpr (std::is_base_of_v<Object, T>) {
380 if (!node.is_object()) {
381 throw std::runtime_error(
"Expected an object for: " +
pointer.to_string());
383 }
else if constexpr (std::is_base_of_v<Array<typename T::value_type>, T>) {
384 if (!node.is_array()) {
385 throw std::runtime_error(
"Expected an array for: " +
pointer.to_string());
397 [[nodiscard]]
json& resolve_pointer()
const
399 return (*m_root).at(m_pointer);
402 const std::shared_ptr<json> m_root;
405 friend class validation::SemanticValidator;
426 if (!
ref().is_object()) {
427 throw std::invalid_argument(
"mnx::Object must wrap a JSON object.");
444 auto extensions = ensure__x();
445 extensions.ref()[key] = value;
449 [[nodiscard]] std::optional<json>
getExtension(
const std::string& key)
const
451 if (
auto extensions = _x()) {
452 const auto it = extensions->ref().find(key);
453 if (it != extensions->ref().end()) {
463template <
typename T, std::enable_if_t<!std::is_base_of_v<Base, T>,
int> = 0>
466 static_assert(std::is_arithmetic_v<T> || std::is_same_v<T, std::string>,
"This template is for simple JSON classes");
481 return ref().template get<T>();
495 return src ==
ref().template get<T>();
499class ArrayElementObject;
507 static_assert(std::is_arithmetic_v<T> || std::is_same_v<T, std::string> ||
508 std::is_base_of_v<ArrayElementObject, T>,
"Invalid MNX array element type.");
511 template<
typename ArrayType>
516 mutable size_t m_idx;
519 using iterator_category = std::input_iterator_tag;
521 using difference_type = std::ptrdiff_t;
522 using pointer = void;
525 iter(ArrayType* ptr,
size_t idx) : m_ptr(ptr), m_idx(idx) {}
526 T operator*()
const {
return (*m_ptr)[m_idx]; }
527 iter& operator++() { ++m_idx;
return *
this; }
528 bool operator!=(
const iter& o)
const {
return m_idx != o.m_idx; }
547 if (!
ref().is_array()) {
548 throw std::invalid_argument(
"mnx::Array must wrap a JSON array.");
559 [[nodiscard]]
size_t size()
const {
return ref().size(); }
562 [[nodiscard]]
bool empty()
const {
return ref().empty(); }
568 [[nodiscard]] T
at(
size_t index)
const
576 [[nodiscard]] T
front()
const {
return (*
this)[0]; }
581 [[nodiscard]] T
back()
const {
return (*
this)[
size() - 1]; }
587 if constexpr (std::is_base_of_v<Base, T>) {
588 return getChild<T>(std::to_string(index));
590 return getChild<SimpleType<T>>(std::to_string(index));
598 if constexpr (std::is_base_of_v<Base, T>) {
599 return getChild<T>(std::to_string(index));
601 return getChild<SimpleType<T>>(std::to_string(index));
606 template <
typename U = T>
607 std::enable_if_t<!std::is_base_of_v<Base, U>,
void>
610 ref().push_back(value);
624 template <
typename U = T>
625 std::enable_if_t<!std::is_base_of_v<Base, U>, std::vector<U>>
627 {
return std::vector<U>(
begin(),
end()); }
648 throw std::out_of_range(
"Index out of range");
653 template <
typename U,
typename... Args>
654 U appendImpl(Args&&... args)
656 static_assert(std::is_base_of_v<Base, U>,
"Array::appendImpl requires a Base-derived element type.");
657 if constexpr (std::is_base_of_v<Object, U>) {
658 ref().push_back(json::object());
660 ref().push_back(json::array());
662 return U(*
this, std::to_string(
ref().
size() - 1), std::forward<Args>(args)...);
665 template <
typename, auto>
666 friend struct detail::ArrayAppendFromMake;
667 template <
typename,
typename>
668 friend struct detail::ArrayAppendBase;
682 return std::stoul(
pointer().back());
689 template <
typename ContainerType>
698 virtual std::string_view defaultType()
const;
701 using ArrayElementObject::ArrayElementObject;
706 template <
typename T, std::enable_if_t<std::is_base_of_v<ContentObject, T>,
int> = 0>
707 [[nodiscard]] T
get()
const
709 return getTypedObject<T>();
714 template <
typename T, std::enable_if_t<std::is_base_of_v<ContentObject, T>,
int> = 0>
717 if (type() != T::ContentTypeValue) {
718 throw std::invalid_argument(
"Type mismatch: expected " + std::string(T::ContentTypeValue) +
727template <
typename ContainerType>
730 if constexpr (std::is_base_of_v<ContainerType, ContentObject>) {
731 const auto obj = parent<Array<ArrayElementObject>>().
template parent<ContentObject>();
732 if constexpr (std::is_same_v<ContainerType, ContentObject>) {
735 MNX_ASSERT_IF(obj.type() != ContainerType::ContentTypeValue) {
736 throw std::invalid_argument(
737 "container(): requested type does not match underlying content object type");
739 return obj.template get<ContainerType>();
742 return parent<Array<ArrayElementObject>>().
template parent<ContainerType>();
777 using BaseArray::BaseArray;
780 template <
typename T, std::enable_if_t<std::is_base_of_v<ContentObject, T>,
int> = 0>
781 [[nodiscard]] T
get(
size_t index)
const
788 template <
typename T,
789 std::enable_if_t<std::is_base_of_v<ContentObject, T> &&
790 !std::is_same_v<T, sequence::Event> &&
791 !std::is_same_v<T, sequence::Space> &&
792 !std::is_same_v<T, sequence::MultiNoteTremolo> &&
793 !std::is_same_v<T, sequence::Tuplet>,
int> = 0>
796 return appendWithType<T>();
800 template <
typename T,
typename... Args,
801 std::enable_if_t<std::is_base_of_v<ContentObject, T> && (
sizeof...(Args) > 0),
int> = 0>
804 static_assert(!std::is_same_v<T, T>,
805 "ContentArray::append requires explicit specialization for each content type.");
806 return appendWithType<T>(args...);
813 template <
typename T,
typename... Args>
814 T appendWithType(Args&&... args)
816 static_assert(std::is_base_of_v<ContentObject, T>,
817 "ContentArray::appendWithType requires a ContentObject-derived type.");
818 auto result = BaseArray::append<T>(std::forward<Args>(args)...);
820 if (T::ContentTypeValue != contentObject.defaultType()) {
821 result.set_type(std::string(T::ContentTypeValue));
828 template <
typename T, std::enable_if_t<std::is_base_of_v<ContentObject, T>,
int> = 0>
829 [[nodiscard]] T getTypedObject(
size_t index)
const
832 auto element = (*this)[index];
833 if (element.type() != T::ContentTypeValue) {
834 throw std::invalid_argument(
"Type mismatch: expected " + std::string(T::ContentTypeValue) +
835 ", got " + element.type());
837 return T(
root(),
pointer() / std::to_string(index));
845template <
typename E,
typename = std::enable_if_t<std::is_enum_v<E>>>
853 static const std::unordered_map<E, std::string> reverseMap = []() {
854 std::unordered_map<E, std::string> result;
856 result.emplace(element.second, element.first);
871 static_assert(std::is_arithmetic_v<T> || std::is_same_v<T, std::string> ||
872 std::is_base_of_v<ArrayElementObject, T>,
"Invalid MNX dictionary element type.");
875 template <
typename DictionaryType,
typename IteratorType>
878 using value_type = std::pair<const std::string, T>;
879 using difference_type = std::ptrdiff_t;
880 using iterator_category = std::forward_iterator_tag;
885 DictionaryType* m_ptr {};
886 IteratorType m_it {};
887 mutable std::optional<value_type> m_pair;
889 void update_pair()
const
892 if (m_it != m_ptr->ref().end()) {
893 m_pair.emplace(m_it.key(), m_ptr->valueForKey(m_it.key()));
898 iter(DictionaryType* ptr, IteratorType it)
899 : m_ptr(ptr), m_it(it)
904 [[nodiscard]] reference operator*()
const {
return *m_pair; }
905 [[nodiscard]] pointer operator->()
const {
return &*m_pair; }
907 iter& operator++() { ++m_it; update_pair();
return *
this; }
908 iter operator++(
int) { iter tmp(*
this); ++(*this);
return tmp; }
910 [[nodiscard]]
bool operator!=(
const iter& o)
const {
return m_it != o.m_it; }
911 [[nodiscard]]
bool operator==(
const iter& o)
const {
return m_it == o.m_it; }
936 [[nodiscard]]
size_t size()
const {
return ref().size(); }
939 [[nodiscard]]
bool empty()
const {
return ref().empty(); }
947 [[nodiscard]] T
at(std::string_view key)
const
948 {
return valueForKey(key); }
951 template <
typename U = T>
952 std::enable_if_t<!std::is_base_of_v<Base, U>,
void>
967 [[nodiscard]]
auto find(std::string_view key)
969 auto it =
ref().find(key);
976 [[nodiscard]]
auto find(std::string_view key)
const
978 auto it =
ref().find(key);
984 [[nodiscard]]
bool contains(std::string_view key)
const
1001 [[nodiscard]] T valueForKey(std::string_view key)
const
1003 if constexpr (std::is_base_of_v<Base, T>) {
1004 return getChild<T>(key);
1006 return getChild<SimpleType<T>>(key);
1010 template <
typename U,
typename... Args>
1011 U appendImpl(std::string_view key, Args&&... args)
1013 static_assert(std::is_base_of_v<Base, U>,
"Dictionary::appendImpl requires a Base-derived element type.");
1014 if constexpr (std::is_base_of_v<Object, U>) {
1015 ref()[key] = json::object();
1017 ref()[key] = json::array();
1019 return U(*
this, key, std::forward<Args>(args)...);
1022 template <
typename, auto>
1023 friend struct detail::DictionaryAppendFromMake;
1024 template <
typename,
typename>
1025 friend struct detail::DictionaryAppendBase;
1030#ifndef DOXYGEN_SHOULD_IGNORE_THIS
1037template<
typename EnumType>
1038struct adl_serializer<EnumType, std::enable_if_t<std::is_enum_v<EnumType>>>
1040 template<
typename BasicJsonType>
1041 static EnumType from_json(
const BasicJsonType& j)
1045 auto it = map.find(j.get<std::string>());
1046 if (it != map.end()) {
1053 template<
typename BasicJsonType>
1054 static void to_json(BasicJsonType& j,
const EnumType& value)
1057 auto it = map.find(value);
1058 if (it == map.end()) {
1060 j = BasicJsonType();
1070template<
typename BasicJsonType,
typename EnumType,
1071 std::enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
1072inline void from_json(
const BasicJsonType& j, EnumType& value)
1076 auto it = map.find(j.template get<std::string>());
1077 if (it != map.end()) {
1085template<
typename BasicJsonType,
typename EnumType,
1086 std::enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
1087inline void to_json(BasicJsonType& j, EnumType value)
noexcept
1090 auto it = map.find(value);
1091 if (it != map.end()) {
1095 j = BasicJsonType();
Represents an MNX object that is included as an array element.
Definition BaseTypes.h:675
ContainerType container() const
Returns the object that owns the content array this element belongs to wrapped as the specified templ...
Definition BaseTypes.h:728
size_t calcArrayIndex() const
Calculates the array index of the current instance within the array.
Definition BaseTypes.h:680
Represents an MNX array, encapsulating property access.
Definition BaseTypes.h:506
T front() const
Access the first element.
Definition BaseTypes.h:576
void checkIndex(size_t index) const
validates that an index is not out of range
Definition BaseTypes.h:644
auto begin()
Returns an iterator to the beginning of the array.
Definition BaseTypes.h:630
size_t size() const
Get the size of the array.
Definition BaseTypes.h:559
bool empty() const
Check if the array is empty.
Definition BaseTypes.h:562
iter< Array > iterator
non-const iterator type
Definition BaseTypes.h:535
iter< const Array > const_iterator
const iterator type
Definition BaseTypes.h:536
T value_type
The type for elements in this Array.
Definition BaseTypes.h:533
auto operator[](size_t index) const
const operator[]
Definition BaseTypes.h:584
Array(Base &parent, std::string_view key)
Creates a new Array class as a child of a JSON node.
Definition BaseTypes.h:555
auto begin() const
Returns a const iterator to the beginning of the array.
Definition BaseTypes.h:636
void erase(size_t index)
Remove an element at a given index.
Definition BaseTypes.h:614
std::enable_if_t<!std::is_base_of_v< Base, U >, std::vector< U > > toStdVector() const
Converts the Array to an owning std::vector.
Definition BaseTypes.h:626
auto end()
Returns an iterator to the end of the array.
Definition BaseTypes.h:633
T back() const
Access the last element.
Definition BaseTypes.h:581
Array()
Constructor for detached array instance.
Definition BaseTypes.h:539
void clear()
Clear all elements.
Definition BaseTypes.h:565
Array(const std::shared_ptr< json > &root, json_pointer pointer)
Wraps an Array class around an existing JSON array node.
Definition BaseTypes.h:545
std::enable_if_t<!std::is_base_of_v< Base, U >, void > push_back(const U &value)
Append a new value to the array. (Available only for primitive types)
Definition BaseTypes.h:608
T at(size_t index) const
Direct getter for a particular element.
Definition BaseTypes.h:568
auto end() const
Returns a const iterator to the end of the array.
Definition BaseTypes.h:639
auto operator[](size_t index)
non-const operator[]
Definition BaseTypes.h:595
Base class wrapper for all MNX JSON nodes.
Definition BaseTypes.h:198
json & ref() const
Convert this node for retrieval.
Definition BaseTypes.h:274
Base(json &&jsonRef, Base &parent, std::string_view key)
Construct a Base reference as a child inside a parent node.
Definition BaseTypes.h:299
json_pointer pointer() const
Returns the json_pointer for this node.
Definition BaseTypes.h:260
Base(const std::shared_ptr< json > &root, json_pointer pointer)
Wrap a Base instance around a specific JSON reference using a json_pointer.
Definition BaseTypes.h:290
T parent() const
Returns the parent object for this node.
Definition BaseTypes.h:246
T getChild(std::string_view key) const
Retrieves and validates a required child node.
Definition BaseTypes.h:313
json & ref()
Access the JSON node for modification.
Definition BaseTypes.h:280
std::optional< T > getOptionalChild(std::string_view key) const
Retrieves an optional child node.
Definition BaseTypes.h:350
std::optional< T > getEnclosingElement() const
Returns the enclosing array element for this instance. If T is a type that can be nested (e....
Definition Implementations.cpp:69
T setChild(std::string_view key, const T &value)
Sets a child node.
Definition BaseTypes.h:333
bool empty() const
Returns true if the object is empty.
Definition BaseTypes.h:266
Base(const Base &src)
Copy constructor.
Definition BaseTypes.h:203
Base & operator=(const Base &src)
Copy assignment operator.
Definition BaseTypes.h:212
Base(Base &&src) noexcept
Move constructor.
Definition BaseTypes.h:207
Base & operator=(Base &&src)
Move assignment operator.
Definition BaseTypes.h:224
std::string dump(int indents=-1) const
Dumps the branch to a string. Useful in debugging.
Definition BaseTypes.h:237
Document document() const
Returns the document root.
Definition Implementations.cpp:120
const std::shared_ptr< json > & root() const
Returns the root.
Definition BaseTypes.h:283
Class for content arrays.
Definition BaseTypes.h:774
T get(size_t index) const
Retrieve an element from the array as a specific type.
Definition BaseTypes.h:781
T append()
Append an element of the specified type (default overload for no-arg content types).
Definition BaseTypes.h:794
T append(const Args &... args)
Append overload entry point for explicitly specialized argful content types.
Definition BaseTypes.h:802
Base class for objects that are elements of content arrays.
Definition BaseTypes.h:696
MNX_OPTIONAL_PROPERTY_WITH_DEFAULT(std::string, type, std::string(defaultType()))
determines our type in the JSON
T get() const
Retrieve an element as a specific type.
Definition BaseTypes.h:707
T getTypedObject() const
Constructs an object of type T if its type matches the JSON type.
Definition BaseTypes.h:715
Represents an MNX dictionary, where each key is a user-defined string.
Definition BaseTypes.h:870
iter< Dictionary, json::iterator > iterator
non-const iterator type
Definition BaseTypes.h:918
size_t size() const
Get the size of the array.
Definition BaseTypes.h:936
auto end() const
Returns a const iterator to the end of the dictionary.
Definition BaseTypes.h:997
auto begin() const
Returns a const iterator to the beginning of the dictionary.
Definition BaseTypes.h:994
std::enable_if_t<!std::is_base_of_v< Base, U >, void > emplace(std::string_view key, const U &value)
Add a new value to the dictonary. (Available only for primitive types)
Definition BaseTypes.h:953
auto find(std::string_view key)
Finds an element by key and returns an iterator.
Definition BaseTypes.h:967
Dictionary(Base &parent, std::string_view key)
Creates a new Dictionary class as a child of a JSON node.
Definition BaseTypes.h:932
iter< const Dictionary, json::const_iterator > const_iterator
const iterator type
Definition BaseTypes.h:919
T value_type
The type for elements in this Array.
Definition BaseTypes.h:916
auto begin()
Returns an iterator to the beginning of the dictionary.
Definition BaseTypes.h:988
bool empty() const
Check if the array is empty.
Definition BaseTypes.h:939
auto find(std::string_view key) const
Finds an element by key and returns a const iterator.
Definition BaseTypes.h:976
void erase(std::string_view key)
Remove an element at a given key.
Definition BaseTypes.h:959
Dictionary(const std::shared_ptr< json > &root, json_pointer pointer)
Wraps an Dictionary class around an existing JSON node.
Definition BaseTypes.h:924
T at(std::string_view key) const
Direct getter for a particular element.
Definition BaseTypes.h:947
auto end()
Returns an iterator to the end of the dictionary.
Definition BaseTypes.h:991
bool contains(std::string_view key) const
Returns true if the key exists in in the dictionary.
Definition BaseTypes.h:984
void clear()
Clear all elements.
Definition BaseTypes.h:942
Represents an MNX document and provides methods for loading and saving.
Definition Document.h:103
Represents an MNX object, encapsulating property access.
Definition BaseTypes.h:415
MNX_OPTIONAL_PROPERTY(std::string, _c)
An optional comment. This serves a similar function as XML or HTML comments.
Object(const std::shared_ptr< json > &root, json_pointer pointer)
Wraps an Object class around an existing JSON object node.
Definition BaseTypes.h:424
Object()
Constructor fresh document or detached instance.
Definition BaseTypes.h:418
MNX_OPTIONAL_CHILD(Object, _x)
Vendor-defined dictionary.
void setExtension(const std::string &key, const json &value)
Sets a vendor extension value in _x, creating _x when needed.
Definition BaseTypes.h:442
std::optional< json > getExtension(const std::string &key) const
Gets a vendor extension value from _x.
Definition BaseTypes.h:449
MNX_OPTIONAL_PROPERTY(std::string, id)
Uniquely identifies the object.
Object(Base &parent, std::string_view key)
Creates a new Object class as a child of a JSON node.
Definition BaseTypes.h:434
Allows access to a fundamental type (number, boolean, string) in a JSON node.
Definition BaseTypes.h:465
SimpleType(const std::shared_ptr< json > &root, json_pointer pointer)
Wraps a SimpleType class around an existing JSON object node.
Definition BaseTypes.h:474
bool operator==(const T &src) const
Equality comparison with value type.
Definition BaseTypes.h:493
T value_type
value type of this SimpleType
Definition BaseTypes.h:469
SimpleType & operator=(const T &src)
Allow assignment to underlying json reference.
Definition BaseTypes.h:486
Represents a musical event within a sequence.
Definition Sequence.h:418
Represents a multi-note tremolo sequence within a sequence.
Definition Sequence.h:565
Occupies metric space without showing anything.
Definition Sequence.h:493
Represents a tuplet sequence within a sequence.
Definition Sequence.h:616
object model for MNX format
nlohmann::json json
JSON class for MNX.
Definition BaseTypes.h:67
std::function< void(const std::string &message, const Base &location)> ErrorHandler
Error handler type for reporting errors.
Definition BaseTypes.h:409
json::json_pointer json_pointer
JSON pointer class for MNX.
Definition BaseTypes.h:68
const int MNX_VERSION
The MNX version for files generated by the DOM.
Definition BaseTypes.h:65
const std::string & getMnxSchemaId()
Returns the MNX schema id from the embedded schema.
Definition SchemaValidate.cpp:76
int getMnxSchemaVersion()
Returns the MNX version extracted from the trailing segment of schema $id.
Definition SchemaValidate.cpp:81
Supplies enum string mappings to nlohmann json's serializer.
Definition BaseTypes.h:847
static const std::unordered_map< E, std::string > enumToString()
maps enum values to strings
Definition BaseTypes.h:851
static const std::unordered_map< std::string, E > stringToEnum()
maps strings to enum values
Base append implementation for arrays of Base-derived types.
Definition BaseTypes.h:120
U append(Args &&... args)
Append a new element at the end of the array. (Available only for Base types)
Definition BaseTypes.h:127
T append(Args... args)
Append a new element at the end of the array. (Available only for Base types)
Definition BaseTypes.h:111
Adds an append(...) overload that mirrors a type's static make(...) signature for arrays.
Definition BaseTypes.h:101
Definition BaseTypes.h:134
Base append implementation for dictionaries of Base-derived types.
Definition BaseTypes.h:166
U append(std::string_view key, Args &&... args)
Append a new element at the end of the array. (Available only for Base types)
Definition BaseTypes.h:173
T append(std::string_view key, Args... args)
Create a new element using the input key. (Available only for Base types)
Definition BaseTypes.h:157
Adds an append(key, ...) overload that mirrors a type's static make(...) signature for dictionaries.
Definition BaseTypes.h:147
Definition BaseTypes.h:180
Definition BaseTypes.h:90
Definition BaseTypes.h:92
Definition BaseTypes.h:91