HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyConversions.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_USD_PY_CONVERSIONS_H
8 #define PXR_USD_USD_PY_CONVERSIONS_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/usd/api.h"
13 
15 
16 class VtValue;
17 class TfToken;
18 class SdfValueTypeName;
19 
20 // XXX: DEPRECATED. This function does nothing except convert \p value to
21 // python. Do not call, it will be removed.
22 USD_API
24 
25 /// Helper for converting a python value to the target Usd/Sdf type, if
26 /// possible. Invokes VtValue::CastToTypeOf() to do the conversion, if
27 /// required. This internally handles python buffers (e.g. numpy) -> VtArray
28 /// and some python tuple/list -> VtArray conversions. If conversion fails,
29 /// returns a VtValue extracted from the pyVal, which may produce a VtValue
30 /// holding a python object.
31 USD_API
33  SdfValueTypeName const &targetType);
34 
35 /// Helper for converting a python value to a metadata value for metadata
36 /// known to the SdfSchema. Generates a coding error if \p key is unknown
37 /// to the SdfSchema.
38 ///
39 /// For dictionary-valued metadata, \p keyPath may be specified as the path
40 /// in the dictionary we are targeting, so that if the dictionary was registered
41 /// with a fallback for that dictionary subcomponent, we will convert
42 /// appropriately to its type.
43 ///
44 /// \return \c true on successful conversion, which can happen even if
45 /// the converted \p result is an empty VtValue
46 USD_API
47 bool UsdPythonToMetadataValue(const TfToken &key, const TfToken &keyPath,
48  TfPyObjWrapper pyVal, VtValue *result);
49 
50 
52 
53 #endif // PXR_USD_USD_PY_CONVERSIONS_H
USD_API bool UsdPythonToMetadataValue(const TfToken &key, const TfToken &keyPath, TfPyObjWrapper pyVal, VtValue *result)
#define USD_API
Definition: api.h:23
GLsizei const GLfloat * value
Definition: glcorearb.h:824
**But if you need a result
Definition: thread.h:622
USD_API VtValue UsdPythonToSdfType(TfPyObjWrapper pyVal, SdfValueTypeName const &targetType)
Definition: token.h:70
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USD_API TfPyObjWrapper UsdVtValueToPython(const VtValue &value)
Definition: value.h:146