24 #ifndef PXR_BASE_TF_PY_ANNOTATED_BOOL_RESULT_H
25 #define PXR_BASE_TF_PY_ANNOTATED_BOOL_RESULT_H
32 #include <hboost/python/class.hpp>
33 #include <hboost/python/operators.hpp>
34 #include <hboost/python/return_by_value.hpp>
40 template <
class Annotation>
46 _val(val), _annotation(annotation) {}
78 template <
class Derived>
79 static hboost::python::class_<Derived>
80 Wrap(
char const *
name,
char const *annotationName) {
82 using namespace hboost::python;
84 return class_<Derived>(
name, init<bool, Annotation>())
85 .def(
"__bool__", &Derived::GetValue)
86 .def(
"__repr__", &Derived::GetRepr)
106 .add_property(annotationName, &This::_GetAnnotation<Derived>)
107 .def(
"__getitem__", &This::_GetItem<Derived>)
115 template <
class Derived>
116 static Annotation _GetAnnotation(
const Derived&
x)
118 return x.GetAnnotation();
121 template <
class Derived>
131 PyErr_SetString(PyExc_IndexError,
"Index must be 0 or 1.");
132 hboost::python::throw_error_already_set();
139 Annotation _annotation;
144 template <
class Annotation>
151 template <
class Annotation>
159 #endif // PXR_BASE_TF_PY_ANNOTATED_BOOL_RESULT_H
Annotation const & GetAnnotation() const
GLsizei const GLchar *const * string
TfPyAnnotatedBoolResult()
std::string TfPyRepr(T const &t)
TfPyAnnotatedBoolResult(bool val, Annotation const &annotation)
GLuint const GLchar * name
static hboost::python::class_< Derived > Wrap(char const *name, char const *annotationName)
friend bool operator!=(bool lhs, const TfPyAnnotatedBoolResult &rhs)
friend bool operator!=(const TfPyAnnotatedBoolResult &lhs, bool rhs)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Annotation AnnotationType
#define PXR_NAMESPACE_CLOSE_SCOPE
friend bool operator==(bool lhs, const TfPyAnnotatedBoolResult &rhs)
bool operator==(bool rhs) const
Returns true if the result is the same as rhs.
std::string GetRepr() const