// relative to the layer where they were expressed.
curListOp.ApplyOperations(result,
[&](SdfListOpType opType, const RefOrPayloadType& refOrPayload)
- -> boost::optional<RefOrPayloadType>
+ -> std::optional<RefOrPayloadType>
{
// Fill in the result reference or payload with the anchored
// asset path instead of the authored asset path. This
// layer. If the empty result was due to an error, that
// will have already been saved to the errors list above.
if (authoredAssetPath.empty()) {
- return boost::none;
+ return std::nullopt;
}
assetPath = SdfComputeAssetPathRelativeToLayer(
#include "pxr/base/trace/trace.h"
-#include <boost/optional.hpp>
-
#include <functional>
+#include <optional>
PXR_NAMESPACE_OPEN_SCOPE
// Callback used to translate paths as path list operations from
// various nodes are applied.
-static boost::optional<SdfPath>
+static std::optional<SdfPath>
_PathTranslateCallback(
SdfListOpType opType,
const PcpSite &propSite,
_RemoveTargetPathErrorsForPath(translatedPath, targetPathErrors);
return translatedPath;
}
- return boost::optional<SdfPath>();
+ return std::optional<SdfPath>();
}
if (!pathIsMappable) {
err->layer = owningProp->GetLayer();
err->composedTargetPath = SdfPath();
targetPathErrors->push_back(err);
- return boost::optional<SdfPath>();
+ return std::optional<SdfPath>();
}
if (translatedPath.IsEmpty()) {
- return boost::optional<SdfPath>();
+ return std::optional<SdfPath>();
}
if (cacheForValidation) {
err->layer = owningProp->GetLayer();
err->composedTargetPath = translatedPath;
targetPathErrors->push_back(err);
- return boost::optional<SdfPath>();
+ return std::optional<SdfPath>();
}
// Check if the connection is invalid due to permissions or
err->layer = owningProp->GetLayer();
err->composedTargetPath = translatedPath;
targetPathErrors->push_back(err);
- return boost::optional<SdfPath>();
+ return std::optional<SdfPath>();
}
case InvalidTarget:
err->layer = owningProp->GetLayer();
err->composedTargetPath = translatedPath;
targetPathErrors->push_back(err);
- return boost::optional<SdfPath>();
+ return std::optional<SdfPath>();
}
case NoError:
#include <functional>
#include <iostream>
#include <mutex>
+#include <optional>
#include <set>
#include <thread>
#include <vector>
// ModifyItemEdits() callback that updates a reference's or payload's
// asset path for SdfReferenceListEditor and SdfPayloadListEditor.
template <class RefOrPayloadType>
-static boost::optional<RefOrPayloadType>
+static std::optional<RefOrPayloadType>
_UpdateRefOrPayloadPath(
const string &oldLayerPath,
const string &newLayerPath,
if (refOrPayload.GetAssetPath() == oldLayerPath) {
// Delete if new layer path is empty, otherwise rename.
if (newLayerPath.empty()) {
- return boost::optional<RefOrPayloadType>();
+ return std::optional<RefOrPayloadType>();
} else {
RefOrPayloadType updatedRefOrPayload = refOrPayload;
updatedRefOrPayload.SetAssetPath(newLayerPath);
#include "pxr/usd/sdf/schema.h"
#include "pxr/usd/sdf/spec.h"
-#include <boost/optional.hpp>
-
#include <functional>
+#include <optional>
PXR_NAMESPACE_OPEN_SCOPE
virtual bool ClearEditsAndMakeExplicit() = 0;
typedef std::function<
- boost::optional<value_type>(const value_type&)
+ std::optional<value_type>(const value_type&)
>
ModifyCallback;
virtual void ModifyItemEdits(const ModifyCallback& cb) = 0;
typedef std::function<
- boost::optional<value_type>(SdfListOpType, const value_type&)
+ std::optional<value_type>(SdfListOpType, const value_type&)
>
ApplyCallback;
#include "pxr/base/vt/value.h" // for Vt_DefaultValueFactory
-#include <boost/optional.hpp>
-
#include <functional>
#include <memory>
+#include <optional>
PXR_NAMESPACE_OPEN_SCOPE
typedef std::vector<value_type> value_vector_type;
// ApplyEdits types.
- typedef std::function<boost::optional<value_type>
+ typedef std::function<std::optional<value_type>
(SdfListOpType, const value_type&)> ApplyCallback;
// ModifyEdits types.
- typedef std::function<boost::optional<value_type>
+ typedef std::function<std::optional<value_type>
(const value_type&)> ModifyCallback;
/// Creates a default proxy object. The object evaluates to \c false in a
#include "pxr/base/tf/token.h"
#include "pxr/base/trace/trace.h"
-#include <boost/optional.hpp>
-
#include <ostream>
using std::string;
}
template <typename T>
-boost::optional<SdfListOp<T>>
+std::optional<SdfListOp<T>>
SdfListOp<T>::ApplyOperations(const SdfListOp<T> &inner) const
{
if (IsExplicit()) {
// and there is no way to express the relative order dependency
// between 0 and 1.
//
- return boost::optional<SdfListOp<T>>();
+ return std::optional<SdfListOp<T>>();
}
template <class ItemType, class ListType, class MapType>
{
TF_FOR_ALL(i, GetItems(op)) {
if (callback) {
- if (boost::optional<T> item = callback(op, *i)) {
+ if (std::optional<T> item = callback(op, *i)) {
// Only append if the item isn't already present.
_InsertIfUnique(*item, result, search);
}
const ItemVector& items = GetItems(op);
if (callback) {
for (auto i = items.rbegin(), iEnd = items.rend(); i != iEnd; ++i) {
- if (boost::optional<T> mappedItem = callback(op, *i)) {
+ if (std::optional<T> mappedItem = callback(op, *i)) {
_InsertOrMove(*mappedItem, result->begin(), result, search);
}
}
const ItemVector& items = GetItems(op);
if (callback) {
for (const T& item: items) {
- if (boost::optional<T> mappedItem = callback(op, item)) {
+ if (std::optional<T> mappedItem = callback(op, item)) {
_InsertOrMove(*mappedItem, result->end(), result, search);
}
}
{
TF_FOR_ALL(i, GetItems(op)) {
if (callback) {
- if (boost::optional<T> item = callback(op, *i)) {
+ if (std::optional<T> item = callback(op, *i)) {
_RemoveIfPresent(*item, result, search);
}
}
std::set<ItemType, _ItemComparator> orderSet;
TF_FOR_ALL(i, GetItems(op)) {
if (callback) {
- if (boost::optional<T> item = callback(op, *i)) {
+ if (std::optional<T> item = callback(op, *i)) {
if (orderSet.insert(*item).second) {
order.push_back(*item);
}
TfDenseHashSet<T, TfHash> existingSet;
for (const T& item : *itemVector) {
- boost::optional<T> modifiedItem = cb(item);
+ std::optional<T> modifiedItem = cb(item);
if (removeDuplicates && modifiedItem) {
if (!existingSet.insert(*modifiedItem).second) {
- modifiedItem = boost::none;
+ modifiedItem = std::nullopt;
}
}
#include "pxr/base/tf/token.h"
#include "pxr/base/tf/hash.h"
-#include <boost/optional/optional_fwd.hpp>
-
#include <functional>
#include <iosfwd>
#include <list>
#include <map>
+#include <optional>
#include <string>
#include <vector>
/// Callback type for ApplyOperations.
typedef std::function<
- boost::optional<ItemType>(SdfListOpType, const ItemType&)
+ std::optional<ItemType>(SdfListOpType, const ItemType&)
> ApplyCallback;
/// Applies edit operations to the given ItemVector.
/// the explicit, prepended, appended, and deleted portions of
/// SdfListOp are closed under composition with ApplyOperations().
SDF_API
- boost::optional<SdfListOp<T>>
+ std::optional<SdfListOp<T>>
ApplyOperations(const SdfListOp<T> &inner) const;
/// Callback type for ModifyOperations.
typedef std::function<
- boost::optional<ItemType>(const ItemType&)
+ std::optional<ItemType>(const ItemType&)
> ModifyCallback;
/// Modifies operations specified in this object.
private:
static
- boost::optional<value_type>
+ std::optional<value_type>
_ModifyCallbackHelper(const ModifyCallback& cb,
const TypePolicy& typePolicy,
const value_type& v)
{
- boost::optional<value_type> value = cb(v);
+ std::optional<value_type> value = cb(v);
return value ? typePolicy.Canonicalize(*value) : value;
}
#include "pxr/base/tf/diagnostic.h"
#include "pxr/base/tf/errorMark.h"
#include "pxr/base/tf/iterator.h"
-#include <boost/optional.hpp>
#include <memory>
+#include <optional>
#include <type_traits>
PXR_NAMESPACE_OPEN_SCOPE
/// Modify all edits in this list.
///
/// \p callback must be a callable that accepts an argument of type
- /// value_type and returns a boost::optional<value_type>.
+ /// value_type and returns a std::optional<value_type>.
///
/// \p callback is called with every item in the list. If an invalid
- /// boost::optional is returned, the item is removed. Otherwise it's
+ /// std::optional is returned, the item is removed. Otherwise it's
/// replaced with the returned item. If a returned item matches an
/// item that was previously returned, the returned item will be
/// removed.
// Do nothing
}
- boost::optional<V> operator()(SdfListOpType op, const V& value)
+ std::optional<V> operator()(SdfListOpType op, const V& value)
{
using namespace boost::python;
if (! TfPyIsNone(result)) {
extract<V> e(result);
if (e.check()) {
- return boost::optional<V>(e());
+ return std::optional<V>(e());
}
else {
TF_CODING_ERROR("ApplyEditsToList callback has "
"incorrect return type.");
}
}
- return boost::optional<V>();
+ return std::optional<V>();
}
private:
// Do nothing
}
- boost::optional<V> operator()(const V& value)
+ std::optional<V> operator()(const V& value)
{
using namespace boost::python;
if (! TfPyIsNone(result)) {
extract<V> e(result);
if (e.check()) {
- return boost::optional<V>(e());
+ return std::optional<V>(e());
}
else {
TF_CODING_ERROR("ModifyItemEdits callback has "
"incorrect return type.");
}
}
- return boost::optional<V>();
+ return std::optional<V>();
}
private:
}
static boost::python::object
_ApplyOperations2(const T& outer, const T& inner) {
- if (boost::optional<T> r = outer.ApplyOperations(inner)) {
+ if (std::optional<T> r = outer.ApplyOperations(inner)) {
return boost::python::object(*r);
} else {
return boost::python::object();
#include "pxr/base/trace/trace.h"
#include <functional>
+#include <optional>
PXR_NAMESPACE_OPEN_SCOPE
GetTargetPathList().ClearEdits();
}
-static boost::optional<SdfPath>
+static std::optional<SdfPath>
_ReplacePath(
const SdfPath &oldPath, const SdfPath &newPath, const SdfPath &path)
{
return newPath;
}
if (path == newPath) {
- return boost::none;
+ return std::nullopt;
}
return path;
}
private:
static
- boost::optional<value_type>
+ std::optional<value_type>
_ModifyCallbackHelper(const ModifyCallback& cb,
const TypePolicy& typePolicy,
const value_type& v)
{
- boost::optional<value_type> value = cb(v);
+ std::optional<value_type> value = cb(v);
return value ? typePolicy.Canonicalize(*value) : value;
}
#include <algorithm>
#include <functional>
+#include <optional>
#include <vector>
PXR_NAMESPACE_OPEN_SCOPE
_Reduce(const SdfListOp<T> &lhs, const SdfListOp<T> &rhs)
{
// We assume the caller has already applied _FixListOp()
- if (boost::optional<SdfListOp<T>> r = lhs.ApplyOperations(rhs)) {
+ if (std::optional<SdfListOp<T>> r = lhs.ApplyOperations(rhs)) {
return VtValue(*r);
}
// The approximation used should always be composable,
}
template <class RefOrPayloadType>
-static boost::optional<RefOrPayloadType>
+static std::optional<RefOrPayloadType>
_ApplyLayerOffsetToRefOrPayload(const SdfLayerOffset &offset,
const RefOrPayloadType &refOrPayload)
{
RefOrPayloadType result = refOrPayload;
result.SetLayerOffset(offset * refOrPayload.GetLayerOffset());
- return boost::optional<RefOrPayloadType>(result);
+ return std::optional<RefOrPayloadType>(result);
}
// Apply layer offsets (time remapping) to time-keyed metadata.
const std::string& assetPath)>;
template <class RefOrPayloadType>
-static boost::optional<RefOrPayloadType>
+static std::optional<RefOrPayloadType>
_FixReferenceOrPayload(const _ResolveAssetPathFn& resolveAssetPathFn,
const SdfLayerHandle &sourceLayer,
const RefOrPayloadType &refOrPayload)
RefOrPayloadType result = refOrPayload;
result.SetAssetPath(
resolveAssetPathFn(sourceLayer, refOrPayload.GetAssetPath()));
- return boost::optional<RefOrPayloadType>(result);
+ return std::optional<RefOrPayloadType>(result);
}
static void
}
template <class RefOrPayloadType, UsdUtils_DependencyType DEP_TYPE>
-boost::optional<RefOrPayloadType>
+std::optional<RefOrPayloadType>
UsdUtils_WritableLocalizationDelegate::_ProcessRefOrPayload(
const SdfLayerRefPtr &layer,
const RefOrPayloadType& refOrPayload,
// these since they refer to the same layer where the payload was
// authored.
if (refOrPayload.GetAssetPath().empty()) {
- return boost::optional<RefOrPayloadType>(refOrPayload);
+ return std::optional<RefOrPayloadType>(refOrPayload);
}
UsdUtilsDependencyInfo depInfo(refOrPayload.GetAssetPath());
layer, depInfo, DEP_TYPE);
if (info.GetAssetPath().empty()) {
- return boost::none;
+ return std::nullopt;
}
RefOrPayloadType processedRefOrPayload = refOrPayload;
dependencies->insert(dependencies->end(),
info.GetDependencies().begin(), info.GetDependencies().end());
- return boost::optional<RefOrPayloadType>(processedRefOrPayload);
+ return std::optional<RefOrPayloadType>(processedRefOrPayload);
}
// When beginning to process a value, if the value is a dictionary, explicitly
const TfToken &listOpToken);
template <class RefOrPayloadType, UsdUtils_DependencyType DEP_TYPE>
- boost::optional<RefOrPayloadType> _ProcessRefOrPayload(
+ std::optional<RefOrPayloadType> _ProcessRefOrPayload(
const SdfLayerRefPtr &layer,
const RefOrPayloadType& refOrPayload,
std::vector<std::string>* dependencies);
VtValue
_Reduce(const SdfListOp<T> &stronger, const SdfListOp<T> &weaker)
{
- boost::optional<SdfListOp<T>> r = stronger.ApplyOperations(weaker);
+ std::optional<SdfListOp<T>> r = stronger.ApplyOperations(weaker);
if (r) {
return VtValue(*r);
}