I have the following enum defined in C++ API:
typedef enum RESULT_ENUM
{
SUCCESS,
ERR_INVALID_PORT_DEFINITION,
ERR_TOO_MANY_SAMPLES,
ERR_RECORDING_THREAD_ALREADY_RUNNING,
ERR_RECORDING_WITHOUT_APPLY_SETTINGS,
...
}RESULT;
I have a program in C++ that uses the API and creating:
RESULT res;
Then it uses functions from the API to set values inside res
, for example:
res = SetProfile(APP_PROFILE);
res = SetDynamicImageFilter(filterType);
res = StartCalibration();
I want to create a Python program that does the same (literally), using ctypes. How do I translate RESULT res;
in a pythonic way? How do I make it contain the desired results from the functions?
EDIT:
Those functions return values that match the RESULT
enumerators. I want to get those enumerators in Python, How can I do that? I'm currently getting numbers corresponding to the enumerators values.
The name to value mapping is not compiled into the binary.
All ctypes code that needs the value of a enum hard codes that value in the python.
If you wrap the C++ code in a python extension you can choose to expose the enum values as python symbols of your module.
If you control the C++ implementation you are calling you could add a helper fucntion to return the value of the enum you need.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.