ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccSerializableObject.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "../casters.h"
10 #include <pybind11/pybind11.h>
11 #include <pybind11/stl.h>
12 #include <pybind11/stl_bind.h>
13 
14 namespace py = pybind11;
15 using namespace pybind11::literals;
16 
17 void define_ccSerializableObject(py::module &m)
18 {
19  py::class_<ccSerializableObject>(m, "ccSerializableObject")
20  .def(py::init<>())
21  .def("isSerializable", &ccSerializableObject::isSerializable)
22  .def("toFile", &ccSerializableObject::toFile, py::arg("out"), py::arg("dataVersion"))
23  .def("fromFile", &ccSerializableObject::fromFile)
24  .def("minimumFileVersion", &ccSerializableObject::minimumFileVersion)
25  .def_static("WriteError", &ccSerializableObject::WriteError)
26  .def_static("ReadError", &ccSerializableObject::ReadError)
27  .def_static("MemoryError", &ccSerializableObject::MemoryError)
28  .def_static("CorruptError", &ccSerializableObject::CorruptError);
29 }
30 
31 void define_ccSerializationHelper(py::module &m)
32 {
33  py::class_<ccSerializationHelper>(m, "ccSerializationHelper")
34  .def_static("CoordsFromDataStream", &ccSerializationHelper::CoordsFromDataStream)
35  .def_static("ScalarsFromDataStream", &ccSerializationHelper::ScalarsFromDataStream);
36 }
void define_ccSerializableObject(py::module &m)
void define_ccSerializationHelper(py::module &m)
static bool CorruptError()
Sends a custom error message (corrupted file) and returns 'false'.
virtual bool isSerializable() const
Returns whether object is serializable of not.
static bool ReadError()
Sends a custom error message (read error) and returns 'false'.
virtual short minimumFileVersion() const =0
Returns the minimum file version required to save this instance.
static bool WriteError()
Sends a custom error message (write error) and returns 'false'.
virtual bool toFile(QFile &out, short dataVersion) const
Saves data to binary stream.
virtual bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap)
Loads data from binary stream.
static bool MemoryError()
Sends a custom error message (not enough memory) and returns 'false'.
static void ScalarsFromDataStream(QDataStream &stream, int flags, ScalarType *out, unsigned count=1)
static void CoordsFromDataStream(QDataStream &stream, int flags, PointCoordinateType *out, unsigned count=1)