Base: modernize C++11
* remove redundant void-arg * use nullptr * replace deprecated headers
This commit is contained in:
@@ -34,13 +34,13 @@
|
||||
using namespace Base;
|
||||
|
||||
// returns a string which represent the object e.g. when printed in python
|
||||
std::string PersistencePy::representation(void) const
|
||||
std::string PersistencePy::representation() const
|
||||
{
|
||||
return std::string("<persistence object>");
|
||||
}
|
||||
|
||||
|
||||
Py::String PersistencePy::getContent(void) const
|
||||
Py::String PersistencePy::getContent() const
|
||||
{
|
||||
Base::StringWriter writer;
|
||||
// force all objects to write pure XML without files
|
||||
@@ -50,7 +50,7 @@ Py::String PersistencePy::getContent(void) const
|
||||
return Py::String (writer.getString());
|
||||
}
|
||||
|
||||
Py::Int PersistencePy::getMemSize(void) const
|
||||
Py::Int PersistencePy::getMemSize() const
|
||||
{
|
||||
return Py::Int((long)getPersistencePtr()->getMemSize());
|
||||
}
|
||||
@@ -58,10 +58,10 @@ Py::Int PersistencePy::getMemSize(void) const
|
||||
PyObject* PersistencePy::dumpContent(PyObject *args, PyObject *kwds)
|
||||
{
|
||||
int compression = 3;
|
||||
static char* kwds_def[] = {"Compression",NULL};
|
||||
static char* kwds_def[] = {"Compression",nullptr};
|
||||
PyErr_Clear();
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwds_def, &compression)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//setup the stream. the in flag is needed to make "read" work
|
||||
@@ -71,22 +71,22 @@ PyObject* PersistencePy::dumpContent(PyObject *args, PyObject *kwds)
|
||||
}
|
||||
catch (...) {
|
||||
PyErr_SetString(PyExc_IOError, "Unable parse content into binary representation");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//build the byte array with correct size
|
||||
if(!stream.seekp(0, stream.end)) {
|
||||
PyErr_SetString(PyExc_IOError, "Unable to find end of stream");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::stringstream::pos_type offset = stream.tellp();
|
||||
if (!stream.seekg(0, stream.beg)) {
|
||||
PyErr_SetString(PyExc_IOError, "Unable to find begin of stream");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ba = PyByteArray_FromStringAndSize(NULL, offset);
|
||||
PyObject* ba = PyByteArray_FromStringAndSize(nullptr, offset);
|
||||
|
||||
//use the buffer protocol to access the underlying array and write into it
|
||||
Py_buffer buf = Py_buffer();
|
||||
@@ -94,14 +94,14 @@ PyObject* PersistencePy::dumpContent(PyObject *args, PyObject *kwds)
|
||||
try {
|
||||
if(!stream.read((char*)buf.buf, offset)) {
|
||||
PyErr_SetString(PyExc_IOError, "Error copying data into byte array");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
PyBuffer_Release(&buf);
|
||||
}
|
||||
catch(...) {
|
||||
PyBuffer_Release(&buf);
|
||||
PyErr_SetString(PyExc_IOError, "Error copying data into byte array");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ba;
|
||||
@@ -111,21 +111,21 @@ PyObject* PersistencePy::restoreContent(PyObject *args)
|
||||
{
|
||||
PyObject* buffer;
|
||||
if( !PyArg_ParseTuple(args, "O", &buffer) )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
//check if it really is a buffer
|
||||
if( !PyObject_CheckBuffer(buffer) ) {
|
||||
PyErr_SetString(PyExc_TypeError, "Must be a buffer object");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_buffer buf;
|
||||
if(PyObject_GetBuffer(buffer, &buf, PyBUF_SIMPLE) < 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if(!PyBuffer_IsContiguous(&buf, 'C')) {
|
||||
PyErr_SetString(PyExc_TypeError, "Buffer must be contiguous");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//check if it really is a buffer
|
||||
@@ -136,7 +136,7 @@ PyObject* PersistencePy::restoreContent(PyObject *args)
|
||||
}
|
||||
catch (...) {
|
||||
PyErr_SetString(PyExc_IOError, "Unable to restore content");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
@@ -144,7 +144,7 @@ PyObject* PersistencePy::restoreContent(PyObject *args)
|
||||
|
||||
PyObject *PersistencePy::getCustomAttributes(const char*) const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int PersistencePy::setCustomAttributes(const char*,PyObject*)
|
||||
|
||||
Reference in New Issue
Block a user