HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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_Options.h>
16 #include <UT/UT_Variant.h>
17 
18 // This class contains information about the return value of python code
19 // that was executed.
21 {
22 public:
24  : myResultType(NONE)
25  , myStringValue(UT_String::ALWAYS_DEEP)
26  , myErrValue(UT_String::ALWAYS_DEEP)
27  , myDetailedErrValue(UT_String::ALWAYS_DEEP)
28  , myExceptionClass(UT_String::ALWAYS_DEEP)
29  , myOpaquePyObject(NULL)
30  , myVoidPtr(NULL)
31  {}
32 
33  UT_StringHolder asStringForDebugging();
34 
36 
37  // Errors (uncaught exceptions) and exit requests (because sys.exit()
38  // was called) are possible result types, in addition to the standard
39  // int, double, and string types. (Python uses doubles internally,
40  // so double is used instead of float.) If the python None object is
41  // returned or some other object is returned, the result type is "none".
42  // If you request a result type of PY_OBJECT, the raw PyObject * is
43  // set and it is up to you to decrement the reference count on it.
44  enum Type { INT, DOUBLE, STRING, INT_ARRAY, DOUBLE_ARRAY, STRING_ARRAY,
45  OPTIONS, PY_OBJECT, VOID_PTR, NONE, EXIT, ERR, VARIANT };
47 
48  // Type Fields Used
49  // ------- -----------
50  // INT myIntValue
51  // DOUBLE myDoubleValue
52  // STRING myStringValue
53  // INT_ARRAY myIntArray
54  // DOUBLE_ARRAY myDoubleArray
55  // STRING_ARRAY myStringArray
56  // OPTIONS myOptions
57  // PY_OBJECT myOpaquePyObject
58  // VOID_PTR myVoidPtr
59  // VARIANT myValue - Always filled in.
60  // NONE none
61  // EXIT myIntValue for exit code, myStringValue in case
62  // user called sys.exit() with a non-integer object
63  // ERR myDetailedErrValue for exception back trace
64  // myErrValue for a simplified error message
65  // myExceptionClass is the name of the exception (if any)
66 
68  double myDoubleValue;
70  std::vector<int> myIntArray;
71  std::vector<double> myDoubleArray;
78  void *myVoidPtr;
79 };
80 
81 #endif
UT_String myErrValue
Definition: PY_Result.h:74
UT_Variant myValue
Definition: PY_Result.h:35
UT_Options myOptions
Definition: PY_Result.h:73
std::vector< int > myIntArray
Definition: PY_Result.h:70
std::vector< double > myDoubleArray
Definition: PY_Result.h:71
#define PY_API
Definition: PY_API.h:10
UT_String myStringValue
Definition: PY_Result.h:69
UT_String myDetailedErrValue
Definition: PY_Result.h:75
void * myVoidPtr
Definition: PY_Result.h:78
void * myOpaquePyObject
Definition: PY_Result.h:77
A map of string to various well defined value types.
Definition: UT_Options.h:42
PY_Result()
Definition: PY_Result.h:23
UT_String myExceptionClass
Definition: PY_Result.h:76
UT_StringArray myStringArray
Definition: PY_Result.h:72
Type myResultType
Definition: PY_Result.h:46
double myDoubleValue
Definition: PY_Result.h:68
int myIntValue
Definition: PY_Result.h:67