7#ifndef PXR_USD_SDF_ALLOWED_H
8#define PXR_USD_SDF_ALLOWED_H
13#include "pxr/usd/sdf/api.h"
20PXR_NAMESPACE_OPEN_SCOPE
31 typedef std::optional<std::string> _State;
34 typedef std::pair<bool, std::string> Pair;
43 SdfAllowed(
const std::string& whyNot) : _state(whyNot) { }
49 _state(condition ?
std::nullopt :
50 std::make_optional(whyNot)) { }
56 typedef _State
SdfAllowed::*UnspecifiedBoolType;
60 operator UnspecifiedBoolType()
const
62 return _state ? NULL : &SdfAllowed::_state;
68 return static_cast<bool>(_state);
73 operator const std::string&()
const
86 if (whyNot && _state) {
96 return _state == other._state;
101 return !(*
this == other);
108PXR_NAMESPACE_CLOSE_SCOPE
Low-level utilities for informing users of various internal and external diagnostic conditions.
Indicates if an operation is allowed and, if not, why not.
SDF_API const std::string & GetWhyNot() const
Returns the reason why the operation is not allowed.
SdfAllowed()
Construct true.
bool IsAllowed(std::string *whyNot) const
Returns true if allowed, otherwise fills whyNot if not NULL and returns false.
SdfAllowed(const Pair &x)
Construct from bool,string pair x.
SdfAllowed(bool x)
Construct true.
bool operator==(const SdfAllowed &other) const
Compare to other.
bool operator!() const
Returns false in a boolean context if allowed, true otherwise.
SdfAllowed(bool condition, const char *whyNot)
Construct in condition with annotation whyNot if false.
SdfAllowed(const std::string &whyNot)
Construct false with annotation whyNot.
SdfAllowed(const char *whyNot)
Construct false with annotation whyNot.
SdfAllowed(bool condition, const std::string &whyNot)
Construct in condition with annotation whyNot if false.
#define TF_AXIOM(cond)
Aborts if the condition cond is not met.