Base: Quantity: return std::string
This commit is contained in:
committed by
Yorik van Havre
parent
9f7218ac75
commit
0b3adee2ab
@@ -127,10 +127,10 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
char* string {};
|
||||
if (PyArg_ParseTuple(args, "et", "utf-8", &string)) {
|
||||
QString qstr = QString::fromUtf8(string);
|
||||
std::string str(string);
|
||||
PyMem_Free(string);
|
||||
try {
|
||||
*self = Quantity::parse(qstr);
|
||||
*self = Quantity::parse(str);
|
||||
}
|
||||
catch (const Base::ParserError& e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
@@ -142,7 +142,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
if (PyArg_ParseTuple(args, "det", &f, "utf-8", &string)) {
|
||||
QString unit = QString::fromUtf8(string);
|
||||
std::string unit(string);
|
||||
PyMem_Free(string);
|
||||
try {
|
||||
*self = Quantity(f, unit);
|
||||
@@ -161,15 +161,15 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
PyObject* QuantityPy::getUserPreferred(PyObject* /*args*/)
|
||||
{
|
||||
QString uus;
|
||||
std::string uus;
|
||||
double factor {};
|
||||
Py::Tuple res(3);
|
||||
|
||||
QString uss = getQuantityPtr()->getUserString(factor, uus);
|
||||
auto uss = getQuantityPtr()->getUserString(factor, uus);
|
||||
|
||||
res[0] = Py::String(uss.toUtf8(), "utf-8");
|
||||
res[0] = Py::String(uss, "utf-8");
|
||||
res[1] = Py::Float(factor);
|
||||
res[2] = Py::String(uus.toUtf8(), "utf-8");
|
||||
res[2] = Py::String(uus, "utf-8");
|
||||
|
||||
return Py::new_reference_to(res);
|
||||
}
|
||||
@@ -236,9 +236,9 @@ PyObject* QuantityPy::getValueAs(PyObject* args)
|
||||
PyErr_Clear();
|
||||
char* string {};
|
||||
if (PyArg_ParseTuple(args, "et", "utf-8", &string)) {
|
||||
QString qstr = QString::fromUtf8(string);
|
||||
std::string str(string);
|
||||
PyMem_Free(string);
|
||||
quant = Quantity::parse(qstr);
|
||||
quant = Quantity::parse(str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ void QuantityPy::setUnit(Py::Object arg)
|
||||
|
||||
Py::String QuantityPy::getUserString() const
|
||||
{
|
||||
return {getQuantityPtr()->getUserString().toUtf8(), "utf-8"};
|
||||
return {getQuantityPtr()->getUserString(), "utf-8"};
|
||||
}
|
||||
|
||||
Py::Dict QuantityPy::getFormat() const
|
||||
|
||||
Reference in New Issue
Block a user