Qual è il modo migliore di utilizzare standard C++ std :: string da cython? L'ultima distribuzione di cython dovrebbe renderlo facile in ogni caso, ma mi chiedo perché ci sono wrapper per std :: vector e non per std :: string ...Cython C++ e std :: string
9
A
risposta
11
Cython 0.16 includes wrappers for std::string, che può essere importato con:
from libcpp.string cimport string
8
Oops, questa domanda è stata appesa qui per alcuni giorni. Alla fine l'ho fatto:
cdef extern from "string" namespace "std":
cdef cppclass string:
char* c_str()
che non è una soluzione completa ma ancora fa la cosa.
+0
vorrei aggiungere stringa (char *) anche. Questo ti dà avanti e indietro da e verso le stringhe Python. – meawoppl
Problemi correlati
- 1. Differenza tra std: string e std :: string
- 2. C++ std :: string su booleano
- 3. std :: string :: c_str() e provvisori
- 4. C++ Comportamento errato dell'inizializzazione std :: string
- 5. SWIG: come avvolgere std :: string & (std :: string passato per riferimento)
- 6. C++ È uno std :: string un contenitore?
- 7. Ottieni il tipo da std :: string, C++
- 8. Ottieni byte da std :: string in C++
- 9. C++/CLI Conversione da System :: String^a std :: string
- 10. C++ .NET converti System :: String in std :: string
- 11. Usando sprintf con std :: string in C++
- 12. C++ 11 rappresentazione std :: string interna (libstdC++)
- 13. Converti float in std :: string in C++
- 14. Cython: lavorare con C++ flussi
- 15. Propagazione C++ eccezione per Cython - eccezione pitone
- 16. prestazioni std :: strstr vs. std :: string :: trovare
- 17. std :: vector <std::string> crash
- 18. Perché non è std :: string :: max_size() == std :: string :: allocator :: max_size()
- 19. Come trasformare System :: String^in std :: string?
- 20. std :: string :: iterator per offset e back
- 21. std :: string e Unicode codificato UTF-8
- 22. Riutilizza uno std :: string spostato?
- 23. Come posso assumere la proprietà di un C++ std :: string char data senza copiare e mantenere l'oggetto std :: string?
- 24. std :: string a LPCTSTR
- 25. Std :: string pool di C++, build di debug? std :: problemi di stringa e valgrind
- 26. Organizzazione del progetto con Cython e C++
- 27. Funzione C Wrapping in Cython e NumPy
- 28. std :: string x (x);
- 29. restituendo std :: string/std :: lista da dll
- 30. Qual è la differenza tra "std :: string const & s" e "const std :: string & s"?
Sembra molto meglio. – dsign
Sembra che la mia dichiarazione con Cython 0.16 su OSX non sia compatibile con Cython 0.17 su Linux, con OSX si ottiene 'Can not Convertire 'string' su oggetto Python' – linello