HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PY_Result.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  * This class holds the result of python code that was run.
8  */
9 
10 #ifndef __PY_Result_h__
11 #define __PY_Result_h__
12 
13 #include "PY_API.h"
14 #include <UT/UT_StringArray.h>
15 #include <UT/UT_StringHolder.h>
16 #include <UT/UT_Options.h>
17 #include <UT/UT_Variant.h>
18 #include <vector>
19 
20 // This class contains information about the return value of python code
21 // that was executed.
23 {
24 public:
26  : myResultType(NONE)
27  , myOpaquePyObject(nullptr)
28  , myVoidPtr(nullptr)
29  {}
30 
31  UT_StringHolder asStringForDebugging();
32 
34 
35  // Errors (uncaught exceptions) and exit requests (because sys.exit()
36  // was called) are possible result types, in addition to the standard
37  // int, double, and string types. (Python uses doubles internally,
38  // so double is used instead of float.) If the python None object is
39  // returned or some other object is returned, the result type is "none".
40  // If you request a result type of PY_OBJECT, the raw PyObject * is
41  // set and it is up to you to decrement the reference count on it.
42  enum Type { INT, DOUBLE, STRING, INT_ARRAY, DOUBLE_ARRAY, STRING_ARRAY,
43  OPTIONS, PY_OBJECT, VOID_PTR, NONE, EXIT, ERR, VARIANT };
45 
46  // Type Fields Used
47  // ------- -----------
48  // INT myIntValue
49  // DOUBLE myDoubleValue
50  // STRING myStringValue
51  // INT_ARRAY myIntArray
52  // DOUBLE_ARRAY myDoubleArray
53  // STRING_ARRAY myStringArray
54  // OPTIONS myOptions
55  // PY_OBJECT myOpaquePyObject
56  // VOID_PTR myVoidPtr
57  // VARIANT myValue - Always filled in.
58  // NONE none
59  // EXIT myIntValue for exit code, myStringValue in case
60  // user called sys.exit() with a non-integer object
61  // ERR myDetailedErrValue for exception back trace
62  // myErrValue for a simplified error message
63  // myExceptionClass is the name of the exception (if any)
64 
66  double myDoubleValue;
68  std::vector<int> myIntArray;
69  std::vector<double> myDoubleArray;
76  void *myVoidPtr;
77 };
78 
79 #endif
UT_Variant myValue
Definition: PY_Result.h:33
UT_Options myOptions
Definition: PY_Result.h:71
UT_StringHolder myStringValue
Definition: PY_Result.h:67
typedef INT(WINAPI *PFNWGLGETGPUINFOAMDPROC)(UINT id
std::vector< int > myIntArray
Definition: PY_Result.h:68
std::vector< double > myDoubleArray
Definition: PY_Result.h:69
#define PY_API
Definition: PY_API.h:10
void * myVoidPtr
Definition: PY_Result.h:76
void * myOpaquePyObject
Definition: PY_Result.h:75
A map of string to various well defined value types.
Definition: UT_Options.h:84
UT_StringHolder myErrValue
Definition: PY_Result.h:72
UT_StringHolder myExceptionClass
Definition: PY_Result.h:74
UT_StringHolder myDetailedErrValue
Definition: PY_Result.h:73
PY_Result()
Definition: PY_Result.h:25
UT_StringArray myStringArray
Definition: PY_Result.h:70
Type myResultType
Definition: PY_Result.h:44
double myDoubleValue
Definition: PY_Result.h:66
int myIntValue
Definition: PY_Result.h:65