Jak obsługiwać typ powrotu C ++ std :: vector <int> w typach Pythona?
Nie mogę znaleźć sposobu, w jaki ctypes wypełnią lukę międzystd::vector
i Python; nie, gdzie w Internecie jest wspomniana kombinacja. Czy ta zła praktyka nie istnieje, czy coś mi brakuje?
C ++ : xxx.cpp
#include <fstream>
#include <string>
using namespace std;
extern "C" std::vector<int> foo(const char* FILE_NAME)
{
string line;
std::vector<int> result;
ifstream myfile(FILE_NAME);
while (getline(myfile, line)) {
result.push_back(1);
}
return(result);
}
Pyton: xxx.py
import ctypes
xxx = ctypes.CDLL("./libxxx.so")
xxx.foo.argtypes = ??????
xxx.foo.restype = ??????