MCPcopy Create free account
hub / github.com/Kitware/VTK / vtkPythonGetStdStringValue

Function vtkPythonGetStdStringValue

Wrapping/PythonCore/vtkPythonArgs.cxx:129–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129inline bool vtkPythonGetStdStringValue(PyObject* o, std::string& a, const char* exctext)
130{
131 if (PyBytes_Check(o))
132 {
133 char* val;
134 Py_ssize_t len;
135 PyBytes_AsStringAndSize(o, &val, &len);
136 a = std::string(val, len);
137 return true;
138 }
139 else if (PyUnicode_Check(o))
140 {
141 Py_ssize_t len;
142 const char* val = PyUnicode_AsUTF8AndSize(o, &len);
143 a = std::string(val, len);
144 return true;
145 }
146
147 PyErr_SetString(PyExc_TypeError, exctext);
148 return false;
149}
150
151//------------------------------------------------------------------------------
152// Overloaded methods, mostly based on the above templates

Callers 2

vtkPythonGetValueFunction · 0.85
vtkPythonGetFilePathFunction · 0.85

Calls 1

stringClass · 0.50

Tested by

no test coverage detected