CArchive for mrpt::io::CStream classes (use as template argument).
Definition at line 546 of file CArchive.h.
#include <mrpt/serialization/CArchive.h>
Public Member Functions | |
CArchiveStreamBase (STREAM &s) | |
Protected Member Functions | |
size_t | write (const void *d, size_t n) override |
Writes a block of bytes. More... | |
size_t | read (void *d, size_t n) override |
Reads a block of bytes. More... | |
void | internal_ReadObject (CSerializable *newObj, const std::string &className, bool isOldFormat, int8_t version) |
Read the object. More... | |
void | internal_ReadObjectHeader (std::string &className, bool &isOldFormat, int8_t &version) |
Read the object Header. More... | |
Private Attributes | |
STREAM & | m_s |
Serialization API for generic "archives" I/O streams | |
size_t | ReadBuffer (void *Buffer, size_t Count) |
Reads a block of bytes from the stream into Buffer. More... | |
template<typename T > | |
size_t | ReadBufferFixEndianness (T *ptr, size_t ElementCount) |
Reads a sequence of elemental datatypes, taking care of reordering their bytes from the MRPT stream standard (little endianness) to the format of the running architecture. More... | |
void | WriteBuffer (const void *Buffer, size_t Count) |
Writes a block of bytes to the stream from Buffer. More... | |
template<typename T > | |
void | WriteBufferFixEndianness (const T *ptr, size_t ElementCount) |
Writes a sequence of elemental datatypes, taking care of reordering their bytes from the running architecture to MRPT stream standard (little endianness). More... | |
template<typename STORED_TYPE , typename CAST_TO_TYPE > | |
void | ReadAsAndCastTo (CAST_TO_TYPE &read_here) |
Read a value from a stream stored in a type different of the target variable, making the conversion via static_cast. More... | |
template<typename STORED_TYPE > | |
STORED_TYPE | ReadAs () |
De-serialize a variable and returns it by value. More... | |
template<typename TYPE_TO_STORE , typename TYPE_FROM_ACTUAL > | |
void | WriteAs (const TYPE_FROM_ACTUAL &value) |
void | WriteObject (const CSerializable *o) |
Writes an object to the stream. More... | |
void | WriteObject (const CSerializable &o) |
CSerializable::Ptr | ReadObject () |
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the object. More... | |
template<typename T > | |
T::Ptr | ReadObject () |
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the object. More... | |
void | ReadObject (CSerializable *existingObj) |
Reads an object from stream, where its class must be the same as the supplied object, where the loaded object will be stored in. More... | |
template<typename T , typename T2 , typename ... REST> | |
const mrpt::rtti::TRuntimeClassId * | findRegisteredClassInList (std::string_view strClassName) |
template<typename T > | |
const mrpt::rtti::TRuntimeClassId * | findRegisteredClassInList (std::string_view strClassName) |
template<typename... T> | |
std::variant< T... > | ReadVariant () |
Reads a variant from stream, its class determined at runtime, and returns a variant to the object. More... | |
template<typename T > | |
void | WriteVariant (T t) |
Writes a Variant to the stream. More... | |
template<typename T > | |
T | ReadPOD () |
Reads a simple POD type and returns by value. More... | |
void | sendMessage (const CMessage &msg) |
Send a message to the device. More... | |
bool | receiveMessage (CMessage &msg) |
Tries to receive a message from the device. More... | |
CArchive & | operator<< (const CSerializable &obj) |
Write a CSerializable object to a stream in the binary MRPT format. More... | |
CArchive & | operator<< (const CSerializable::Ptr &pObj) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
CArchive & | operator>> (CSerializable &obj) |
Reads a CSerializable object from the stream. More... | |
CArchive & | operator>> (CSerializable::Ptr &pObj) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename RET > | |
RET | ReadVariant_helper (CSerializable::Ptr &ptr) |
template<typename RET , typename T , typename... R> | |
RET | ReadVariant_helper (CSerializable::Ptr &ptr, std::enable_if_t< mrpt::is_shared_ptr< T >::value > *=nullptr) |
template<typename RET , typename T , typename... R> | |
RET | ReadVariant_helper (CSerializable::Ptr &ptr, std::enable_if_t<!mrpt::is_shared_ptr< T >::value > *=nullptr) |
|
inline |
Definition at line 551 of file CArchive.h.
|
inlineinherited |
Definition at line 236 of file CArchive.h.
References mrpt::rtti::TRuntimeClassId::className.
Referenced by mrpt::serialization::CArchive::ReadVariant().
|
inlineinherited |
Definition at line 243 of file CArchive.h.
References mrpt::rtti::TRuntimeClassId::className.
|
protectedinherited |
Read the object.
Definition at line 483 of file CArchive.cpp.
References mrpt::serialization::CArchive::ReadBuffer(), SERIALIZATION_END_FLAG, THROW_EXCEPTION, THROW_EXCEPTION_FMT, and THROW_TYPED_EXCEPTION.
Referenced by mrpt::serialization::CArchive::ReadObject(), and mrpt::serialization::CArchive::ReadVariant().
|
protectedinherited |
Read the object Header.
Definition at line 380 of file CArchive.cpp.
References ASSERT_, mrpt::serialization::CArchive::ReadBuffer(), mrpt::serialization::CArchive::ReadBufferFixEndianness(), THROW_EXCEPTION, THROW_STACKED_EXCEPTION_CUSTOM_MSG2, and THROW_TYPED_EXCEPTION.
Referenced by mrpt::serialization::CArchive::ReadObject(), and mrpt::serialization::CArchive::ReadVariant().
|
inherited |
Write a CSerializable object to a stream in the binary MRPT format.
Write an object to a stream in the binary MRPT format.
Definition at line 187 of file CArchive.cpp.
References mrpt::serialization::CArchive::WriteObject().
|
inherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 180 of file CArchive.cpp.
References mrpt::serialization::CArchive::WriteObject().
|
inherited |
Reads a CSerializable object from the stream.
Definition at line 199 of file CArchive.cpp.
References mrpt::serialization::CArchive::ReadObject().
|
inherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 193 of file CArchive.cpp.
References mrpt::serialization::CArchive::ReadObject().
|
inlineoverrideprotectedvirtual |
Reads a block of bytes.
std::exception | On any error, or if ZERO bytes are read. |
Implements mrpt::serialization::CArchive.
Definition at line 555 of file CArchive.h.
References mrpt::serialization::CArchiveStreamBase< STREAM >::m_s.
|
inlineinherited |
De-serialize a variable and returns it by value.
Definition at line 145 of file CArchive.h.
|
inlineinherited |
Read a value from a stream stored in a type different of the target variable, making the conversion via static_cast.
Useful for coding backwards compatible de-serialization blocks
Definition at line 137 of file CArchive.h.
Referenced by mrpt::maps::CPointsMap::TRenderOptions::readFromStream().
|
inherited |
Reads a block of bytes from the stream into Buffer.
std::exception | On any error, or if ZERO bytes are read. |
Definition at line 24 of file CArchive.cpp.
References ASSERT_, mrpt::serialization::CArchive::read(), and THROW_EXCEPTION.
Referenced by mrpt::serialization::CArchive::internal_ReadObject(), mrpt::serialization::CArchive::internal_ReadObjectHeader(), mrpt::serialization::CArchive::ReadBufferFixEndianness(), mrpt::serialization::CArchive::receiveMessage(), and mrpt::obs::CObservationVelodyneScan::serializeFrom().
|
inlineinherited |
Reads a sequence of elemental datatypes, taking care of reordering their bytes from the MRPT stream standard (little endianness) to the format of the running architecture.
ElementCount | The number of elements (not bytes) to read. |
ptr | A pointer to the first output element in an array (or std::vector<>, etc...). |
std::exception | On any error, or if ZERO bytes are read. |
Definition at line 84 of file CArchive.h.
References mrpt::serialization::CArchive::ReadBuffer(), and mrpt::reverseBytesInPlace().
Referenced by mrpt::serialization::CArchive::internal_ReadObjectHeader(), mrpt::math::operator>>(), mrpt::serialization::CArchive::ReadPOD(), and triangle_readFromStream().
|
inlineinherited |
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the object.
std::exception | On I/O error or undefined class. |
CExceptionEOF | On an End-Of-File condition found at a correct place: an EOF that abruptly finishes in the middle of one object raises a plain std::exception instead. |
Definition at line 167 of file CArchive.h.
Referenced by mrpt::serialization::CArchive::operator>>().
|
inlineinherited |
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the object.
This version is similar to mrpt::make_aligned_shared<T>.
std::exception | On I/O error or undefined class. |
CExceptionEOF | On an End-Of-File condition found at a correct place: an EOF that abruptly finishes in the middle of one object raises a plain std::exception instead. |
Definition at line 177 of file CArchive.h.
References mrpt::rtti::TRuntimeClassId::createObject(), mrpt::rtti::findRegisteredClass(), mrpt::serialization::CArchive::internal_ReadObject(), mrpt::serialization::CArchive::internal_ReadObjectHeader(), and THROW_EXCEPTION_FMT.
|
inherited |
Reads an object from stream, where its class must be the same as the supplied object, where the loaded object will be stored in.
std::exception | On I/O error or different class found. |
CExceptionEOF | On an End-Of-File condition found at a correct place: an EOF that abruptly finishes in the middle of one object raises a plain std::exception instead. |
Definition at line 526 of file CArchive.cpp.
References ASSERT_, mrpt::format(), mrpt::serialization::CSerializable::GetRuntimeClass(), mrpt::serialization::CArchive::internal_ReadObject(), mrpt::serialization::CArchive::internal_ReadObjectHeader(), and THROW_EXCEPTION.
|
inlineinherited |
Reads a simple POD type and returns by value.
Useful when stream >> var;
cannot be used becuase of errors of misaligned reference binding. Use with macro MRPT_READ_POD
to avoid typing the type T yourself.
s << var;
is safe for misaligned variables. Definition at line 305 of file CArchive.h.
References mrpt::serialization::CArchive::ReadBufferFixEndianness().
|
inlineinherited |
Reads a variant from stream, its class determined at runtime, and returns a variant to the object.
To be compatible with the current polymorphic system this support smart pointer types. For pointer types, This will bind to the first possible pointer type. variant<CSerializable::Ptr, CRenderizable::Ptr>
std::exception | On I/O error or undefined class. |
CExceptionEOF | On an End-Of-File condition found at a correct place: an EOF that abruptly finishes in the middle of one object raises a plain std::exception instead. |
Definition at line 261 of file CArchive.h.
References mrpt::rtti::TRuntimeClassId::createObject(), mrpt::serialization::CArchive::findRegisteredClassInList(), mrpt::serialization::CArchive::internal_ReadObject(), mrpt::serialization::CArchive::internal_ReadObjectHeader(), mrpt::serialization::CArchive::ReadVariant_helper(), and THROW_EXCEPTION_FMT.
Referenced by mrpt::serialization::operator>>().
|
inlineprivateinherited |
Definition at line 209 of file CArchive.h.
Referenced by mrpt::serialization::CArchive::ReadVariant(), and mrpt::serialization::CArchive::ReadVariant_helper().
|
inlineprivateinherited |
Definition at line 216 of file CArchive.h.
References IS_CLASS, R, and mrpt::serialization::CArchive::ReadVariant_helper().
|
inlineprivateinherited |
Definition at line 226 of file CArchive.h.
References IS_CLASS, R, and mrpt::serialization::CArchive::ReadVariant_helper().
|
inherited |
Tries to receive a message from the device.
std::exception | On communication errors |
Definition at line 603 of file CArchive.cpp.
References mrpt::serialization::CMessage::content, MAKEWORD16B, mrpt::system::os::memcpy(), MRPT_END, MRPT_START, mrpt::serialization::CArchive::ReadBuffer(), and mrpt::serialization::CMessage::type.
Send a message to the device.
Note that only the low byte from the "type" field will be used.
For frames of size < 255 the frame format is an array of bytes in this order:
For frames of size > 255 the frame format is an array of bytes in this order:
std::exception | On communication errors |
Definition at line 569 of file CArchive.cpp.
References mrpt::serialization::CMessage::content, mrpt::system::os::memcpy(), MRPT_END, MRPT_START, mrpt::serialization::CMessage::type, and mrpt::serialization::CArchive::WriteBuffer().
|
inlineoverrideprotectedvirtual |
Writes a block of bytes.
std::exception | On any error |
Implements mrpt::serialization::CArchive.
Definition at line 554 of file CArchive.h.
References mrpt::serialization::CArchiveStreamBase< STREAM >::m_s.
|
inlineinherited |
Definition at line 152 of file CArchive.h.
Referenced by mrpt::obs::CObservationCANBusJ1939::serializeTo(), mrpt::poses::CPoses2DSequence::serializeTo(), mrpt::poses::CPoses3DSequence::serializeTo(), mrpt::obs::CActionCollection::serializeTo(), mrpt::opengl::CSetOfObjects::serializeTo(), mrpt::obs::CActionRobotMovement3D::serializeTo(), mrpt::obs::CActionRobotMovement2D::serializeTo(), mrpt::hmtslam::CHierarchicalMHMap::serializeTo(), mrpt::maps::CSimpleMap::serializeTo(), mrpt::obs::CSensoryFrame::serializeTo(), mrpt::obs::CRawlog::serializeTo(), mrpt::maps::CMultiMetricMapPDF::serializeTo(), mrpt::obs::CObservationVelodyneScan::serializeTo(), and mrpt::obs::gnss::gnss_message::writeToStream().
Writes a block of bytes to the stream from Buffer.
std::exception | On any error |
Definition at line 48 of file CArchive.cpp.
References ASSERT_, THROW_EXCEPTION, and mrpt::serialization::CArchive::write().
Referenced by IMPLEMENT_CArchive_READ_WRITE_SIMPLE_TYPE(), mrpt::obs::gnss::Message_NV_OEM6_GENERIC_FRAME::internal_writeToStream(), mrpt::obs::gnss::Message_NV_OEM6_GENERIC_SHORT_FRAME::internal_writeToStream(), mrpt::obs::gnss::Message_NV_OEM6_RANGECMP::internal_writeToStream(), mrpt::obs::gnss::Message_NV_OEM6_VERSION::internal_writeToStream(), mrpt::serialization::operator<<(), mrpt::serialization::CArchive::sendMessage(), mrpt::math::CMatrixB::serializeTo(), mrpt::obs::CObservationCANBusJ1939::serializeTo(), mrpt::nav::CLogFileRecord::serializeTo(), mrpt::serialization::CMemoryChunkBase< Derived >::serializeTo(), mrpt::maps::CWirelessPowerGridMap2D::serializeTo(), mrpt::maps::CGasConcentrationGridMap2D::serializeTo(), mrpt::maps::CHeightGridMap2D_MRF::serializeTo(), mrpt::maps::CReflectivityGridMap2D::serializeTo(), mrpt::obs::CObservation2DRangeScan::serializeTo(), mrpt::maps::COccupancyGridMap2D::serializeTo(), mrpt::obs::CObservationVelodyneScan::serializeTo(), mrpt::maps::CRandomFieldGridMap3D::serializeTo(), mrpt::img::CImage::serializeTo(), mrpt::serialization::CArchive::WriteBufferFixEndianness(), mrpt::serialization::CArchive::WriteObject(), and mrpt::opengl::CRenderizable::writeToStreamRender().
|
inlineinherited |
Writes a sequence of elemental datatypes, taking care of reordering their bytes from the running architecture to MRPT stream standard (little endianness).
ElementCount | The number of elements (not bytes) to write. |
ptr | A pointer to the first input element in an array (or std::vector<>, etc...). Example of usage: |
std::exception | On any error |
Definition at line 123 of file CArchive.h.
References mrpt::serialization::CArchive::WriteBuffer().
Referenced by mrpt::math::operator<<(), mrpt::math::CPolygon::serializeTo(), mrpt::math::CMatrix::serializeTo(), mrpt::math::CMatrixD::serializeTo(), mrpt::maps::CColouredPointsMap::serializeTo(), mrpt::maps::CWeightedPointsMap::serializeTo(), mrpt::maps::CSimplePointsMap::serializeTo(), mrpt::obs::CObservation2DRangeScan::serializeTo(), mrpt::maps::COccupancyGridMap2D::serializeTo(), mrpt::obs::CObservation3DRangeScan::serializeTo(), and triangle_writeToStream().
|
inlineinherited |
Definition at line 159 of file CArchive.h.
References mrpt::serialization::CArchive::WriteObject().
Referenced by mrpt::serialization::CArchive::WriteObject().
|
inherited |
Writes an object to the stream.
Definition at line 142 of file CArchive.cpp.
References mrpt::rtti::TRuntimeClassId::className, mrpt::serialization::CSerializable::GetRuntimeClass(), MRPT_END, MRPT_START, SERIALIZATION_END_FLAG, mrpt::serialization::CSerializable::serializeGetVersion(), mrpt::serialization::CSerializable::serializeTo(), and mrpt::serialization::CArchive::WriteBuffer().
Referenced by mrpt::math::operator<<(), mrpt::serialization::CArchive::operator<<(), and mrpt::serialization::CArchive::WriteVariant().
|
inlineinherited |
Writes a Variant to the stream.
Definition at line 292 of file CArchive.h.
References mrpt::serialization::CArchive::WriteObject().
|
private |
Definition at line 548 of file CArchive.h.
Referenced by mrpt::serialization::CArchiveStreamBase< std::istream >::read(), mrpt::serialization::CArchiveStreamBase< std::iostream >::read(), mrpt::serialization::CArchiveStreamBase< STREAM >::read(), mrpt::serialization::CArchiveStreamBase< std::ostream >::write(), mrpt::serialization::CArchiveStreamBase< std::iostream >::write(), and mrpt::serialization::CArchiveStreamBase< STREAM >::write().
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at mié 12 jul 2023 10:03:34 CEST |