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