diff --git a/.gitmodules b/.gitmodules index b8366ffd3..5467b79e5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,9 @@ -[submodule "src/deps/optional-lite"] - path = src/deps/optional-lite - url = https://github.com/martinmoene/optional-lite [submodule "src/deps/pybind11"] path = src/deps/pybind11 url = https://github.com/pybind/pybind11.git [submodule "src/deps/rapidjson"] path = src/deps/rapidjson url = https://github.com/Tencent/rapidjson.git -[submodule "src/deps/any"] - path = src/deps/any - url = https://github.com/thelink2012/any.git [submodule "src/deps/Imath"] path = src/deps/Imath url = https://github.com/AcademySoftwareFoundation/Imath diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f7d70ce1..f2a525b44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ set(OTIO_AUTHOR_EMAIL "otio-discussion@lists.aswf.io") set(OTIO_LICENSE "Modified Apache 2.0 License") set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "") +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version") project(OpenTimelineIO VERSION ${OTIO_VERSION} LANGUAGES C CXX) @@ -142,7 +143,7 @@ endif() # Global language settings if (NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD 17) endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/src/deps/CMakeLists.txt b/src/deps/CMakeLists.txt index 318fced2d..7d7ccec85 100644 --- a/src/deps/CMakeLists.txt +++ b/src/deps/CMakeLists.txt @@ -4,7 +4,7 @@ #----- Other dependencies # detect if the submodules haven't been updated -set(DEPS_SUBMODULES any optional-lite pybind11 rapidjson) +set(DEPS_SUBMODULES pybind11 rapidjson) foreach(submodule IN LISTS DEPS_SUBMODULES) file(GLOB SUBMOD_CONTENTS ${submodule}) list(LENGTH SUBMOD_CONTENTS SUBMOD_CONTENT_LEN) @@ -20,13 +20,6 @@ if(OTIO_PYTHON_INSTALL) add_subdirectory(pybind11) endif() -if(OTIO_CXX_INSTALL AND OTIO_DEPENDENCIES_INSTALL) - install(FILES any/any.hpp - DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/include/opentimelineio/deps/any") - install(FILES optional-lite/include/nonstd/optional.hpp - DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/include/opentimelineio/deps/nonstd") -endif() - if (USE_DEPS_IMATH) # preserve BUILD_SHARED_LIBS options for this project, but set it off for Imath option(BUILD_SHARED_LIBS "Build shared libraries" ON) diff --git a/src/deps/any b/src/deps/any deleted file mode 160000 index bfc77f2e4..000000000 --- a/src/deps/any +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bfc77f2e4be6e9a093dd645ef3f1aa30620c9205 diff --git a/src/deps/optional-lite b/src/deps/optional-lite deleted file mode 160000 index be720ebfd..000000000 --- a/src/deps/optional-lite +++ /dev/null @@ -1 +0,0 @@ -Subproject commit be720ebfd7add22abe60e49602735de9231105d0 diff --git a/src/opentimelineio/CMakeLists.txt b/src/opentimelineio/CMakeLists.txt index 318eac362..4b08e6d96 100644 --- a/src/opentimelineio/CMakeLists.txt +++ b/src/opentimelineio/CMakeLists.txt @@ -2,7 +2,6 @@ # opentimelineio/CMakeLists.txt set(OPENTIMELINEIO_HEADER_FILES - any.h anyDictionary.h anyVector.h clip.h @@ -22,7 +21,6 @@ set(OPENTIMELINEIO_HEADER_FILES marker.h mediaReference.h missingReference.h - optional.h safely_typed_any.h serializableCollection.h serializableObject.h @@ -83,7 +81,6 @@ target_include_directories(opentimelineio PRIVATE "${IMATH_INCLUDES}" "${PROJECT_SOURCE_DIR}/src" "${PROJECT_SOURCE_DIR}/src/deps" - "${PROJECT_SOURCE_DIR}/src/deps/optional-lite/include" "${PROJECT_SOURCE_DIR}/src/deps/rapidjson/include" "${IMATH_INCLUDES}") diff --git a/src/opentimelineio/any.h b/src/opentimelineio/any.h deleted file mode 100644 index 5a55ee448..000000000 --- a/src/opentimelineio/any.h +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright Contributors to the OpenTimelineIO project - -#pragma once - -#include "any/any.hpp" -#include "opentimelineio/version.h" - -namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { - -using linb::any; -using linb::any_cast; - -}} // namespace opentimelineio::OPENTIMELINEIO_VERSION diff --git a/src/opentimelineio/anyDictionary.h b/src/opentimelineio/anyDictionary.h index af5f5a29f..19eeabdf0 100644 --- a/src/opentimelineio/anyDictionary.h +++ b/src/opentimelineio/anyDictionary.h @@ -3,9 +3,9 @@ #pragma once -#include "opentimelineio/any.h" #include "opentimelineio/version.h" +#include #include #include #include @@ -14,7 +14,7 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { /** * An AnyDictionary has exactly the same API as - * std::map + * std::map * * except that it records a "time-stamp" that bumps monotonically every time an * operation that would invalidate iterators is performed. @@ -26,7 +26,7 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { * and take steps to safe-guard themselves from causing a crash. (Yes, * I'm talking to you, Python...) */ -class AnyDictionary : private std::map +class AnyDictionary : private std::map { public: using map::map; @@ -125,7 +125,7 @@ class AnyDictionary : private std::map /// @TODO: remove all of these @{ // if key is in this, and the type of key matches the type of result, then - // set result to the value of any_cast(this[key]) and return true, + // set result to the value of std::any_cast(this[key]) and return true, // otherwise return false template bool get_if_set(const std::string& key, containedType* result) const @@ -141,7 +141,7 @@ class AnyDictionary : private std::map && (it->second.type().hash_code() == typeid(containedType).hash_code())) { - *result = any_cast(it->second); + *result = std::any_cast(it->second); return true; } else @@ -171,7 +171,7 @@ class AnyDictionary : private std::map && (d_it->second.type().hash_code() == typeid(containedType).hash_code())) { - *result = any_cast(d_it->second); + *result = std::any_cast(d_it->second); return true; } else diff --git a/src/opentimelineio/anyVector.h b/src/opentimelineio/anyVector.h index 38561fead..ee78c3f6c 100644 --- a/src/opentimelineio/anyVector.h +++ b/src/opentimelineio/anyVector.h @@ -3,8 +3,9 @@ #pragma once -#include "opentimelineio/any.h" #include "opentimelineio/version.h" + +#include #include #include @@ -12,7 +13,7 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { /** * An AnyVector has exactly the same API as - * std::vector + * std::vector * * except that it records a "time-stamp" that * lets external observers know when the vector has been destroyed (which includes @@ -22,7 +23,7 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { * and take steps to safe-guard themselves from causing a crash. */ -class AnyVector : private std::vector +class AnyVector : private std::vector { public: using vector::vector; diff --git a/src/opentimelineio/clip.cpp b/src/opentimelineio/clip.cpp index f390692c7..e642b48f3 100644 --- a/src/opentimelineio/clip.cpp +++ b/src/opentimelineio/clip.cpp @@ -9,11 +9,11 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { char constexpr Clip::default_media_key[]; Clip::Clip( - std::string const& name, - MediaReference* media_reference, - optional const& source_range, - AnyDictionary const& metadata, - std::string const& active_media_reference_key) + std::string const& name, + MediaReference* media_reference, + std::optional const& source_range, + AnyDictionary const& metadata, + std::string const& active_media_reference_key) : Parent{ name, source_range, metadata } , _active_media_reference_key(active_media_reference_key) { @@ -184,7 +184,7 @@ Clip::available_range(ErrorStatus* error_status) const return active_media->available_range().value(); } -optional +std::optional Clip::available_image_bounds(ErrorStatus* error_status) const { auto active_media = media_reference(); @@ -194,7 +194,7 @@ Clip::available_image_bounds(ErrorStatus* error_status) const ErrorStatus::CANNOT_COMPUTE_BOUNDS, "No image bounds set on clip", this); - return optional(); + return std::optional(); } if (!active_media->available_image_bounds()) @@ -203,7 +203,7 @@ Clip::available_image_bounds(ErrorStatus* error_status) const ErrorStatus::CANNOT_COMPUTE_BOUNDS, "No image bounds set on media reference on clip", this); - return optional(); + return std::optional(); } return active_media->available_image_bounds(); diff --git a/src/opentimelineio/clip.h b/src/opentimelineio/clip.h index 0eea7131c..d7f8195bd 100644 --- a/src/opentimelineio/clip.h +++ b/src/opentimelineio/clip.h @@ -23,11 +23,11 @@ class Clip : public Item using Parent = Item; Clip( - std::string const& name = std::string(), - MediaReference* media_reference = nullptr, - optional const& source_range = nullopt, - AnyDictionary const& metadata = AnyDictionary(), - std::string const& active_media_reference_key = default_media_key); + std::string const& name = std::string(), + MediaReference* media_reference = nullptr, + std::optional const& source_range = std::nullopt, + AnyDictionary const& metadata = AnyDictionary(), + std::string const& active_media_reference_key = default_media_key); void set_media_reference(MediaReference* media_reference); MediaReference* media_reference() const noexcept; @@ -48,7 +48,7 @@ class Clip : public Item TimeRange available_range(ErrorStatus* error_status = nullptr) const override; - optional + std::optional available_image_bounds(ErrorStatus* error_status) const override; protected: diff --git a/src/opentimelineio/composable.cpp b/src/opentimelineio/composable.cpp index 88e1299d4..0a6f3b957 100644 --- a/src/opentimelineio/composable.cpp +++ b/src/opentimelineio/composable.cpp @@ -74,11 +74,11 @@ Composable::duration(ErrorStatus* error_status) const return RationalTime(); } -optional +std::optional Composable::available_image_bounds(ErrorStatus* error_status) const { *error_status = ErrorStatus::NOT_IMPLEMENTED; - return optional(); + return std::optional(); } }} // namespace opentimelineio::OPENTIMELINEIO_VERSION diff --git a/src/opentimelineio/composable.h b/src/opentimelineio/composable.h index bd1d31df9..d2691ff09 100644 --- a/src/opentimelineio/composable.h +++ b/src/opentimelineio/composable.h @@ -34,7 +34,7 @@ class Composable : public SerializableObjectWithMetadata virtual RationalTime duration(ErrorStatus* error_status = nullptr) const; - virtual optional + virtual std::optional available_image_bounds(ErrorStatus* error_status) const; protected: diff --git a/src/opentimelineio/composition.cpp b/src/opentimelineio/composition.cpp index cd9811d31..2bf12ad88 100644 --- a/src/opentimelineio/composition.cpp +++ b/src/opentimelineio/composition.cpp @@ -11,11 +11,11 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { Composition::Composition( - std::string const& name, - optional const& source_range, - AnyDictionary const& metadata, - std::vector const& effects, - std::vector const& markers) + std::string const& name, + std::optional const& source_range, + AnyDictionary const& metadata, + std::vector const& effects, + std::vector const& markers) : Parent(name, source_range, metadata, effects, markers) {} @@ -228,12 +228,14 @@ Composition::is_parent_of(Composable const* other) const return false; } -std::pair, optional> +std::pair, std::optional> Composition::handles_of_child( Composable const* /* child */, ErrorStatus* /* error_status */) const { - return std::make_pair(optional(), optional()); + return std::make_pair( + std::optional(), + std::optional()); } std::vector @@ -306,9 +308,9 @@ Composition::range_of_child(Composable const* child, ErrorStatus* error_status) return TimeRange(); } - Composition const* reference_space = this; // XXX - optional result_range; - auto current = child; + Composition const* reference_space = this; // XXX + std::optional result_range; + auto current = child; assert(!parents.empty()); for (auto parent: parents) @@ -347,7 +349,7 @@ Composition::range_of_child(Composable const* child, ErrorStatus* error_status) } // XXX should have reference_space argument or something -optional +std::optional Composition::trimmed_range_of_child( Composable const* child, ErrorStatus* error_status) const @@ -358,8 +360,8 @@ Composition::trimmed_range_of_child( return TimeRange(); } - optional result_range; - auto current = child; + std::optional result_range; + auto current = child; assert(!parents.empty()); for (auto parent: parents) @@ -398,7 +400,7 @@ Composition::trimmed_range_of_child( std::max(source_range()->start_time(), result_range->start_time()); if (new_start_time > result_range->end_time_exclusive()) { - return nullopt; + return std::nullopt; } auto new_duration = std::min( @@ -407,7 +409,7 @@ Composition::trimmed_range_of_child( - new_start_time; if (new_duration.value() < 0) { - return nullopt; + return std::nullopt; } return TimeRange(new_start_time, new_duration); @@ -430,7 +432,7 @@ Composition::_children_at_time(RationalTime t, ErrorStatus* error_status) const return result; } -optional +std::optional Composition::trim_child_range(TimeRange child_range) const { if (!source_range()) @@ -445,7 +447,7 @@ Composition::trim_child_range(TimeRange child_range) const if (past_end_time || before_start_time) { - return nullopt; + return std::nullopt; } if (child_range.start_time() < sr.start_time()) @@ -610,8 +612,8 @@ Composition::_bisect_right( RationalTime const& tgt, std::function const& key_func, ErrorStatus* error_status, - optional lower_search_bound, - optional upper_search_bound) const + std::optional lower_search_bound, + std::optional upper_search_bound) const { if (*lower_search_bound < 0) { @@ -625,7 +627,7 @@ Composition::_bisect_right( } if (!upper_search_bound) { - upper_search_bound = optional(_children.size()); + upper_search_bound = std::optional(_children.size()); } int64_t midpoint_index = 0; while (*lower_search_bound < *upper_search_bound) @@ -651,8 +653,8 @@ Composition::_bisect_left( RationalTime const& tgt, std::function const& key_func, ErrorStatus* error_status, - optional lower_search_bound, - optional upper_search_bound) const + std::optional lower_search_bound, + std::optional upper_search_bound) const { if (*lower_search_bound < 0) { @@ -666,7 +668,7 @@ Composition::_bisect_left( } if (!upper_search_bound) { - upper_search_bound = optional(_children.size()); + upper_search_bound = std::optional(_children.size()); } int64_t midpoint_index = 0; while (*lower_search_bound < *upper_search_bound) diff --git a/src/opentimelineio/composition.h b/src/opentimelineio/composition.h index 814e4d05c..9a8802f68 100644 --- a/src/opentimelineio/composition.h +++ b/src/opentimelineio/composition.h @@ -21,11 +21,11 @@ class Composition : public Item using Parent = Item; Composition( - std::string const& name = std::string(), - optional const& source_range = nullopt, - AnyDictionary const& metadata = AnyDictionary(), - std::vector const& effects = std::vector(), - std::vector const& markers = std::vector()); + std::string const& name = std::string(), + std::optional const& source_range = std::nullopt, + AnyDictionary const& metadata = AnyDictionary(), + std::vector const& effects = std::vector(), + std::vector const& markers = std::vector()); virtual std::string composition_kind() const; @@ -63,7 +63,7 @@ class Composition : public Item bool is_parent_of(Composable const* other) const; - virtual std::pair, optional> + virtual std::pair, std::optional> handles_of_child( Composable const* child, ErrorStatus* error_status = nullptr) const; @@ -79,11 +79,11 @@ class Composition : public Item TimeRange range_of_child( Composable const* child, ErrorStatus* error_status = nullptr) const; - optional trimmed_range_of_child( + std::optional trimmed_range_of_child( Composable const* child, ErrorStatus* error_status = nullptr) const; - optional trim_child_range(TimeRange child_range) const; + std::optional trim_child_range(TimeRange child_range) const; bool has_child(Composable* child) const; @@ -112,9 +112,9 @@ class Composition : public Item // The search is recursive unless shallow_search is set to true. template std::vector> find_children( - ErrorStatus* error_status = nullptr, - optional search_range = nullopt, - bool shallow_search = false) const; + ErrorStatus* error_status = nullptr, + std::optional search_range = std::nullopt, + bool shallow_search = false) const; protected: virtual ~Composition(); @@ -143,9 +143,9 @@ class Composition : public Item int64_t _bisect_right( RationalTime const& tgt, std::function const& key_func, - ErrorStatus* error_status = nullptr, - optional lower_search_bound = optional(0), - optional upper_search_bound = nullopt) const; + ErrorStatus* error_status = nullptr, + std::optional lower_search_bound = std::optional(0), + std::optional upper_search_bound = std::nullopt) const; // Return the index of the last item in seq such that all e in seq[:index] // have key_func(e) < tgt, and all e in seq[index:] have key_func(e) >= tgt. @@ -159,9 +159,9 @@ class Composition : public Item int64_t _bisect_left( RationalTime const& tgt, std::function const& key_func, - ErrorStatus* error_status = nullptr, - optional lower_search_bound = optional(0), - optional upper_search_bound = nullopt) const; + ErrorStatus* error_status = nullptr, + std::optional lower_search_bound = std::optional(0), + std::optional upper_search_bound = std::nullopt) const; std::vector> _children; @@ -173,9 +173,9 @@ class Composition : public Item template inline std::vector> Composition::find_children( - ErrorStatus* error_status, - optional search_range, - bool shallow_search) const + ErrorStatus* error_status, + std::optional search_range, + bool shallow_search) const { std::vector> out; std::vector> children; diff --git a/src/opentimelineio/deserialization.cpp b/src/opentimelineio/deserialization.cpp index a50c8ecfd..5bfa60a6d 100644 --- a/src/opentimelineio/deserialization.cpp +++ b/src/opentimelineio/deserialization.cpp @@ -56,26 +56,26 @@ class JSONDecoder : public OTIO_rapidjson:: } } - bool Null() { return store(any()); } - bool Bool(bool b) { return store(any(b)); } + bool Null() { return store(std::any()); } + bool Bool(bool b) { return store(std::any(b)); } // coerce all integer types to int64_t... - bool Int(int i) { return store(any(static_cast(i))); } - bool Int64(int64_t i) { return store(any(static_cast(i))); } - bool Uint(unsigned u) { return store(any(static_cast(u))); } + bool Int(int i) { return store(std::any(static_cast(i))); } + bool Int64(int64_t i) { return store(std::any(static_cast(i))); } + bool Uint(unsigned u) { return store(std::any(static_cast(u))); } bool Uint64(uint64_t u) { /// prevent an overflow - return store(any(static_cast(u & 0x7FFFFFFFFFFFFFFF))); + return store(std::any(static_cast(u & 0x7FFFFFFFFFFFFFFF))); } // ...and all floating point types to double - bool Double(double d) { return store(any(d)); } + bool Double(double d) { return store(std::any(d)); } bool String(const char* str, OTIO_rapidjson::SizeType length, bool /* copy */) { - return store(any(std::string(str, length))); + return store(std::any(std::string(str, length))); } bool Key(const char* str, OTIO_rapidjson::SizeType length, bool /* copy */) @@ -144,7 +144,7 @@ class JSONDecoder : public OTIO_rapidjson:: AnyVector va; va.swap(top.array); _stack.pop_back(); - store(any(std::move(va))); + store(std::any(std::move(va))); } } return true; @@ -187,7 +187,7 @@ class JSONDecoder : public OTIO_rapidjson:: return true; } - bool store(any&& a) + bool store(std::any&& a) { if (has_errored()) { @@ -219,12 +219,12 @@ class JSONDecoder : public OTIO_rapidjson:: auto e = d.find(key); if (e != d.end() && typeid(T) == e->second.type()) { - return &any_cast(e->second); + return &std::any_cast(e->second); } return nullptr; } - any _root; + std::any _root; void _internal_error(std::string const& err_msg) { @@ -303,7 +303,7 @@ SerializableObject::Reader::_error(ErrorStatus const& error_status) auto e = _dict.find("name"); if (e != _dict.end() && e->second.type() == typeid(std::string)) { - name = any_cast(e->second); + name = std::any_cast(e->second); } _error_function(ErrorStatus( @@ -331,7 +331,7 @@ SerializableObject::Reader::_fix_reference_ids( void SerializableObject::Reader::_fix_reference_ids( - any& a, + std::any& a, error_function_t const& error_function, _Resolver& resolver, int line_number) @@ -339,14 +339,14 @@ SerializableObject::Reader::_fix_reference_ids( if (a.type() == typeid(AnyDictionary)) { _fix_reference_ids( - any_cast(a), + std::any_cast(a), error_function, resolver, line_number); } else if (a.type() == typeid(AnyVector)) { - AnyVector& child_array = any_cast(a); + AnyVector& child_array = std::any_cast(a); for (size_t i = 0; i < child_array.size(); i++) { _fix_reference_ids( @@ -358,7 +358,7 @@ SerializableObject::Reader::_fix_reference_ids( } else if (a.type() == typeid(SerializableObject::ReferenceId)) { - std::string id = any_cast(a).id; + std::string id = std::any_cast(a).id; auto e = resolver.object_for_id.find(id); if (e == resolver.object_for_id.end()) { @@ -368,7 +368,7 @@ SerializableObject::Reader::_fix_reference_ids( } else { - a = any(Retainer<>(e->second)); + a = std::any(Retainer<>(e->second)); } } } @@ -409,7 +409,7 @@ SerializableObject::Reader::_fetch( *had_null = false; } - std::swap(*dest, any_cast(e->second)); + std::swap(*dest, std::any_cast(e->second)); _dict.erase(e); return true; } @@ -426,19 +426,19 @@ SerializableObject::Reader::_fetch(std::string const& key, double* dest) if (e->second.type() == typeid(double)) { - *dest = any_cast(e->second); + *dest = std::any_cast(e->second); _dict.erase(e); return true; } else if (e->second.type() == typeid(int)) { - *dest = static_cast(any_cast(e->second)); + *dest = static_cast(std::any_cast(e->second)); _dict.erase(e); return true; } else if (e->second.type() == typeid(int64_t)) { - *dest = static_cast(any_cast(e->second)); + *dest = static_cast(std::any_cast(e->second)); _dict.erase(e); return true; } @@ -465,13 +465,13 @@ SerializableObject::Reader::_fetch(std::string const& key, int64_t* dest) if (e->second.type() == typeid(int64_t)) { - *dest = any_cast(e->second); + *dest = std::any_cast(e->second); _dict.erase(e); return true; } else if (e->second.type() == typeid(int)) { - *dest = any_cast(e->second); + *dest = std::any_cast(e->second); _dict.erase(e); return true; } @@ -515,7 +515,7 @@ SerializableObject::Reader::_fetch( return false; } - *dest = any_cast>(e->second); + *dest = std::any_cast>(e->second); _dict.erase(e); return true; } @@ -557,35 +557,35 @@ SerializableObject::Reader::_type_check_so( return true; } -any +std::any SerializableObject::Reader::_decode(_Resolver& resolver) { if (_dict.find("OTIO_SCHEMA") == _dict.end()) { - return any(std::move(_dict)); + return std::any(std::move(_dict)); } std::string schema_name_and_version; if (!_fetch("OTIO_SCHEMA", &schema_name_and_version)) { - return any(); + return std::any(); } if (schema_name_and_version == "RationalTime.1") { double rate, value; return _fetch("rate", &rate) && _fetch("value", &value) - ? any(RationalTime(value, rate)) - : any(); + ? std::any(RationalTime(value, rate)) + : std::any(); } else if (schema_name_and_version == "TimeRange.1") { RationalTime start_time, duration; return _fetch("start_time", &start_time) && _fetch("duration", &duration) - ? any(TimeRange(start_time, duration)) - : any(); + ? std::any(TimeRange(start_time, duration)) + : std::any(); } else if (schema_name_and_version == "TimeTransform.1") { @@ -593,32 +593,32 @@ SerializableObject::Reader::_decode(_Resolver& resolver) double rate, scale; return _fetch("offset", &offset) && _fetch("rate", &rate) && _fetch("scale", &scale) - ? any(TimeTransform(offset, scale, rate)) - : any(); + ? std::any(TimeTransform(offset, scale, rate)) + : std::any(); } else if (schema_name_and_version == "SerializableObjectRef.1") { std::string ref_id; if (!_fetch("id", &ref_id)) { - return any(); + return std::any(); } - return any(SerializableObject::ReferenceId{ ref_id }); + return std::any(SerializableObject::ReferenceId{ ref_id }); } else if (schema_name_and_version == "V2d.1") { double x, y; return _fetch("x", &x) && _fetch("y", &y) - ? any(IMATH_NAMESPACE::V2d(x, y)) - : any(); + ? std::any(IMATH_NAMESPACE::V2d(x, y)) + : std::any(); } else if (schema_name_and_version == "Box2d.1") { IMATH_NAMESPACE::V2d min, max; return _fetch("min", &min) && _fetch("max", &max) - ? any(IMATH_NAMESPACE::Box2d(std::move(min), std::move(max))) - : any(); + ? std::any(IMATH_NAMESPACE::Box2d(std::move(min), std::move(max))) + : std::any(); } else { @@ -627,7 +627,7 @@ SerializableObject::Reader::_decode(_Resolver& resolver) { if (!_fetch("OTIO_REF_ID", &ref_id)) { - return any(); + return std::any(); } auto e = resolver.object_for_id.find(ref_id); @@ -636,7 +636,7 @@ SerializableObject::Reader::_decode(_Resolver& resolver) _error(ErrorStatus( ErrorStatus::DUPLICATE_OBJECT_REFERENCE, ref_id)); - return any(); + return std::any(); } } @@ -654,7 +654,7 @@ SerializableObject::Reader::_decode(_Resolver& resolver) string_printf( "badly formed schema version string '%s'", schema_name_and_version.c_str()))); - return any(); + return std::any(); } ErrorStatus error_status; @@ -671,11 +671,11 @@ SerializableObject::Reader::_decode(_Resolver& resolver) } resolver.data_for_object.emplace(so, std::move(_dict)); resolver.line_number_for_object[so] = _line_number; - return any(SerializableObject::Retainer<>(so)); + return std::any(SerializableObject::Retainer<>(so)); } _error(error_status); - return any(); + return std::any(); } } @@ -763,7 +763,7 @@ template bool SerializableObject::Reader::_read_optional( std::string const& key, - optional* value) + std::optional* value) { bool had_null; T result; @@ -772,63 +772,63 @@ SerializableObject::Reader::_read_optional( return false; } - *value = had_null ? optional() : optional(result); + *value = had_null ? std::optional() : std::optional(result); return true; } bool -SerializableObject::Reader::read(std::string const& key, optional* value) +SerializableObject::Reader::read(std::string const& key, std::optional* value) { return _read_optional(key, value); } bool -SerializableObject::Reader::read(std::string const& key, optional* value) +SerializableObject::Reader::read(std::string const& key, std::optional* value) { return _read_optional(key, value); } bool SerializableObject::Reader::read( - std::string const& key, - optional* value) + std::string const& key, + std::optional* value) { return _read_optional(key, value); } bool SerializableObject::Reader::read( - std::string const& key, - optional* value) + std::string const& key, + std::optional* value) { return _read_optional(key, value); } bool SerializableObject::Reader::read( - std::string const& key, - optional* value) + std::string const& key, + std::optional* value) { return _read_optional(key, value); } bool SerializableObject::Reader::read( - std::string const& key, - optional* value) + std::string const& key, + std::optional* value) { return _read_optional(key, value); } bool SerializableObject::Reader::read( - std::string const& key, - optional* value) + std::string const& key, + std::optional* value) { return _read_optional(key, value); } bool -SerializableObject::Reader::read(std::string const& key, any* value) +SerializableObject::Reader::read(std::string const& key, std::any* value) { auto e = _dict.find(key); if (e == _dict.end()) @@ -847,7 +847,7 @@ SerializableObject::Reader::read(std::string const& key, any* value) bool deserialize_json_from_string( std::string const& input, - any* destination, + std::any* destination, ErrorStatus* error_status) { OTIO_rapidjson::Reader reader; @@ -888,7 +888,7 @@ deserialize_json_from_string( bool deserialize_json_from_file( std::string const& file_name, - any* destination, + std::any* destination, ErrorStatus* error_status) { diff --git a/src/opentimelineio/deserialization.h b/src/opentimelineio/deserialization.h index f010d0b6c..2ee044a1d 100644 --- a/src/opentimelineio/deserialization.h +++ b/src/opentimelineio/deserialization.h @@ -3,22 +3,22 @@ #pragma once -#include "opentimelineio/any.h" #include "opentimelineio/serializableObject.h" #include "opentimelineio/version.h" +#include #include namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { bool deserialize_json_from_string( std::string const& input, - any* destination, + std::any* destination, ErrorStatus* error_status = nullptr); bool deserialize_json_from_file( std::string const& file_name, - any* destination, + std::any* destination, ErrorStatus* error_status = nullptr); }} // namespace opentimelineio::OPENTIMELINEIO_VERSION diff --git a/src/opentimelineio/externalReference.cpp b/src/opentimelineio/externalReference.cpp index 9b655f194..41b6561e3 100644 --- a/src/opentimelineio/externalReference.cpp +++ b/src/opentimelineio/externalReference.cpp @@ -6,10 +6,10 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { ExternalReference::ExternalReference( - std::string const& target_url, - optional const& available_range, - AnyDictionary const& metadata, - optional const& available_image_bounds) + std::string const& target_url, + std::optional const& available_range, + AnyDictionary const& metadata, + std::optional const& available_image_bounds) : Parent(std::string(), available_range, metadata, available_image_bounds) , _target_url(target_url) {} diff --git a/src/opentimelineio/externalReference.h b/src/opentimelineio/externalReference.h index bc4dadebf..42141a222 100644 --- a/src/opentimelineio/externalReference.h +++ b/src/opentimelineio/externalReference.h @@ -20,11 +20,10 @@ class ExternalReference final : public MediaReference using Parent = MediaReference; ExternalReference( - std::string const& target_url = std::string(), - optional const& available_range = nullopt, - AnyDictionary const& metadata = AnyDictionary(), - optional const& available_image_bounds = - nullopt); + std::string const& target_url = std::string(), + std::optional const& available_range = std::nullopt, + AnyDictionary const& metadata = AnyDictionary(), + std::optional const& available_image_bounds = std::nullopt); std::string target_url() const noexcept { return _target_url; } diff --git a/src/opentimelineio/generatorReference.cpp b/src/opentimelineio/generatorReference.cpp index a75448c83..7e4c133b6 100644 --- a/src/opentimelineio/generatorReference.cpp +++ b/src/opentimelineio/generatorReference.cpp @@ -6,12 +6,12 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { GeneratorReference::GeneratorReference( - std::string const& name, - std::string const& generator_kind, - optional const& available_range, - AnyDictionary const& parameters, - AnyDictionary const& metadata, - optional const& available_image_bounds) + std::string const& name, + std::string const& generator_kind, + std::optional const& available_range, + AnyDictionary const& parameters, + AnyDictionary const& metadata, + std::optional const& available_image_bounds) : Parent(name, available_range, metadata, available_image_bounds) , _generator_kind(generator_kind) , _parameters(parameters) diff --git a/src/opentimelineio/generatorReference.h b/src/opentimelineio/generatorReference.h index f06171116..75017c816 100644 --- a/src/opentimelineio/generatorReference.h +++ b/src/opentimelineio/generatorReference.h @@ -20,13 +20,12 @@ class GeneratorReference final : public MediaReference using Parent = MediaReference; GeneratorReference( - std::string const& name = std::string(), - std::string const& generator_kind = std::string(), - optional const& available_range = nullopt, - AnyDictionary const& parameters = AnyDictionary(), - AnyDictionary const& metadata = AnyDictionary(), - optional const& available_image_bounds = - nullopt); + std::string const& name = std::string(), + std::string const& generator_kind = std::string(), + std::optional const& available_range = std::nullopt, + AnyDictionary const& parameters = AnyDictionary(), + AnyDictionary const& metadata = AnyDictionary(), + std::optional const& available_image_bounds = std::nullopt); std::string generator_kind() const noexcept { return _generator_kind; } diff --git a/src/opentimelineio/imageSequenceReference.cpp b/src/opentimelineio/imageSequenceReference.cpp index c4cdf57bc..88e956877 100644 --- a/src/opentimelineio/imageSequenceReference.cpp +++ b/src/opentimelineio/imageSequenceReference.cpp @@ -6,17 +6,17 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { ImageSequenceReference::ImageSequenceReference( - std::string const& target_url_base, - std::string const& name_prefix, - std::string const& name_suffix, - int start_frame, - int frame_step, - double rate, - int frame_zero_padding, - MissingFramePolicy const missing_frame_policy, - optional const& available_range, - AnyDictionary const& metadata, - optional const& available_image_bounds) + std::string const& target_url_base, + std::string const& name_prefix, + std::string const& name_suffix, + int start_frame, + int frame_step, + double rate, + int frame_zero_padding, + MissingFramePolicy const missing_frame_policy, + std::optional const& available_range, + AnyDictionary const& metadata, + std::optional const& available_image_bounds) : Parent(std::string(), available_range, metadata, available_image_bounds) , _target_url_base(target_url_base) , _name_prefix(name_prefix) diff --git a/src/opentimelineio/imageSequenceReference.h b/src/opentimelineio/imageSequenceReference.h index c2df5147d..176ddb560 100644 --- a/src/opentimelineio/imageSequenceReference.h +++ b/src/opentimelineio/imageSequenceReference.h @@ -27,19 +27,17 @@ class ImageSequenceReference final : public MediaReference using Parent = MediaReference; ImageSequenceReference( - std::string const& target_url_base = std::string(), - std::string const& name_prefix = std::string(), - std::string const& name_suffix = std::string(), - int start_frame = 1, - int frame_step = 1, - double rate = 1, - int frame_zero_padding = 0, - MissingFramePolicy const missing_frame_policy = - MissingFramePolicy::error, - optional const& available_range = nullopt, - AnyDictionary const& metadata = AnyDictionary(), - optional const& available_image_bounds = - nullopt); + std::string const& target_url_base = std::string(), + std::string const& name_prefix = std::string(), + std::string const& name_suffix = std::string(), + int start_frame = 1, + int frame_step = 1, + double rate = 1, + int frame_zero_padding = 0, + MissingFramePolicy const missing_frame_policy = MissingFramePolicy::error, + std::optional const& available_range = std::nullopt, + AnyDictionary const& metadata = AnyDictionary(), + std::optional const& available_image_bounds = std::nullopt); std::string target_url_base() const noexcept { return _target_url_base; } diff --git a/src/opentimelineio/item.cpp b/src/opentimelineio/item.cpp index 9ac6dfe43..2ed16f38b 100644 --- a/src/opentimelineio/item.cpp +++ b/src/opentimelineio/item.cpp @@ -11,12 +11,12 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { Item::Item( - std::string const& name, - optional const& source_range, - AnyDictionary const& metadata, - std::vector const& effects, - std::vector const& markers, - bool enabled) + std::string const& name, + std::optional const& source_range, + AnyDictionary const& metadata, + std::vector const& effects, + std::vector const& markers, + bool enabled) : Parent(name, metadata) , _source_range(source_range) , _effects(effects.begin(), effects.end()) @@ -82,7 +82,7 @@ Item::visible_range(ErrorStatus* error_status) const return result; } -optional +std::optional Item::trimmed_range_in_parent(ErrorStatus* error_status) const { if (!parent() && error_status) diff --git a/src/opentimelineio/item.h b/src/opentimelineio/item.h index 570deacfa..0cce7a7e9 100644 --- a/src/opentimelineio/item.h +++ b/src/opentimelineio/item.h @@ -6,7 +6,6 @@ #include "opentime/timeRange.h" #include "opentimelineio/composable.h" #include "opentimelineio/errorStatus.h" -#include "opentimelineio/optional.h" #include "opentimelineio/version.h" namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { @@ -26,12 +25,12 @@ class Item : public Composable using Parent = Composable; Item( - std::string const& name = std::string(), - optional const& source_range = nullopt, - AnyDictionary const& metadata = AnyDictionary(), - std::vector const& effects = std::vector(), - std::vector const& markers = std::vector(), - bool enabled = true); + std::string const& name = std::string(), + std::optional const& source_range = std::nullopt, + AnyDictionary const& metadata = AnyDictionary(), + std::vector const& effects = std::vector(), + std::vector const& markers = std::vector(), + bool enabled = true); bool visible() const override; bool overlapping() const override; @@ -40,9 +39,9 @@ class Item : public Composable void set_enabled(bool enabled) { _enabled = enabled; } - optional source_range() const noexcept { return _source_range; } + std::optional source_range() const noexcept { return _source_range; } - void set_source_range(optional const& source_range) + void set_source_range(std::optional const& source_range) { _source_range = source_range; } @@ -73,7 +72,7 @@ class Item : public Composable TimeRange visible_range(ErrorStatus* error_status = nullptr) const; - optional + std::optional trimmed_range_in_parent(ErrorStatus* error_status = nullptr) const; TimeRange range_in_parent(ErrorStatus* error_status = nullptr) const; @@ -95,7 +94,7 @@ class Item : public Composable void write_to(Writer&) const override; private: - optional _source_range; + std::optional _source_range; std::vector> _effects; std::vector> _markers; bool _enabled; diff --git a/src/opentimelineio/mediaReference.cpp b/src/opentimelineio/mediaReference.cpp index ed4baa94f..8cb1f9e30 100644 --- a/src/opentimelineio/mediaReference.cpp +++ b/src/opentimelineio/mediaReference.cpp @@ -6,10 +6,10 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { MediaReference::MediaReference( - std::string const& name, - optional const& available_range, - AnyDictionary const& metadata, - optional const& available_image_bounds) + std::string const& name, + std::optional const& available_range, + AnyDictionary const& metadata, + std::optional const& available_image_bounds) : Parent(name, metadata) , _available_range(available_range) , _available_image_bounds(available_image_bounds) diff --git a/src/opentimelineio/mediaReference.h b/src/opentimelineio/mediaReference.h index d062e3f5e..514ef3ec4 100644 --- a/src/opentimelineio/mediaReference.h +++ b/src/opentimelineio/mediaReference.h @@ -24,31 +24,30 @@ class MediaReference : public SerializableObjectWithMetadata using Parent = SerializableObjectWithMetadata; MediaReference( - std::string const& name = std::string(), - optional const& available_range = nullopt, - AnyDictionary const& metadata = AnyDictionary(), - optional const& available_image_bounds = - nullopt); + std::string const& name = std::string(), + std::optional const& available_range = std::nullopt, + AnyDictionary const& metadata = AnyDictionary(), + std::optional const& available_image_bounds = std::nullopt); - optional available_range() const noexcept + std::optional available_range() const noexcept { return _available_range; } - void set_available_range(optional const& available_range) + void set_available_range(std::optional const& available_range) { _available_range = available_range; } virtual bool is_missing_reference() const; - optional available_image_bounds() const + std::optional available_image_bounds() const { return _available_image_bounds; } void set_available_image_bounds( - optional const& available_image_bounds) + std::optional const& available_image_bounds) { _available_image_bounds = available_image_bounds; } @@ -60,8 +59,8 @@ class MediaReference : public SerializableObjectWithMetadata void write_to(Writer&) const override; private: - optional _available_range; - optional _available_image_bounds; + std::optional _available_range; + std::optional _available_image_bounds; }; }} // namespace opentimelineio::OPENTIMELINEIO_VERSION diff --git a/src/opentimelineio/missingReference.cpp b/src/opentimelineio/missingReference.cpp index 3109ae9aa..fc901505d 100644 --- a/src/opentimelineio/missingReference.cpp +++ b/src/opentimelineio/missingReference.cpp @@ -6,10 +6,10 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { MissingReference::MissingReference( - std::string const& name, - optional const& available_range, - AnyDictionary const& metadata, - optional const& available_image_bounds) + std::string const& name, + std::optional const& available_range, + AnyDictionary const& metadata, + std::optional const& available_image_bounds) : Parent(name, available_range, metadata, available_image_bounds) {} diff --git a/src/opentimelineio/missingReference.h b/src/opentimelineio/missingReference.h index ffc486a83..63cfd3a6a 100644 --- a/src/opentimelineio/missingReference.h +++ b/src/opentimelineio/missingReference.h @@ -20,11 +20,10 @@ class MissingReference final : public MediaReference using Parent = MediaReference; MissingReference( - std::string const& name = std::string(), - optional const& available_range = nullopt, - AnyDictionary const& metadata = AnyDictionary(), - optional const& available_image_bounds = - nullopt); + std::string const& name = std::string(), + std::optional const& available_range = std::nullopt, + AnyDictionary const& metadata = AnyDictionary(), + std::optional const& available_image_bounds = std::nullopt); bool is_missing_reference() const override; diff --git a/src/opentimelineio/optional.h b/src/opentimelineio/optional.h deleted file mode 100644 index 8b8521b04..000000000 --- a/src/opentimelineio/optional.h +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright Contributors to the OpenTimelineIO project - -#pragma once - -#include "nonstd/optional.hpp" -#include "opentimelineio/version.h" - -namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { - -using nonstd::nullopt; -using nonstd::nullopt_t; -using nonstd::optional; - -}} // namespace opentimelineio::OPENTIMELINEIO_VERSION diff --git a/src/opentimelineio/safely_typed_any.cpp b/src/opentimelineio/safely_typed_any.cpp index 751429bb5..d549b5ac5 100644 --- a/src/opentimelineio/safely_typed_any.cpp +++ b/src/opentimelineio/safely_typed_any.cpp @@ -5,184 +5,184 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { -any +std::any create_safely_typed_any(bool&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(int&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(int64_t&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(uint64_t&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(double&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(std::string&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(RationalTime&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(TimeRange&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(TimeTransform&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(IMATH_NAMESPACE::V2d&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(IMATH_NAMESPACE::Box2d&& value) { - return any(value); + return std::any(value); } -any +std::any create_safely_typed_any(AnyVector&& value) { - return any(std::move(value)); + return std::any(std::move(value)); } -any +std::any create_safely_typed_any(AnyDictionary&& value) { - return any(std::move(value)); + return std::any(std::move(value)); } -any +std::any create_safely_typed_any(SerializableObject* value) { - return any(SerializableObject::Retainer<>(value)); + return std::any(SerializableObject::Retainer<>(value)); } bool -safely_cast_bool_any(any const& a) +safely_cast_bool_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } int -safely_cast_int_any(any const& a) +safely_cast_int_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } int64_t -safely_cast_int64_any(any const& a) +safely_cast_int64_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } uint64_t -safely_cast_uint64_any(any const& a) +safely_cast_uint64_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } double -safely_cast_double_any(any const& a) +safely_cast_double_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } std::string -safely_cast_string_any(any const& a) +safely_cast_string_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } RationalTime -safely_cast_rational_time_any(any const& a) +safely_cast_rational_time_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } TimeRange -safely_cast_time_range_any(any const& a) +safely_cast_time_range_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } TimeTransform -safely_cast_time_transform_any(any const& a) +safely_cast_time_transform_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } IMATH_NAMESPACE::V2d -safely_cast_point_any(any const& a) +safely_cast_point_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } IMATH_NAMESPACE::Box2d -safely_cast_box_any(any const& a) +safely_cast_box_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } AnyDictionary -safely_cast_any_dictionary_any(any const& a) +safely_cast_any_dictionary_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } AnyVector -safely_cast_any_vector_any(any const& a) +safely_cast_any_vector_any(std::any const& a) { - return any_cast(a); + return std::any_cast(a); } SerializableObject* -safely_cast_retainer_any(any const& a) +safely_cast_retainer_any(std::any const& a) { - return any_cast const&>(a); + return std::any_cast const&>(a); } AnyVector& -temp_safely_cast_any_vector_any(any const& a) +temp_safely_cast_any_vector_any(std::any const& a) { - return const_cast(any_cast(a)); + return const_cast(std::any_cast(a)); } AnyDictionary& -temp_safely_cast_any_dictionary_any(any const& a) +temp_safely_cast_any_dictionary_any(std::any const& a) { - return const_cast(any_cast(a)); + return const_cast(std::any_cast(a)); } }} // namespace opentimelineio::OPENTIMELINEIO_VERSION diff --git a/src/opentimelineio/safely_typed_any.h b/src/opentimelineio/safely_typed_any.h index 75ff1b1b2..6eae1c541 100644 --- a/src/opentimelineio/safely_typed_any.h +++ b/src/opentimelineio/safely_typed_any.h @@ -27,40 +27,40 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { -any create_safely_typed_any(bool&&); -any create_safely_typed_any(int&&); -any create_safely_typed_any(int64_t&&); -any create_safely_typed_any(uint64_t&&); -any create_safely_typed_any(double&&); -any create_safely_typed_any(std::string&&); -any create_safely_typed_any(RationalTime&&); -any create_safely_typed_any(TimeRange&&); -any create_safely_typed_any(TimeTransform&&); -any create_safely_typed_any(IMATH_NAMESPACE::V2d&&); -any create_safely_typed_any(IMATH_NAMESPACE::Box2d&&); -any create_safely_typed_any(AnyVector&&); -any create_safely_typed_any(AnyDictionary&&); -any create_safely_typed_any(SerializableObject*); +std::any create_safely_typed_any(bool&&); +std::any create_safely_typed_any(int&&); +std::any create_safely_typed_any(int64_t&&); +std::any create_safely_typed_any(uint64_t&&); +std::any create_safely_typed_any(double&&); +std::any create_safely_typed_any(std::string&&); +std::any create_safely_typed_any(RationalTime&&); +std::any create_safely_typed_any(TimeRange&&); +std::any create_safely_typed_any(TimeTransform&&); +std::any create_safely_typed_any(IMATH_NAMESPACE::V2d&&); +std::any create_safely_typed_any(IMATH_NAMESPACE::Box2d&&); +std::any create_safely_typed_any(AnyVector&&); +std::any create_safely_typed_any(AnyDictionary&&); +std::any create_safely_typed_any(SerializableObject*); -bool safely_cast_bool_any(any const& a); -int safely_cast_int_any(any const& a); -int64_t safely_cast_int64_any(any const& a); -uint64_t safely_cast_uint64_any(any const& a); -double safely_cast_double_any(any const& a); -std::string safely_cast_string_any(any const& a); -RationalTime safely_cast_rational_time_any(any const& a); -TimeRange safely_cast_time_range_any(any const& a); -TimeTransform safely_cast_time_transform_any(any const& a); -IMATH_NAMESPACE::V2d safely_cast_point_any(any const& a); -IMATH_NAMESPACE::Box2d safely_cast_box_any(any const& a); +bool safely_cast_bool_any(std::any const& a); +int safely_cast_int_any(std::any const& a); +int64_t safely_cast_int64_any(std::any const& a); +uint64_t safely_cast_uint64_any(std::any const& a); +double safely_cast_double_any(std::any const& a); +std::string safely_cast_string_any(std::any const& a); +RationalTime safely_cast_rational_time_any(std::any const& a); +TimeRange safely_cast_time_range_any(std::any const& a); +TimeTransform safely_cast_time_transform_any(std::any const& a); +IMATH_NAMESPACE::V2d safely_cast_point_any(std::any const& a); +IMATH_NAMESPACE::Box2d safely_cast_box_any(std::any const& a); -SerializableObject* safely_cast_retainer_any(any const& a); +SerializableObject* safely_cast_retainer_any(std::any const& a); -AnyDictionary safely_cast_any_dictionary_any(any const& a); -AnyVector safely_cast_any_vector_any(any const& a); +AnyDictionary safely_cast_any_dictionary_any(std::any const& a); +AnyVector safely_cast_any_vector_any(std::any const& a); // don't use these unless you know what you're doing... -AnyDictionary& temp_safely_cast_any_dictionary_any(any const& a); -AnyVector& temp_safely_cast_any_vector_any(any const& a); +AnyDictionary& temp_safely_cast_any_dictionary_any(std::any const& a); +AnyVector& temp_safely_cast_any_vector_any(std::any const& a); }} // namespace opentimelineio::OPENTIMELINEIO_VERSION diff --git a/src/opentimelineio/serializableCollection.cpp b/src/opentimelineio/serializableCollection.cpp index def0014e5..431afb238 100644 --- a/src/opentimelineio/serializableCollection.cpp +++ b/src/opentimelineio/serializableCollection.cpp @@ -106,9 +106,9 @@ SerializableCollection::write_to(Writer& writer) const std::vector> SerializableCollection::find_clips( - ErrorStatus* error_status, - optional const& search_range, - bool shallow_search) const + ErrorStatus* error_status, + std::optional const& search_range, + bool shallow_search) const { return find_children(error_status, search_range, shallow_search); } diff --git a/src/opentimelineio/serializableCollection.h b/src/opentimelineio/serializableCollection.h index f36ae2610..45da16129 100644 --- a/src/opentimelineio/serializableCollection.h +++ b/src/opentimelineio/serializableCollection.h @@ -58,9 +58,9 @@ class SerializableCollection : public SerializableObjectWithMetadata // // The search is recursive unless shallow_search is set to true. std::vector> find_clips( - ErrorStatus* error_status = nullptr, - optional const& search_range = nullopt, - bool shallow_search = false) const; + ErrorStatus* error_status = nullptr, + std::optional const& search_range = std::nullopt, + bool shallow_search = false) const; // Find child objects that match the given template type. // @@ -69,9 +69,9 @@ class SerializableCollection : public SerializableObjectWithMetadata // The search is recursive unless shallow_search is set to true. template std::vector> find_children( - ErrorStatus* error_status = nullptr, - optional search_range = nullopt, - bool shallow_search = false) const; + ErrorStatus* error_status = nullptr, + std::optional search_range = std::nullopt, + bool shallow_search = false) const; protected: virtual ~SerializableCollection(); @@ -86,9 +86,9 @@ class SerializableCollection : public SerializableObjectWithMetadata template inline std::vector> SerializableCollection::find_children( - ErrorStatus* error_status, - optional search_range, - bool shallow_search) const + ErrorStatus* error_status, + std::optional search_range, + bool shallow_search) const { std::vector> out; for (const auto& child: _children) diff --git a/src/opentimelineio/serializableObject.cpp b/src/opentimelineio/serializableObject.cpp index dfad434a8..e7872b1c3 100644 --- a/src/opentimelineio/serializableObject.cpp +++ b/src/opentimelineio/serializableObject.cpp @@ -26,7 +26,7 @@ SerializableObject::Reader::fwd_type_name_for_error_message( return type_name_for_error_message(t); } std::string -SerializableObject::Reader::fwd_type_name_for_error_message(any const& a) +SerializableObject::Reader::fwd_type_name_for_error_message(std::any const& a) { return type_name_for_error_message(a); } @@ -119,7 +119,7 @@ SerializableObject::to_json_string( int indent) const { return serialize_json_to_string( - any(Retainer<>(this)), + std::any(Retainer<>(this)), schema_version_targets, error_status, indent); @@ -133,7 +133,7 @@ SerializableObject::to_json_file( int indent) const { return serialize_json_to_file( - any(Retainer<>(this)), + std::any(Retainer<>(this)), file_name, schema_version_targets, error_status, @@ -145,7 +145,7 @@ SerializableObject::from_json_string( std::string const& input, ErrorStatus* error_status) { - any dest; + std::any dest; if (!deserialize_json_from_string(input, &dest, error_status)) { @@ -165,7 +165,7 @@ SerializableObject::from_json_string( return nullptr; } - return any_cast&>(dest).take_value(); + return std::any_cast&>(dest).take_value(); } SerializableObject* @@ -173,7 +173,7 @@ SerializableObject::from_json_file( std::string const& file_name, ErrorStatus* error_status) { - any dest; + std::any dest; if (!deserialize_json_from_file(file_name, &dest, error_status)) { @@ -193,7 +193,7 @@ SerializableObject::from_json_file( return nullptr; } - return any_cast&>(dest).take_value(); + return std::any_cast&>(dest).take_value(); } std::string diff --git a/src/opentimelineio/serializableObject.h b/src/opentimelineio/serializableObject.h index f54a6362b..63ccc0438 100644 --- a/src/opentimelineio/serializableObject.h +++ b/src/opentimelineio/serializableObject.h @@ -9,7 +9,6 @@ #include "opentimelineio/anyDictionary.h" #include "opentimelineio/anyVector.h" #include "opentimelineio/errorStatus.h" -#include "opentimelineio/optional.h" #include "opentimelineio/typeRegistry.h" #include "opentimelineio/version.h" @@ -17,6 +16,7 @@ #include "serialization.h" #include +#include #include namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { @@ -101,28 +101,29 @@ class SerializableObject bool read(std::string const& key, IMATH_NAMESPACE::Box2d* value); bool read(std::string const& key, AnyVector* dest); bool read(std::string const& key, AnyDictionary* dest); - bool read(std::string const& key, any* dest); - - bool read(std::string const& key, optional* dest); - bool read(std::string const& key, optional* dest); - bool read(std::string const& key, optional* dest); - bool read(std::string const& key, optional* dest); - bool read(std::string const& key, optional* dest); - bool read(std::string const& key, optional* dest); - bool - read(std::string const& key, optional* value); + bool read(std::string const& key, std::any* dest); + + bool read(std::string const& key, std::optional* dest); + bool read(std::string const& key, std::optional* dest); + bool read(std::string const& key, std::optional* dest); + bool read(std::string const& key, std::optional* dest); + bool read(std::string const& key, std::optional* dest); + bool read(std::string const& key, std::optional* dest); + bool read( + std::string const& key, + std::optional* value); // skipping std::string because we translate null into the empty // string, so the conversion is somewhat ambiguous - // no other optionals are allowed: + // no other std::optionals are allowed: template - bool read(std::string const& key, optional* dest) = delete; + bool read(std::string const& key, std::optional* dest) = delete; template bool read(std::string const& key, T* dest) { - any a; + std::any a; return read(key, &a) && _from_any(a, dest); } @@ -176,7 +177,7 @@ class SerializableObject // forward functions to keep stringUtils.h private static std::string fwd_type_name_for_error_message(std::type_info const&); - static std::string fwd_type_name_for_error_message(any const& a); + static std::string fwd_type_name_for_error_message(std::any const& a); static std::string fwd_type_name_for_error_message(class SerializableObject*); @@ -202,17 +203,17 @@ class SerializableObject } }; - any _decode(_Resolver& resolver); + std::any _decode(_Resolver& resolver); template - bool _from_any(any const& source, std::vector* dest) + bool _from_any(std::any const& source, std::vector* dest) { if (!_type_check(typeid(AnyVector), source.type())) { return false; } - AnyVector const& av = any_cast(source); + AnyVector const& av = std::any_cast(source); std::vector result; result.reserve(av.size()); @@ -232,14 +233,14 @@ class SerializableObject } template - bool _from_any(any const& source, std::list* dest) + bool _from_any(std::any const& source, std::list* dest) { if (!_type_check(typeid(AnyVector), source.type())) { return false; } - AnyVector const& av = any_cast(source); + AnyVector const& av = std::any_cast(source); std::list result; for (auto e: av) @@ -258,14 +259,15 @@ class SerializableObject } template - bool _from_any(any const& source, std::map* dest) + bool _from_any(std::any const& source, std::map* dest) { if (!_type_check(typeid(AnyDictionary), source.type())) { return false; } - AnyDictionary const& dict = any_cast(source); + AnyDictionary const& dict = + std::any_cast(source); std::map result; for (auto e: dict) @@ -284,7 +286,7 @@ class SerializableObject } template - bool _from_any(any const& source, T** dest) + bool _from_any(std::any const& source, T** dest) { if (source.type() == typeid(void)) { @@ -298,7 +300,7 @@ class SerializableObject } SerializableObject* so = - any_cast>(source).value; + std::any_cast>(source).value; if (!so) { *dest = nullptr; @@ -316,14 +318,14 @@ class SerializableObject } template - bool _from_any(any const& source, Retainer* dest) + bool _from_any(std::any const& source, Retainer* dest) { if (!_type_check_so(typeid(Retainer<>), source.type(), typeid(T))) { return false; } - Retainer<> const& rso = any_cast const&>(source); + Retainer<> const& rso = std::any_cast const&>(source); if (!rso.value) { *dest = Retainer(nullptr); @@ -340,14 +342,14 @@ class SerializableObject } template - bool _from_any(any const& source, T* dest) + bool _from_any(std::any const& source, T* dest) { if (!_type_check(typeid(T), source.type())) { return false; } - *dest = any_cast(source); + *dest = std::any_cast(source); return true; } @@ -363,7 +365,7 @@ class SerializableObject bool _fetch(std::string const& key, T* dest, bool* had_null = nullptr); template - bool _read_optional(std::string const& key, optional* value); + bool _read_optional(std::string const& key, std::optional* value); bool _fetch(std::string const& key, int64_t* dest); bool _fetch(std::string const& key, double* dest); @@ -381,7 +383,7 @@ class SerializableObject _Resolver&, int line_number); static void _fix_reference_ids( - any&, + std::any&, error_function_t const& error_function, _Resolver&, int line_number); @@ -405,7 +407,7 @@ class SerializableObject { public: static bool write_root( - any const& value, + std::any const& value, class Encoder& encoder, const schema_version_map* downgrade_version_manifest = nullptr, ErrorStatus* error_status = nullptr); @@ -418,10 +420,11 @@ class SerializableObject void write(std::string const& key, TimeRange value); void write(std::string const& key, IMATH_NAMESPACE::V2d value); void write(std::string const& key, IMATH_NAMESPACE::Box2d value); - void write(std::string const& key, optional value); - void write(std::string const& key, optional value); - void - write(std::string const& key, optional value); + void write(std::string const& key, std::optional value); + void write(std::string const& key, std::optional value); + void write( + std::string const& key, + std::optional value); void write(std::string const& key, class TimeTransform value); void write(std::string const& key, SerializableObject const* value); void write(std::string const& key, SerializableObject* value) @@ -430,7 +433,7 @@ class SerializableObject } void write(std::string const& key, AnyDictionary const& value); void write(std::string const& key, AnyVector const& value); - void write(std::string const& key, any const& value); + void write(std::string const& key, std::any const& value); template void write(std::string const& key, T const& value) @@ -447,10 +450,10 @@ class SerializableObject private: ///@{ /** Convience routines for converting various STL structures of specific - types to a parallel hierarchy holding anys!. */ + types to a parallel hierarchy holding std::anys!. */ template - static any _to_any(std::vector const& value) + static std::any _to_any(std::vector const& value) { AnyVector av; av.reserve(value.size()); @@ -460,11 +463,11 @@ class SerializableObject av.emplace_back(_to_any(e)); } - return any(std::move(av)); + return std::any(std::move(av)); } template - static any _to_any(std::map const& value) + static std::any _to_any(std::map const& value) { AnyDictionary am; for (const auto& e: value) @@ -472,11 +475,11 @@ class SerializableObject am.emplace(e.first, _to_any(e.second)); } - return any(std::move(am)); + return std::any(std::move(am)); } template - static any _to_any(std::list const& value) + static std::any _to_any(std::list const& value) { AnyVector av; av.reserve(value.size()); @@ -486,34 +489,34 @@ class SerializableObject av.emplace_back(_to_any(e)); } - return any(std::move(av)); + return std::any(std::move(av)); } template - static any _to_any(T const* value) + static std::any _to_any(T const* value) { SerializableObject* so = (SerializableObject*) value; - return any(SerializableObject::Retainer<>(so)); + return std::any(SerializableObject::Retainer<>(so)); } template - static any _to_any(T* value) + static std::any _to_any(T* value) { SerializableObject* so = (SerializableObject*) value; - return any(SerializableObject::Retainer<>(so)); + return std::any(SerializableObject::Retainer<>(so)); } template - static any _to_any(Retainer const& value) + static std::any _to_any(Retainer const& value) { SerializableObject* so = value.value; - return any(SerializableObject::Retainer<>(so)); + return std::any(SerializableObject::Retainer<>(so)); } template - static any _to_any(T const& value) + static std::any _to_any(T const& value) { - return any(value); + return std::any(value); } ///@} @@ -533,24 +536,24 @@ class SerializableObject Writer operator=(Writer const&) = delete; void _build_dispatch_tables(); - void _write(std::string const& key, any const& value); + void _write(std::string const& key, std::any const& value); void _encoder_write_key(std::string const& key); - bool _any_dict_equals(any const& lhs, any const& rhs); - bool _any_array_equals(any const& lhs, any const& rhs); - bool _any_equals(any const& lhs, any const& rhs); + bool _any_dict_equals(std::any const& lhs, std::any const& rhs); + bool _any_array_equals(std::any const& lhs, std::any const& rhs); + bool _any_equals(std::any const& lhs, std::any const& rhs); std::string _no_key; std::unordered_map< std::type_info const*, - std::function> + std::function> _write_dispatch_table; std::unordered_map< std::type_info const*, - std::function> + std::function> _equality_dispatch_table; - std::unordered_map> + std::unordered_map> _write_dispatch_table_by_name; std::unordered_map _id_for_object; diff --git a/src/opentimelineio/serialization.cpp b/src/opentimelineio/serialization.cpp index bb7051eea..7ff58bf6b 100644 --- a/src/opentimelineio/serialization.cpp +++ b/src/opentimelineio/serialization.cpp @@ -3,7 +3,6 @@ #include "opentimelineio/serialization.h" #include "errorStatus.h" -#include "nonstd/optional.hpp" #include "opentimelineio/anyDictionary.h" #include "opentimelineio/serializableObject.h" #include "opentimelineio/unknownSchema.h" @@ -148,7 +147,7 @@ class CloningEncoder : public Encoder if (_stack.size() == 1) { - any newstack(std::move(a)); + std::any newstack(std::move(a)); _root.swap(newstack); } else @@ -161,13 +160,13 @@ class CloningEncoder : public Encoder } else { - any newstack(std::move(a)); + std::any newstack(std::move(a)); top.array.emplace_back(newstack); } } } - void _store(any&& a) + void _store(std::any&& a) { if (has_errored()) { @@ -192,13 +191,13 @@ class CloningEncoder : public Encoder } } - void write_null_value() override { _store(any()); } - void write_value(bool value) override { _store(any(value)); } - void write_value(int value) override { _store(any(value)); } - void write_value(int64_t value) override { _store(any(value)); } - void write_value(uint64_t value) override { _store(any(value)); } - void write_value(std::string const& value) override { _store(any(value)); } - void write_value(double value) override { _store(any(value)); } + void write_null_value() override { _store(std::any()); } + void write_value(bool value) override { _store(std::any(value)); } + void write_value(int value) override { _store(std::any(value)); } + void write_value(int64_t value) override { _store(std::any(value)); } + void write_value(uint64_t value) override { _store(std::any(value)); } + void write_value(std::string const& value) override { _store(std::any(value)); } + void write_value(double value) override { _store(std::any(value)); } void write_value(RationalTime const& value) override { @@ -209,11 +208,11 @@ class CloningEncoder : public Encoder { "value", value.value() }, { "rate", value.rate() }, }; - _store(any(std::move(result))); + _store(std::any(std::move(result))); } else { - _store(any(value)); + _store(std::any(value)); } } void write_value(TimeRange const& value) override @@ -226,11 +225,11 @@ class CloningEncoder : public Encoder { "duration", value.duration() }, { "start_time", value.start_time() }, }; - _store(any(std::move(result))); + _store(std::any(std::move(result))); } else { - _store(any(value)); + _store(std::any(value)); } } void write_value(TimeTransform const& value) override @@ -243,11 +242,11 @@ class CloningEncoder : public Encoder { "rate", value.rate() }, { "scale", value.scale() }, }; - _store(any(std::move(result))); + _store(std::any(std::move(result))); } else { - _store(any(value)); + _store(std::any(value)); } } void write_value(SerializableObject::ReferenceId value) override @@ -258,13 +257,13 @@ class CloningEncoder : public Encoder { "OTIO_SCHEMA", "SerializableObjectRef.1" }, { "id", value.id.c_str() }, }; - _store(any(std::move(result))); + _store(std::any(std::move(result))); } else { - _store(any(value)); + _store(std::any(value)); } - _store(any(value)); + _store(std::any(value)); } void write_value(IMATH_NAMESPACE::V2d const& value) @@ -277,11 +276,11 @@ class CloningEncoder : public Encoder { "x", value.x }, { "y", value.y }, }; - _store(any(std::move(result))); + _store(std::any(std::move(result))); } else { - _store(any(value)); + _store(std::any(value)); } } @@ -294,11 +293,11 @@ class CloningEncoder : public Encoder { "min", value.min }, { "max", value.max }, }; - _store(any(std::move(result))); + _store(std::any(std::move(result))); } else { - _store(any(value)); + _store(std::any(value)); } } // @} @@ -349,7 +348,7 @@ class CloningEncoder : public Encoder AnyVector va; va.swap(top.array); _stack.pop_back(); - _store(any(std::move(va))); + _store(std::any(std::move(va))); } } } @@ -407,7 +406,7 @@ class CloningEncoder : public Encoder } private: - any _root; + std::any _root; SerializableObject::Reader::_Resolver _resolver; std::function _error_function; @@ -635,26 +634,28 @@ class JSONEncoder : public Encoder template bool -_simple_any_comparison(any const& lhs, any const& rhs) +_simple_any_comparison(std::any const& lhs, std::any const& rhs) { return lhs.type() == typeid(T) && rhs.type() == typeid(T) - && any_cast(lhs) == any_cast(rhs); + && std::any_cast(lhs) == std::any_cast(rhs); } template <> bool -_simple_any_comparison(any const& lhs, any const& rhs) +_simple_any_comparison(std::any const& lhs, std::any const& rhs) { return lhs.type() == typeid(void) && rhs.type() == typeid(void); } template <> bool -_simple_any_comparison(any const& lhs, any const& rhs) +_simple_any_comparison(std::any const& lhs, std::any const& rhs) { return lhs.type() == typeid(char const*) && rhs.type() == typeid(char const*) - && !strcmp(any_cast(lhs), any_cast(rhs)); + && !strcmp( + std::any_cast(lhs), + std::any_cast(rhs)); } void @@ -665,51 +666,53 @@ SerializableObject::Writer::_build_dispatch_tables() */ auto& wt = _write_dispatch_table; - wt[&typeid(void)] = [this](any const&) { _encoder.write_null_value(); }; - wt[&typeid(bool)] = [this](any const& value) { - _encoder.write_value(any_cast(value)); + wt[&typeid(void)] = [this](std::any const&) { + _encoder.write_null_value(); + }; + wt[&typeid(bool)] = [this](std::any const& value) { + _encoder.write_value(std::any_cast(value)); }; - wt[&typeid(int64_t)] = [this](any const& value) { - _encoder.write_value(any_cast(value)); + wt[&typeid(int64_t)] = [this](std::any const& value) { + _encoder.write_value(std::any_cast(value)); }; - wt[&typeid(double)] = [this](any const& value) { - _encoder.write_value(any_cast(value)); + wt[&typeid(double)] = [this](std::any const& value) { + _encoder.write_value(std::any_cast(value)); }; - wt[&typeid(std::string)] = [this](any const& value) { - _encoder.write_value(any_cast(value)); + wt[&typeid(std::string)] = [this](std::any const& value) { + _encoder.write_value(std::any_cast(value)); }; - wt[&typeid(char const*)] = [this](any const& value) { - _encoder.write_value(std::string(any_cast(value))); + wt[&typeid(char const*)] = [this](std::any const& value) { + _encoder.write_value(std::string(std::any_cast(value))); }; - wt[&typeid(RationalTime)] = [this](any const& value) { - _encoder.write_value(any_cast(value)); + wt[&typeid(RationalTime)] = [this](std::any const& value) { + _encoder.write_value(std::any_cast(value)); }; - wt[&typeid(TimeRange)] = [this](any const& value) { - _encoder.write_value(any_cast(value)); + wt[&typeid(TimeRange)] = [this](std::any const& value) { + _encoder.write_value(std::any_cast(value)); }; - wt[&typeid(TimeTransform)] = [this](any const& value) { - _encoder.write_value(any_cast(value)); + wt[&typeid(TimeTransform)] = [this](std::any const& value) { + _encoder.write_value(std::any_cast(value)); }; - wt[&typeid(IMATH_NAMESPACE::V2d)] = [this](any const& value) { - _encoder.write_value(any_cast(value)); + wt[&typeid(IMATH_NAMESPACE::V2d)] = [this](std::any const& value) { + _encoder.write_value(std::any_cast(value)); }; - wt[&typeid(IMATH_NAMESPACE::Box2d)] = [this](any const& value) { - _encoder.write_value(any_cast(value)); + wt[&typeid(IMATH_NAMESPACE::Box2d)] = [this](std::any const& value) { + _encoder.write_value(std::any_cast(value)); }; /* * These next recurse back through the Writer itself: */ - wt[&typeid(SerializableObject::Retainer<>)] = [this](any const& value) { - this->write(_no_key, any_cast>(value)); + wt[&typeid(SerializableObject::Retainer<>)] = [this](std::any const& value) { + this->write(_no_key, std::any_cast>(value)); }; - wt[&typeid(AnyDictionary)] = [this](any const& value) { - this->write(_no_key, any_cast(value)); + wt[&typeid(AnyDictionary)] = [this](std::any const& value) { + this->write(_no_key, std::any_cast(value)); }; - wt[&typeid(AnyVector)] = [this](any const& value) { - this->write(_no_key, any_cast(value)); + wt[&typeid(AnyVector)] = [this](std::any const& value) { + this->write(_no_key, std::any_cast(value)); }; /* @@ -741,16 +744,18 @@ SerializableObject::Writer::_build_dispatch_tables() /* * These next recurse back through the Writer itself: */ - et[&typeid(AnyDictionary)] = [this](any const& lhs, any const& rhs) { + et[&typeid(AnyDictionary)] = [this](std::any const& lhs, std::any const& rhs) { return _any_dict_equals(lhs, rhs); }; - et[&typeid(AnyVector)] = [this](any const& lhs, any const& rhs) { + et[&typeid(AnyVector)] = [this](std::any const& lhs, std::any const& rhs) { return _any_array_equals(lhs, rhs); }; } bool -SerializableObject::Writer::_any_dict_equals(any const& lhs, any const& rhs) +SerializableObject::Writer::_any_dict_equals( + std::any const& lhs, + std::any const& rhs) { if (lhs.type() != typeid(AnyDictionary) || rhs.type() != typeid(AnyDictionary)) @@ -758,8 +763,8 @@ SerializableObject::Writer::_any_dict_equals(any const& lhs, any const& rhs) return false; } - AnyDictionary const& ld = any_cast(lhs); - AnyDictionary const& rd = any_cast(rhs); + AnyDictionary const& ld = std::any_cast(lhs); + AnyDictionary const& rd = std::any_cast(rhs); auto r_it = rd.begin(); @@ -781,15 +786,17 @@ SerializableObject::Writer::_any_dict_equals(any const& lhs, any const& rhs) } bool -SerializableObject::Writer::_any_array_equals(any const& lhs, any const& rhs) +SerializableObject::Writer::_any_array_equals( + std::any const& lhs, + std::any const& rhs) { if (lhs.type() != typeid(AnyVector) || rhs.type() != typeid(AnyVector)) { return false; } - AnyVector const& lv = any_cast(lhs); - AnyVector const& rv = any_cast(rhs); + AnyVector const& lv = std::any_cast(lhs); + AnyVector const& rv = std::any_cast(rhs); if (lv.size() != rv.size()) { @@ -808,7 +815,9 @@ SerializableObject::Writer::_any_array_equals(any const& lhs, any const& rhs) } bool -SerializableObject::Writer::_any_equals(any const& lhs, any const& rhs) +SerializableObject::Writer::_any_equals( + std::any const& lhs, + std::any const& rhs) { auto e = _equality_dispatch_table.find(&lhs.type()); return (e != _equality_dispatch_table.end()) && e->second(lhs, rhs); @@ -816,7 +825,7 @@ SerializableObject::Writer::_any_equals(any const& lhs, any const& rhs) bool SerializableObject::Writer::write_root( - any const& value, + std::any const& value, Encoder& encoder, const schema_version_map* schema_version_targets, ErrorStatus* error_status) @@ -881,8 +890,8 @@ SerializableObject::Writer::write(std::string const& key, TimeRange value) void SerializableObject::Writer::write( - std::string const& key, - optional value) + std::string const& key, + std::optional value) { _encoder_write_key(key); value ? _encoder.write_value(*value) : _encoder.write_null_value(); @@ -890,8 +899,8 @@ SerializableObject::Writer::write( void SerializableObject::Writer::write( - std::string const& key, - optional value) + std::string const& key, + std::optional value) { _encoder_write_key(key); value ? _encoder.write_value(*value) : _encoder.write_null_value(); @@ -899,8 +908,8 @@ SerializableObject::Writer::write( void SerializableObject::Writer::write( - std::string const& key, - optional value) + std::string const& key, + std::optional value) { _encoder_write_key(key); value ? _encoder.write_value(*value) : _encoder.write_null_value(); @@ -963,7 +972,7 @@ SerializableObject::Writer::write( const std::string& schema_name = value->schema_name(); int schema_version = value->schema_version(); - any downgraded = {}; + std::any downgraded = {}; // if there is a manifest & the encoder is not converting to AnyDictionary if ((_downgrade_version_manifest != nullptr) @@ -1034,9 +1043,9 @@ SerializableObject::Writer::write( // write the contents of the object to the encoder, either the downgraded // anydictionary or the SerializableObject - if (!(downgraded.empty())) + if (downgraded.has_value()) { - for (const auto& kv: any_cast(downgraded)) + for (const auto& kv: std::any_cast(downgraded)) { this->write(kv.first, kv.second); } @@ -1112,7 +1121,7 @@ SerializableObject::Writer::write( } void -SerializableObject::Writer::write(std::string const& key, any const& value) +SerializableObject::Writer::write(std::string const& key, std::any const& value) { std::type_info const& type = value.type(); @@ -1147,7 +1156,7 @@ SerializableObject::Writer::write(std::string const& key, any const& value) std::string s; std::string bad_type_name = (type == typeid(UnknownType)) ? type_name_for_error_message( - any_cast(value).type_name) + std::any_cast(value).type_name) : type_name_for_error_message(type); if (&key != &_no_key) @@ -1184,8 +1193,8 @@ SerializableObject::is_equivalent_to(SerializableObject const& other) const SerializableObject::Writer w1(e1, {}); SerializableObject::Writer w2(e2, {}); - w1.write(w1._no_key, any(Retainer<>(this))); - w2.write(w2._no_key, any(Retainer<>(&other))); + w1.write(w1._no_key, std::any(Retainer<>(this))); + w2.write(w2._no_key, std::any(Retainer<>(&other))); return ( !e1.has_errored() && !e2.has_errored() @@ -1199,7 +1208,7 @@ SerializableObject::clone(ErrorStatus* error_status) const CloningEncoder::ResultObjectPolicy::CloneBackToSerializableObject); SerializableObject::Writer w(e, {}); - w.write(w._no_key, any(Retainer<>(this))); + w.write(w._no_key, std::any(Retainer<>(this))); if (e.has_errored(error_status)) { return nullptr; @@ -1216,14 +1225,14 @@ SerializableObject::clone(ErrorStatus* error_status) const e._resolver.finalize(error_function); return e._root.type() == typeid(SerializableObject::Retainer<>) - ? any_cast&>(e._root).take_value() + ? std::any_cast&>(e._root).take_value() : nullptr; } // to json_string std::string serialize_json_to_string_pretty( - const any& value, + const std::any& value, const schema_version_map* schema_version_targets, ErrorStatus* error_status, int indent) @@ -1257,7 +1266,7 @@ serialize_json_to_string_pretty( // to json_string std::string serialize_json_to_string_compact( - const any& value, + const std::any& value, const schema_version_map* schema_version_targets, ErrorStatus* error_status) { @@ -1288,7 +1297,7 @@ serialize_json_to_string_compact( // to json_string std::string serialize_json_to_string( - const any& value, + const std::any& value, const schema_version_map* schema_version_targets, ErrorStatus* error_status, int indent) @@ -1309,7 +1318,7 @@ serialize_json_to_string( bool serialize_json_to_file( - any const& value, + std::any const& value, std::string const& file_name, const schema_version_map* schema_version_targets, ErrorStatus* error_status, diff --git a/src/opentimelineio/serialization.h b/src/opentimelineio/serialization.h index 2fce4dbf6..292171db8 100644 --- a/src/opentimelineio/serialization.h +++ b/src/opentimelineio/serialization.h @@ -3,25 +3,24 @@ #pragma once -#include "opentimelineio/any.h" #include "opentimelineio/errorStatus.h" #include "opentimelineio/typeRegistry.h" #include "opentimelineio/version.h" -#include +#include #include #include namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { std::string serialize_json_to_string( - const any& value, + const std::any& value, const schema_version_map* schema_version_targets = nullptr, ErrorStatus* error_status = nullptr, int indent = 4); bool serialize_json_to_file( - const any& value, + const std::any& value, std::string const& file_name, const schema_version_map* schema_version_targets = nullptr, ErrorStatus* error_status = nullptr, diff --git a/src/opentimelineio/stack.cpp b/src/opentimelineio/stack.cpp index 175ab2b46..ce10b204f 100644 --- a/src/opentimelineio/stack.cpp +++ b/src/opentimelineio/stack.cpp @@ -8,11 +8,11 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { Stack::Stack( - std::string const& name, - optional const& source_range, - AnyDictionary const& metadata, - std::vector const& effects, - std::vector const& markers) + std::string const& name, + std::optional const& source_range, + AnyDictionary const& metadata, + std::vector const& effects, + std::vector const& markers) : Parent(name, source_range, metadata, effects, markers) {} @@ -115,28 +115,28 @@ Stack::available_range(ErrorStatus* error_status) const std::vector> Stack::find_clips( - ErrorStatus* error_status, - optional const& search_range, - bool shallow_search) const + ErrorStatus* error_status, + std::optional const& search_range, + bool shallow_search) const { return find_children(error_status, search_range, shallow_search); } -optional +std::optional Stack::available_image_bounds(ErrorStatus* error_status) const { - optional box; - bool found_first_child = false; + std::optional box; + bool found_first_child = false; for (auto clip: find_children(error_status)) { - optional child_box; + std::optional child_box; if (auto clip_box = clip->available_image_bounds(error_status)) { child_box = clip_box; } if (is_error(error_status)) { - return optional(); + return std::optional(); } if (child_box) { diff --git a/src/opentimelineio/stack.h b/src/opentimelineio/stack.h index 065274308..7354774de 100644 --- a/src/opentimelineio/stack.h +++ b/src/opentimelineio/stack.h @@ -22,11 +22,11 @@ class Stack : public Composition using Parent = Composition; Stack( - std::string const& name = std::string(), - optional const& source_range = nullopt, - AnyDictionary const& metadata = AnyDictionary(), - std::vector const& effects = std::vector(), - std::vector const& markers = std::vector()); + std::string const& name = std::string(), + std::optional const& source_range = std::nullopt, + AnyDictionary const& metadata = AnyDictionary(), + std::vector const& effects = std::vector(), + std::vector const& markers = std::vector()); TimeRange range_of_child_at_index( int index, @@ -40,7 +40,7 @@ class Stack : public Composition std::map range_of_all_children(ErrorStatus* error_status = nullptr) const override; - optional + std::optional available_image_bounds(ErrorStatus* error_status) const override; // Find child clips. @@ -49,9 +49,9 @@ class Stack : public Composition // // The search is recursive unless shallow_search is set to true. std::vector> find_clips( - ErrorStatus* error_status = nullptr, - optional const& search_range = nullopt, - bool shallow_search = false) const; + ErrorStatus* error_status = nullptr, + std::optional const& search_range = std::nullopt, + bool shallow_search = false) const; protected: virtual ~Stack(); diff --git a/src/opentimelineio/stackAlgorithm.cpp b/src/opentimelineio/stackAlgorithm.cpp index 56f65bbda..774d0f9db 100644 --- a/src/opentimelineio/stackAlgorithm.cpp +++ b/src/opentimelineio/stackAlgorithm.cpp @@ -18,7 +18,7 @@ _flatten_next_item( Track* flat_track, std::vector const& tracks, int track_index, - optional trim_range, + std::optional trim_range, ErrorStatus* error_status) { if (track_index < 0) @@ -213,7 +213,7 @@ flatten_stack(Stack* in_stack, ErrorStatus* error_status) flat_track, tracks, -1, - nullopt, + std::nullopt, error_status); return flat_track; } @@ -247,7 +247,7 @@ flatten_stack(std::vector const& tracks, ErrorStatus* error_status) flat_track, flat_tracks, -1, - nullopt, + std::nullopt, error_status); return flat_track; } diff --git a/src/opentimelineio/stringUtils.cpp b/src/opentimelineio/stringUtils.cpp index f84d97765..3b3946223 100644 --- a/src/opentimelineio/stringUtils.cpp +++ b/src/opentimelineio/stringUtils.cpp @@ -50,7 +50,7 @@ type_name_for_error_message(std::type_info const& t) } std::string -type_name_for_error_message(any const& a) +type_name_for_error_message(std::any const& a) { return type_name_for_error_message(a.type()); } diff --git a/src/opentimelineio/stringUtils.h b/src/opentimelineio/stringUtils.h index 6630238a3..725abc167 100644 --- a/src/opentimelineio/stringUtils.h +++ b/src/opentimelineio/stringUtils.h @@ -4,10 +4,10 @@ #pragma once #include "opentime/stringPrintf.h" -#include "opentimelineio/any.h" #include "opentimelineio/version.h" using opentime::string_printf; +#include #include namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { @@ -15,7 +15,7 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { void fatal_error(std::string const& errMsg); std::string type_name_for_error_message(std::type_info const&); -std::string type_name_for_error_message(any const& a); +std::string type_name_for_error_message(std::any const& a); std::string type_name_for_error_message(class SerializableObject*); template diff --git a/src/opentimelineio/timeline.cpp b/src/opentimelineio/timeline.cpp index 251ae951e..d2f38571e 100644 --- a/src/opentimelineio/timeline.cpp +++ b/src/opentimelineio/timeline.cpp @@ -7,9 +7,9 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { Timeline::Timeline( - std::string const& name, - optional global_start_time, - AnyDictionary const& metadata) + std::string const& name, + std::optional global_start_time, + AnyDictionary const& metadata) : SerializableObjectWithMetadata(name, metadata) , _global_start_time(global_start_time) , _tracks(new Stack("tracks")) @@ -76,9 +76,9 @@ Timeline::audio_tracks() const std::vector> Timeline::find_clips( - ErrorStatus* error_status, - optional const& search_range, - bool shallow_search) const + ErrorStatus* error_status, + std::optional const& search_range, + bool shallow_search) const { return _tracks.value->find_clips( error_status, diff --git a/src/opentimelineio/timeline.h b/src/opentimelineio/timeline.h index 2203812e2..ab0f67500 100644 --- a/src/opentimelineio/timeline.h +++ b/src/opentimelineio/timeline.h @@ -24,9 +24,9 @@ class Timeline : public SerializableObjectWithMetadata using Parent = SerializableObjectWithMetadata; Timeline( - std::string const& name = std::string(), - optional global_start_time = nullopt, - AnyDictionary const& metadata = AnyDictionary()); + std::string const& name = std::string(), + std::optional global_start_time = std::nullopt, + AnyDictionary const& metadata = AnyDictionary()); Stack* tracks() const noexcept { return _tracks; } @@ -37,12 +37,13 @@ class Timeline : public SerializableObjectWithMetadata void set_tracks(Stack* stack); - optional global_start_time() const noexcept + std::optional global_start_time() const noexcept { return _global_start_time; } - void set_global_start_time(optional const& global_start_time) + void + set_global_start_time(std::optional const& global_start_time) { _global_start_time = global_start_time; } @@ -68,9 +69,9 @@ class Timeline : public SerializableObjectWithMetadata // // The search is recursive unless shallow_search is set to true. std::vector> find_clips( - ErrorStatus* error_status = nullptr, - optional const& search_range = nullopt, - bool shallow_search = false) const; + ErrorStatus* error_status = nullptr, + std::optional const& search_range = std::nullopt, + bool shallow_search = false) const; // Find child objects that match the given template type. // @@ -79,11 +80,11 @@ class Timeline : public SerializableObjectWithMetadata // The search is recursive unless shallow_search is set to true. template std::vector> find_children( - ErrorStatus* error_status = nullptr, - optional search_range = nullopt, - bool shallow_search = false) const; + ErrorStatus* error_status = nullptr, + std::optional search_range = std::nullopt, + bool shallow_search = false) const; - optional + std::optional available_image_bounds(ErrorStatus* error_status) const { return _tracks.value->available_image_bounds(error_status); @@ -96,16 +97,16 @@ class Timeline : public SerializableObjectWithMetadata void write_to(Writer&) const override; private: - optional _global_start_time; - Retainer _tracks; + std::optional _global_start_time; + Retainer _tracks; }; template inline std::vector> Timeline::find_children( - ErrorStatus* error_status, - optional search_range, - bool shallow_search) const + ErrorStatus* error_status, + std::optional search_range, + bool shallow_search) const { return _tracks.value->find_children( error_status, diff --git a/src/opentimelineio/track.cpp b/src/opentimelineio/track.cpp index d6a1c782a..3f81f2714 100644 --- a/src/opentimelineio/track.cpp +++ b/src/opentimelineio/track.cpp @@ -10,10 +10,10 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION { Track::Track( - std::string const& name, - optional const& source_range, - std::string const& kind, - AnyDictionary const& metadata) + std::string const& name, + std::optional const& source_range, + std::string const& kind, + AnyDictionary const& metadata) : Parent(name, source_range, metadata) , _kind(kind) {} @@ -140,12 +140,12 @@ Track::available_range(ErrorStatus* error_status) const return TimeRange(RationalTime(0, duration.rate()), duration); } -std::pair, optional> +std::pair, std::optional> Track::handles_of_child(Composable const* child, ErrorStatus* error_status) const { - optional head, tail; - auto neighbors = neighbors_of(child, error_status); + std::optional head, tail; + auto neighbors = neighbors_of(child, error_status); if (auto transition = dynamic_retainer_cast(neighbors.first)) { head = transition->in_offset(); @@ -265,18 +265,18 @@ Track::range_of_all_children(ErrorStatus* error_status) const std::vector> Track::find_clips( - ErrorStatus* error_status, - optional const& search_range, - bool shallow_search) const + ErrorStatus* error_status, + std::optional const& search_range, + bool shallow_search) const { return find_children(error_status, search_range, shallow_search); } -optional +std::optional Track::available_image_bounds(ErrorStatus* error_status) const { - optional box; - bool found_first_clip = false; + std::optional box; + bool found_first_clip = false; for (const auto& child: children()) { if (auto clip = dynamic_cast(child.value)) @@ -298,7 +298,7 @@ Track::available_image_bounds(ErrorStatus* error_status) const } if (is_error(error_status)) { - return optional(); + return std::optional(); } } } diff --git a/src/opentimelineio/track.h b/src/opentimelineio/track.h index 7c8ef13f1..32a786c6a 100644 --- a/src/opentimelineio/track.h +++ b/src/opentimelineio/track.h @@ -34,10 +34,10 @@ class Track : public Composition using Parent = Composition; Track( - std::string const& name = std::string(), - optional const& source_range = nullopt, - std::string const& = Kind::video, - AnyDictionary const& metadata = AnyDictionary()); + std::string const& name = std::string(), + std::optional const& source_range = std::nullopt, + std::string const& kind = Kind::video, + AnyDictionary const& metadata = AnyDictionary()); std::string kind() const noexcept { return _kind; } @@ -52,7 +52,8 @@ class Track : public Composition TimeRange available_range(ErrorStatus* error_status = nullptr) const override; - std::pair, optional> handles_of_child( + std::pair, std::optional> + handles_of_child( Composable const* child, ErrorStatus* error_status = nullptr) const override; @@ -64,7 +65,7 @@ class Track : public Composition std::map range_of_all_children(ErrorStatus* error_status = nullptr) const override; - optional + std::optional available_image_bounds(ErrorStatus* error_status) const override; // Find child clips. @@ -73,9 +74,9 @@ class Track : public Composition // // The search is recursive unless shallow_search is set to true. std::vector> find_clips( - ErrorStatus* error_status = nullptr, - optional const& search_range = nullopt, - bool shallow_search = false) const; + ErrorStatus* error_status = nullptr, + std::optional const& search_range = std::nullopt, + bool shallow_search = false) const; protected: virtual ~Track(); diff --git a/src/opentimelineio/transition.cpp b/src/opentimelineio/transition.cpp index 63be6f76e..d64010f5e 100644 --- a/src/opentimelineio/transition.cpp +++ b/src/opentimelineio/transition.cpp @@ -51,7 +51,7 @@ Transition::duration(ErrorStatus* /* error_status */) const return _in_offset + _out_offset; } -optional +std::optional Transition::range_in_parent(ErrorStatus* error_status) const { if (!parent()) @@ -68,7 +68,7 @@ Transition::range_in_parent(ErrorStatus* error_status) const return parent()->range_of_child(this, error_status); } -optional +std::optional Transition::trimmed_range_in_parent(ErrorStatus* error_status) const { if (!parent()) diff --git a/src/opentimelineio/transition.h b/src/opentimelineio/transition.h index ead239962..717826f09 100644 --- a/src/opentimelineio/transition.h +++ b/src/opentimelineio/transition.h @@ -57,10 +57,10 @@ class Transition : public Composable RationalTime duration(ErrorStatus* error_status = nullptr) const override; - optional + std::optional range_in_parent(ErrorStatus* error_status = nullptr) const; - optional + std::optional trimmed_range_in_parent(ErrorStatus* error_status = nullptr) const; protected: diff --git a/src/opentimelineio/typeRegistry.h b/src/opentimelineio/typeRegistry.h index 2f2e61854..a0a6047f7 100644 --- a/src/opentimelineio/typeRegistry.h +++ b/src/opentimelineio/typeRegistry.h @@ -3,7 +3,6 @@ #pragma once -#include "opentimelineio/any.h" #include "opentimelineio/errorStatus.h" #include "opentimelineio/version.h" diff --git a/src/py-opentimelineio/bindings-common/casters.h b/src/py-opentimelineio/bindings-common/casters.h deleted file mode 100644 index 561c3b7a7..000000000 --- a/src/py-opentimelineio/bindings-common/casters.h +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright Contributors to the OpenTimelineIO project - -#include -#include -#include "nonstd/optional.hpp" - -using nonstd::optional; -using nonstd::nullopt_t; - -#if __cplusplus < 201703L -namespace pybind11 { namespace detail { - // Caster for converting to/from nonstd::optional. - // Pybind11 supports optional types when C++17 is used. - // So for now we have to create the casters manually. See - // https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html#c-17-library-containers - // ...however, if this is present AFTER c++17, because nonstd::optional - // becomes std::optional starting in C++17, and Pybind11 already defines - // casters for std::optional, this becomes a duplicate (and therefore build - // error). - // The casters can be removed when C++ versions less than 17 are no longer - // supported by OTIO. - template struct type_caster> - : public optional_caster> {}; - - template<> struct type_caster - : public void_caster {}; -}} -#endif diff --git a/src/py-opentimelineio/opentime-bindings/opentime_rationalTime.cpp b/src/py-opentimelineio/opentime-bindings/opentime_rationalTime.cpp index a311b5d0a..be6c9db17 100644 --- a/src/py-opentimelineio/opentime-bindings/opentime_rationalTime.cpp +++ b/src/py-opentimelineio/opentime-bindings/opentime_rationalTime.cpp @@ -3,11 +3,10 @@ #include #include +#include #include "opentime/rationalTime.h" #include "opentimelineio/stringUtils.h" -#include "opentimelineio/optional.h" -#include "py-opentimelineio/bindings-common/casters.h" namespace py = pybind11; using namespace pybind11::literals; @@ -30,7 +29,7 @@ struct ErrorStatusConverter { ErrorStatus error_status; }; -IsDropFrameRate df_enum_converter(optional& df) { +IsDropFrameRate df_enum_converter(std::optional& df) { if (!df.has_value()) { return IsDropFrameRate::InferFromRate; } else if (df.value()) { @@ -112,7 +111,7 @@ For example, the duration of a clip from frame 10 to frame 15 is 6 frames. Resul .def("to_frames", (int (RationalTime::*)() const) &RationalTime::to_frames, "Returns the frame number based on the current rate.") .def("to_frames", (int (RationalTime::*)(double) const) &RationalTime::to_frames, "rate"_a, "Returns the frame number based on the given rate.") .def("to_seconds", &RationalTime::to_seconds) - .def("to_timecode", [](RationalTime rt, double rate, optional drop_frame) { + .def("to_timecode", [](RationalTime rt, double rate, std::optional drop_frame) { return rt.to_timecode( rate, df_enum_converter(drop_frame), diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_bindings.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_bindings.cpp index 74572125c..b83c903f5 100644 --- a/src/py-opentimelineio/opentimelineio-bindings/otio_bindings.cpp +++ b/src/py-opentimelineio/opentimelineio-bindings/otio_bindings.cpp @@ -221,7 +221,7 @@ PYBIND11_MODULE(_otio, m) { "indent"_a) .def("deserialize_json_from_string", [](std::string input) { - any result; + std::any result; deserialize_json_from_string(input, &result, ErrorStatusHandler()); return any_to_py(result, true /*top_level*/); }, "input"_a, @@ -235,7 +235,7 @@ PYBIND11_MODULE(_otio, m) { )docstring") .def("deserialize_json_from_file", [](std::string filename) { - any result; + std::any result; deserialize_json_from_file(filename, &result, ErrorStatusHandler()); return any_to_py(result, true /*top_level*/); }, diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp index d5d0c768f..290a70dae 100644 --- a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp +++ b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp @@ -51,7 +51,7 @@ using SOWithMetadata = SerializableObjectWithMetadata; namespace { template - std::vector vector_or_default(optional> item) { + std::vector vector_or_default(std::optional> item) { if (item.has_value()) { return item.value(); } @@ -60,7 +60,7 @@ namespace { } template - bool find_children(T* t, py::object descended_from_type, optional const& search_range, bool shallow_search, std::vector& l) { + bool find_children(T* t, py::object descended_from_type, std::optional const& search_range, bool shallow_search, std::vector& l) { if (descended_from_type.is(py::type::handle_of())) { for (const auto& child : t->template find_children(ErrorStatusHandler(), search_range, shallow_search)) { @@ -72,7 +72,7 @@ namespace { } template - std::vector find_children(T* t, py::object descended_from_type, optional const& search_range, bool shallow_search = false) { + std::vector find_children(T* t, py::object descended_from_type, std::optional const& search_range, bool shallow_search = false) { std::vector l; if (find_children(t, descended_from_type, search_range, shallow_search, l)) ; else if (find_children(t, descended_from_type, search_range, shallow_search, l)) ; @@ -92,7 +92,7 @@ namespace { } template - std::vector find_clips(T* t, optional const& search_range, bool shallow_search = false) { + std::vector find_clips(T* t, std::optional const& search_range, bool shallow_search = false) { std::vector l; for (const auto& clip : t->find_clips(ErrorStatusHandler(), search_range, shallow_search)) { l.push_back(clip.value); @@ -106,7 +106,7 @@ template static std::string repr(T const& value) { return pybind11::cast(pybind11::repr(pybind11::cast(value))); } -template static std::string repr(optional const& value) { +template static std::string repr(std::optional const& value) { return value ? repr(*value) : "None"; } @@ -119,7 +119,7 @@ template static std::string str(T const& value) { return pybind11::cast(pybind11::str(pybind11::cast(value))); } -template static std::string str(optional const& value) { +template static std::string str(std::optional const& value) { return value ? str(*value) : "None"; } @@ -261,7 +261,7 @@ a named collection. A :class:`~SerializableCollection` is useful for serializing multiple timelines, clips, or media references to a single file. )docstring") - .def(py::init([](std::string const& name, optional> children, + .def(py::init([](std::string const& name, std::optional> children, py::object metadata) { return new SerializableCollection(name, vector_or_default(children), @@ -294,12 +294,12 @@ A :class:`~SerializableCollection` is useful for serializing multiple timelines, .def("__iter__", [](SerializableCollection* c) { return new SerializableCollectionIterator(c); }) - .def("find_clips", [](SerializableCollection* c, optional const& search_range, bool shallow_search) { + .def("find_clips", [](SerializableCollection* c, std::optional const& search_range, bool shallow_search) { return find_clips(c, search_range, shallow_search); - }, "search_range"_a = nullopt, "shallow_search"_a = false) - .def("find_children", [](SerializableCollection* c, py::object descended_from_type, optional const& search_range, bool shallow_search) { + }, "search_range"_a = std::nullopt, "shallow_search"_a = false) + .def("find_children", [](SerializableCollection* c, py::object descended_from_type, std::optional const& search_range, bool shallow_search) { return find_children(c, descended_from_type, search_range, shallow_search); - }, "descended_from_type"_a = py::none(), "search_range"_a = nullopt, "shallow_search"_a = false); + }, "descended_from_type"_a = py::none(), "search_range"_a = std::nullopt, "shallow_search"_a = false); } @@ -310,15 +310,15 @@ An object that can be composed within a :class:`~Composition` (such as :class:`~ )docstring"); py::class_>(m, "Item", py::dynamic_attr()) - .def(py::init([](std::string name, optional source_range, - optional> effects, optional> markers, py::bool_ enabled, py::object metadata) { + .def(py::init([](std::string name, std::optional source_range, + std::optional> effects, std::optional> markers, py::bool_ enabled, py::object metadata) { return new Item(name, source_range, py_to_any_dictionary(metadata), vector_or_default(effects), vector_or_default(markers), enabled); }), py::arg_v("name"_a = std::string()), - "source_range"_a = nullopt, + "source_range"_a = std::nullopt, "effects"_a = py::none(), "markers"_a = py::none(), "enabled"_a = true, @@ -395,8 +395,8 @@ Other effects are handled by the :class:`Effect` class. py::class_>(m, "Gap", py::dynamic_attr()) - .def(py::init([](std::string name, TimeRange source_range, optional> effects, - optional> markers, py::object metadata) { + .def(py::init([](std::string name, TimeRange source_range, std::optional> effects, + std::optional> markers, py::object metadata) { return new Gap(source_range, name, vector_or_default(effects), vector_or_default(markers), @@ -406,8 +406,8 @@ Other effects are handled by the :class:`Effect` class. "effects"_a = py::none(), "markers"_a = py::none(), py::arg_v("metadata"_a = py::none())) - .def(py::init([](std::string name, RationalTime duration, optional> effects, - optional> markers, py::object metadata) { + .def(py::init([](std::string name, RationalTime duration, std::optional> effects, + std::optional> markers, py::object metadata) { return new Gap(duration, name, vector_or_default(effects), vector_or_default(markers), @@ -424,13 +424,13 @@ A :class:`~Clip` is a segment of editable media (usually audio or video). Contains a :class:`.MediaReference` and a trim on that media reference. )docstring") .def(py::init([](std::string name, MediaReference* media_reference, - optional source_range, py::object metadata, + std::optional source_range, py::object metadata, const std::string& active_media_reference) { return new Clip(name, media_reference, source_range, py_to_any_dictionary(metadata), active_media_reference); }), py::arg_v("name"_a = std::string()), "media_reference"_a = nullptr, - "source_range"_a = nullopt, + "source_range"_a = std::nullopt, py::arg_v("metadata"_a = py::none()), "active_media_reference"_a = std::string(Clip::default_media_key)) .def_property_readonly_static("DEFAULT_MEDIA_KEY",[](py::object /* self */) { @@ -456,8 +456,8 @@ Base class for an :class:`~Item` that contains :class:`~Composable`\s. Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not used directly. )docstring") .def(py::init([](std::string name, - optional> children, - optional source_range, py::object metadata) { + std::optional> children, + std::optional source_range, py::object metadata) { Composition* c = new Composition(name, source_range, py_to_any_dictionary(metadata)); c->set_children(vector_or_default(children), ErrorStatusHandler()); @@ -465,7 +465,7 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u }), py::arg_v("name"_a = std::string()), "children"_a = py::none(), - "source_range"_a = nullopt, + "source_range"_a = std::nullopt, py::arg_v("metadata"_a = py::none())) .def_property_readonly("composition_kind", &Composition::composition_kind) .def("is_parent_of", &Composition::is_parent_of, "other"_a) @@ -503,9 +503,9 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u } return l; }, "search_range"_a) - .def("find_children", [](Composition* c, py::object descended_from_type, optional const& search_range, bool shallow_search) { + .def("find_children", [](Composition* c, py::object descended_from_type, std::optional const& search_range, bool shallow_search) { return find_children(c, descended_from_type, search_range, shallow_search); - }, "descended_from_type"_a = py::none(), "search_range"_a = nullopt, "shallow_search"_a = false) + }, "descended_from_type"_a = py::none(), "search_range"_a = std::nullopt, "shallow_search"_a = false) .def("handles_of_child", [](Composition* c, Composable* child) { auto result = c->handles_of_child(child, ErrorStatusHandler()); return py::make_tuple(py::cast(result.first), py::cast(result.second)); @@ -556,8 +556,8 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u .value("never", Track::NeighborGapPolicy::never); track_class - .def(py::init([](std::string name, optional> children, - optional const& source_range, + .def(py::init([](std::string name, std::optional> children, + std::optional const& source_range, std::string const& kind, py::object metadata) { auto composable_children = vector_or_default(children); Track* t = new Track( @@ -572,7 +572,7 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u }), py::arg_v("name"_a = std::string()), "children"_a = py::none(), - "source_range"_a = nullopt, + "source_range"_a = std::nullopt, "kind"_a = std::string(Track::Kind::video), py::arg_v("metadata"_a = py::none())) .def_property("kind", &Track::kind, &Track::set_kind) @@ -580,9 +580,9 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u auto result = t->neighbors_of(item, ErrorStatusHandler(), policy); return py::make_tuple(py::cast(result.first.take_value()), py::cast(result.second.take_value())); }, "item"_a, "policy"_a = Track::NeighborGapPolicy::never) - .def("find_clips", [](Track* t, optional const& search_range, bool shallow_search) { + .def("find_clips", [](Track* t, std::optional const& search_range, bool shallow_search) { return find_clips(t, search_range, shallow_search); - }, "search_range"_a = nullopt, "shallow_search"_a = false); + }, "search_range"_a = std::nullopt, "shallow_search"_a = false); py::class_(track_class, "Kind") .def_property_readonly_static("Audio", [](py::object /* self */) { return Track::Kind::audio; }) @@ -591,10 +591,10 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u py::class_>(m, "Stack", py::dynamic_attr()) .def(py::init([](std::string name, - optional> children, - optional const& source_range, - optional> markers, - optional> effects, + std::optional> children, + std::optional const& source_range, + std::optional> markers, + std::optional> effects, py::object metadata) { auto composable_children = vector_or_default(children); Stack* s = new Stack( @@ -611,18 +611,18 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u }), py::arg_v("name"_a = std::string()), "children"_a = py::none(), - "source_range"_a = nullopt, + "source_range"_a = std::nullopt, "markers"_a = py::none(), "effects"_a = py::none(), py::arg_v("metadata"_a = py::none())) - .def("find_clips", [](Stack* s, optional const& search_range, bool shallow_search) { + .def("find_clips", [](Stack* s, std::optional const& search_range, bool shallow_search) { return find_clips(s, search_range, shallow_search); - }, "search_range"_a = nullopt, "shallow_search"_a = false); + }, "search_range"_a = std::nullopt, "shallow_search"_a = false); py::class_>(m, "Timeline", py::dynamic_attr()) .def(py::init([](std::string name, - optional> children, - optional global_start_time, + std::optional> children, + std::optional global_start_time, py::object metadata) { auto composable_children = vector_or_default(children); Timeline* t = new Timeline(name, global_start_time, @@ -633,7 +633,7 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u }), py::arg_v("name"_a = std::string()), "tracks"_a = py::none(), - "global_start_time"_a = nullopt, + "global_start_time"_a = std::nullopt, py::arg_v("metadata"_a = py::none())) .def_property("global_start_time", &Timeline::global_start_time, &Timeline::set_global_start_time) .def_property("tracks", &Timeline::tracks, &Timeline::set_tracks) @@ -645,12 +645,12 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u }) .def("video_tracks", &Timeline::video_tracks) .def("audio_tracks", &Timeline::audio_tracks) - .def("find_clips", [](Timeline* t, optional const& search_range, bool shallow_search) { + .def("find_clips", [](Timeline* t, std::optional const& search_range, bool shallow_search) { return find_clips(t, search_range, shallow_search); - }, "search_range"_a = nullopt, "shallow_search"_a = false) - .def("find_children", [](Timeline* t, py::object descended_from_type, optional const& search_range, bool shallow_search) { + }, "search_range"_a = std::nullopt, "shallow_search"_a = false) + .def("find_children", [](Timeline* t, py::object descended_from_type, std::optional const& search_range, bool shallow_search) { return find_children(t, descended_from_type, search_range, shallow_search); - }, "descended_from_type"_a = py::none(), "search_range"_a = nullopt, "shallow_search"_a = false); + }, "descended_from_type"_a = py::none(), "search_range"_a = std::nullopt, "shallow_search"_a = false); } static void define_effects(py::module m) { @@ -703,14 +703,14 @@ static void define_media_references(py::module m) { py::class_>(m, "MediaReference", py::dynamic_attr()) .def(py::init([](std::string name, - optional available_range, + std::optional available_range, py::object metadata, - optional const& available_image_bounds) { + std::optional const& available_image_bounds) { return new MediaReference(name, available_range, py_to_any_dictionary(metadata), available_image_bounds); }), py::arg_v("name"_a = std::string()), - "available_range"_a = nullopt, + "available_range"_a = std::nullopt, py::arg_v("metadata"_a = py::none()), - "available_image_bounds"_a = nullopt) + "available_image_bounds"_a = std::nullopt) .def_property("available_range", &MediaReference::available_range, &MediaReference::set_available_range) .def_property("available_image_bounds", &MediaReference::available_image_bounds, &MediaReference::set_available_image_bounds) @@ -719,9 +719,9 @@ static void define_media_references(py::module m) { py::class_>(m, "GeneratorReference", py::dynamic_attr()) .def(py::init([](std::string name, std::string generator_kind, - optional const& available_range, + std::optional const& available_range, py::object parameters, py::object metadata, - optional const& available_image_bounds) { + std::optional const& available_image_bounds) { return new GeneratorReference(name, generator_kind, available_range, py_to_any_dictionary(parameters), @@ -729,10 +729,10 @@ static void define_media_references(py::module m) { available_image_bounds); }), py::arg_v("name"_a = std::string()), "generator_kind"_a = std::string(), - "available_range"_a = nullopt, + "available_range"_a = std::nullopt, "parameters"_a = py::none(), py::arg_v("metadata"_a = py::none()), - "available_image_bounds"_a = nullopt) + "available_image_bounds"_a = std::nullopt) .def_property("generator_kind", &GeneratorReference::generator_kind, &GeneratorReference::set_generator_kind) .def_property_readonly("parameters", [](GeneratorReference* g) { auto ptr = g->parameters().get_or_create_mutation_stamp(); @@ -747,9 +747,9 @@ Note that a :class:`~MissingReference` may have useful metadata, even if the loc )docstring") .def(py::init([]( std::string name, - optional available_range, + std::optional available_range, py::object metadata, - optional const& available_image_bounds) { + std::optional const& available_image_bounds) { return new MissingReference( name, available_range, @@ -757,25 +757,25 @@ Note that a :class:`~MissingReference` may have useful metadata, even if the loc available_image_bounds); }), py::arg_v("name"_a = std::string()), - "available_range"_a = nullopt, + "available_range"_a = std::nullopt, py::arg_v("metadata"_a = py::none()), - "available_image_bounds"_a = nullopt); + "available_image_bounds"_a = std::nullopt); py::class_>(m, "ExternalReference", py::dynamic_attr()) .def(py::init([](std::string target_url, - optional const& available_range, + std::optional const& available_range, py::object metadata, - optional const& available_image_bounds) { + std::optional const& available_image_bounds) { return new ExternalReference(target_url, available_range, py_to_any_dictionary(metadata), available_image_bounds); }), "target_url"_a = std::string(), - "available_range"_a = nullopt, + "available_range"_a = std::nullopt, py::arg_v("metadata"_a = py::none()), - "available_image_bounds"_a = nullopt) + "available_image_bounds"_a = std::nullopt) .def_property("target_url", &ExternalReference::target_url, &ExternalReference::set_target_url); auto imagesequencereference_class = py:: class_ const& available_range, + std::optional const& available_range, py::object metadata, - optional const& available_image_bounds) { + std::optional const& available_image_bounds) { return new ImageSequenceReference(target_url_base, name_prefix, name_suffix, @@ -883,9 +883,9 @@ Negative ``start_frame`` is also handled. The above example with a ``start_frame "rate"_a = 1, "frame_zero_padding"_a = 0, "missing_frame_policy"_a = ImageSequenceReference::MissingFramePolicy::error, - "available_range"_a = nullopt, + "available_range"_a = std::nullopt, py::arg_v("metadata"_a = py::none()), - "available_image_bounds"_a = nullopt) + "available_image_bounds"_a = std::nullopt) .def_property("target_url_base", &ImageSequenceReference::target_url_base, &ImageSequenceReference::set_target_url_base, "Everything leading up to the file name in the ``target_url``.") .def_property("name_prefix", &ImageSequenceReference::name_prefix, &ImageSequenceReference::set_name_prefix, "Everything in the file name leading up to the frame number.") .def_property("name_suffix", &ImageSequenceReference::name_suffix, &ImageSequenceReference::set_name_suffix, "Everything after the frame number in the file name.") diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_tests.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_tests.cpp index 218ed856a..ff44c1fb9 100644 --- a/src/py-opentimelineio/opentimelineio-bindings/otio_tests.cpp +++ b/src/py-opentimelineio/opentimelineio-bindings/otio_tests.cpp @@ -31,9 +31,9 @@ class TestObject : public SerializableObjectWithMetadata { } SerializableObject* lookup(std::string key) { - any a = metadata()[key]; + std::any a = metadata()[key]; if (a.type() == typeid(Retainer<>)) { - return any_cast>(a).value; + return std::any_cast>(a).value; } return nullptr; } @@ -148,7 +148,7 @@ bool test_big_uint() { bool result = true; - if (any_cast(so->metadata()["giant_number"]) != giant_number) { + if (std::any_cast(so->metadata()["giant_number"]) != giant_number) { return false; } diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_utils.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_utils.cpp index c327374e3..13e406c65 100644 --- a/src/py-opentimelineio/opentimelineio-bindings/otio_utils.cpp +++ b/src/py-opentimelineio/opentimelineio-bindings/otio_utils.cpp @@ -4,7 +4,6 @@ #include "otio_utils.h" #include "otio_anyDictionary.h" #include "otio_anyVector.h" -#include "opentimelineio/any.h" #include "opentime/rationalTime.h" #include "opentime/timeRange.h" #include "opentime/timeTransform.h" @@ -21,8 +20,8 @@ bool compare_typeids(std::type_info const& lhs, std::type_info const& rhs) { return lhs.name() == rhs.name() || !strcmp(lhs.name(), rhs.name()); } -static std::map> _py_cast_dispatch_table; -static std::map> _py_cast_dispatch_table_by_name; +static std::map> _py_cast_dispatch_table; +static std::map> _py_cast_dispatch_table_by_name; py::object plain_string(std::string const& s) { #if PY_MAJOR_VERSION >= 3 @@ -51,23 +50,23 @@ py::object plain_uint(uint64_t i) { void _build_any_to_py_dispatch_table() { auto& t = _py_cast_dispatch_table; - t[&typeid(void)] = [](any const& /* a */, bool) { return py::none(); }; - t[&typeid(bool)] = [](any const& a, bool) { return py::cast(safely_cast_bool_any(a)); }; - t[&typeid(int)] = [](any const& a, bool) { return plain_int(safely_cast_int_any(a)); }; - t[&typeid(int64_t)] = [](any const& a, bool) { return plain_int(safely_cast_int64_any(a)); }; - t[&typeid(uint64_t)] = [](any const& a, bool) { return plain_uint(safely_cast_uint64_any(a)); }; - t[&typeid(double)] = [](any const& a, bool) { return py::cast(safely_cast_double_any(a)); }; - t[&typeid(std::string)] = [](any const& a, bool) { return py::cast(safely_cast_string_any(a)); }; - t[&typeid(RationalTime)] = [](any const& a, bool) { return py::cast(safely_cast_rational_time_any(a)); }; - t[&typeid(TimeRange)] = [](any const& a, bool) { return py::cast(safely_cast_time_range_any(a)); }; - t[&typeid(TimeTransform)] = [](any const& a, bool) { return py::cast(safely_cast_time_transform_any(a)); }; - t[&typeid(SerializableObject::Retainer<>)] = [](any const& a, bool) { + t[&typeid(void)] = [](std::any const& /* a */, bool) { return py::none(); }; + t[&typeid(bool)] = [](std::any const& a, bool) { return py::cast(safely_cast_bool_any(a)); }; + t[&typeid(int)] = [](std::any const& a, bool) { return plain_int(safely_cast_int_any(a)); }; + t[&typeid(int64_t)] = [](std::any const& a, bool) { return plain_int(safely_cast_int64_any(a)); }; + t[&typeid(uint64_t)] = [](std::any const& a, bool) { return plain_uint(safely_cast_uint64_any(a)); }; + t[&typeid(double)] = [](std::any const& a, bool) { return py::cast(safely_cast_double_any(a)); }; + t[&typeid(std::string)] = [](std::any const& a, bool) { return py::cast(safely_cast_string_any(a)); }; + t[&typeid(RationalTime)] = [](std::any const& a, bool) { return py::cast(safely_cast_rational_time_any(a)); }; + t[&typeid(TimeRange)] = [](std::any const& a, bool) { return py::cast(safely_cast_time_range_any(a)); }; + t[&typeid(TimeTransform)] = [](std::any const& a, bool) { return py::cast(safely_cast_time_transform_any(a)); }; + t[&typeid(SerializableObject::Retainer<>)] = [](std::any const& a, bool) { SerializableObject* so = safely_cast_retainer_any(a); return py::cast(managing_ptr(so)); }; - t[&typeid(AnyDictionaryProxy*)] = [](any const& a, bool) { return py::cast(any_cast(a)); }; - t[&typeid(AnyVectorProxy*)] = [](any const& a, bool) { return py::cast(any_cast(a)); }; + t[&typeid(AnyDictionaryProxy*)] = [](std::any const& a, bool) { return py::cast(std::any_cast(a)); }; + t[&typeid(AnyVectorProxy*)] = [](std::any const& a, bool) { return py::cast(std::any_cast(a)); }; - t[&typeid(AnyDictionary)] = [](any const& a, bool top_level) { + t[&typeid(AnyDictionary)] = [](std::any const& a, bool top_level) { AnyDictionary& d = temp_safely_cast_any_dictionary_any(a); if (top_level) { auto proxy = new AnyDictionaryProxy; @@ -79,7 +78,7 @@ void _build_any_to_py_dispatch_table() { } }; - t[&typeid(AnyVector)] = [](any const& a, bool top_level) { + t[&typeid(AnyVector)] = [](std::any const& a, bool top_level) { AnyVector& v = temp_safely_cast_any_vector_any(a); if (top_level) { auto proxy = new AnyVectorProxy; @@ -96,7 +95,7 @@ void _build_any_to_py_dispatch_table() { static py::object _value_to_any = py::none(); -static void py_to_any(py::object const& o, any* result) { +static void py_to_any(py::object const& o, std::any* result) { if (_value_to_any.is_none()) { py::object core = py::module::import("opentimelineio.core"); _value_to_any = core.attr("_value_to_any"); @@ -110,7 +109,7 @@ AnyDictionary py_to_any_dictionary(py::object const& o) { return AnyDictionary(); } - any a; + std::any a; py_to_any(o, &a); if (!compare_typeids(a.type(), typeid(AnyDictionary))) { throw py::type_error(string_printf("Expected an AnyDictionary (i.e. metadata); got %s instead", @@ -120,7 +119,7 @@ AnyDictionary py_to_any_dictionary(py::object const& o) { return safely_cast_any_dictionary_any(a); } -py::object any_to_py(any const& a, bool top_level) { +py::object any_to_py(std::any const& a, bool top_level) { std::type_info const& tInfo = a.type(); auto e = _py_cast_dispatch_table.find(&tInfo); diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_utils.h b/src/py-opentimelineio/opentimelineio-bindings/otio_utils.h index 2a979aabc..889df128b 100644 --- a/src/py-opentimelineio/opentimelineio-bindings/otio_utils.h +++ b/src/py-opentimelineio/opentimelineio-bindings/otio_utils.h @@ -6,8 +6,6 @@ #include #include #include -#include "py-opentimelineio/bindings-common/casters.h" -#include "opentimelineio/any.h" #include "opentimelineio/stringUtils.h" #include "opentimelineio/serializableObject.h" #include "opentimelineio/vectorIndexing.h" @@ -146,10 +144,10 @@ struct PyAny { : a(create_safely_typed_any(value)) { } - any a; + std::any a; }; -pybind11::object any_to_py(any const& a, bool top_level = false); +pybind11::object any_to_py(std::any const& a, bool top_level = false); pybind11::object plain_string(std::string const& s); pybind11::object plain_int(int i); AnyDictionary py_to_any_dictionary(pybind11::object const& o); diff --git a/tests/test_clip.cpp b/tests/test_clip.cpp index 8dac199bc..467211d7f 100644 --- a/tests/test_clip.cpp +++ b/tests/test_clip.cpp @@ -157,7 +157,11 @@ main(int argc, char** argv) new otio::ExternalReference()); SerializableObject::Retainer clip(new Clip( - "unit_clip", media, nullopt, AnyDictionary(), high_quality)); + "unit_clip", + media, + std::nullopt, + AnyDictionary(), + high_quality)); assertEqual(clip->active_media_reference_key().c_str(), high_quality); assertEqual(clip->media_reference(), media.value); diff --git a/tests/test_serializableCollection.cpp b/tests/test_serializableCollection.cpp index 1956b28e2..0593ef8b6 100644 --- a/tests/test_serializableCollection.cpp +++ b/tests/test_serializableCollection.cpp @@ -81,9 +81,9 @@ main(int argc, char** argv) sc = new otio::SerializableCollection(); sc->insert_child(0, tl); opentimelineio::v1_0::ErrorStatus err; - auto result = sc->find_children(&err, nullopt, true); + auto result = sc->find_children(&err, std::nullopt, true); assertEqual(result.size(), 0); - result = sc->find_children(&err, nullopt, false); + result = sc->find_children(&err, std::nullopt, false); assertEqual(result.size(), 1); assertEqual(result[0].value, cl.value); }); diff --git a/tests/test_timeline.cpp b/tests/test_timeline.cpp index b8022a530..bc63feafd 100644 --- a/tests/test_timeline.cpp +++ b/tests/test_timeline.cpp @@ -71,9 +71,9 @@ main(int argc, char** argv) new otio::Timeline(); tl->tracks()->append_child(tr); opentimelineio::v1_0::ErrorStatus err; - auto result = tl->find_children(&err, nullopt, true); + auto result = tl->find_children(&err, std::nullopt, true); assertEqual(result.size(), 0); - result = tl->find_children(&err, nullopt, false); + result = tl->find_children(&err, std::nullopt, false); assertEqual(result.size(), 1); assertEqual(result[0].value, cl.value); }); diff --git a/tests/test_track.cpp b/tests/test_track.cpp index 96ae06145..26820f8e0 100644 --- a/tests/test_track.cpp +++ b/tests/test_track.cpp @@ -99,10 +99,10 @@ main(int argc, char** argv) tr->append_child(cl0); tr->append_child(st); opentimelineio::v1_0::ErrorStatus err; - auto result = tr->find_children(&err, nullopt, true); + auto result = tr->find_children(&err, std::nullopt, true); assertEqual(result.size(), 1); assertEqual(result[0].value, cl0.value); - result = tr->find_children(&err, nullopt, false); + result = tr->find_children(&err, std::nullopt, false); assertEqual(result.size(), 2); assertEqual(result[0].value, cl0.value); assertEqual(result[1].value, cl1.value);