Struct cv::gapi::s11n::detail::S11N#
This structure allows to implement serialization routines for custom types. View details
#include <opencv2/gapi/s11n/base.hpp>Collaboration diagram for cv::gapi::s11n::detail::S11N:
Detailed Description#
-
template<typename T>
struct S11N : public cv::gapi::s11n::detail::NotImplemented# This structure allows to implement serialization routines for custom types.
The default S11N for custom types is not implemented.
Example of usage:
namespace cv { namespace gapi { namespace s11n { namespace detail { template<> struct S11N<SimpleCustomType> { static void serialize(IOStream &os, const SimpleCustomType &p) { os << p.val; } static SimpleCustomType deserialize(IIStream &is) { SimpleCustomType p; is >> p.val; return p; } }; template<> struct S11N<SimpleCustomType2> { static void serialize(IOStream &os, const SimpleCustomType2 &p) { os << p.val << p.name << p.vec << p.mmap; } static SimpleCustomType2 deserialize(IIStream &is) { SimpleCustomType2 p; is >> p.val >> p.name >> p.vec >> p.mmap; return p; } }; } // namespace detail } // namespace s11n } // namespace gapi } // namespace cv
Note
When providing an overloaded implementation for S11N with your type don’t inherit it from NotImplemented structure.
Note
There are lots of overloaded >> and << operators for basic and OpenCV/G-API types which can be utilized when serializing a custom type.
Member Function Documentation#
deserialize()#
static T cv::gapi::s11n::detail::S11N::deserialize(IIStream &)
This function allows user to deserialize their custom type.
Note
The default overload throws an exception if called. User need to properly overload the function to use it.
serialize()#
static void cv::gapi::s11n::detail::S11N::serialize(
IOStream & ,
const T & )
This function allows user to serialize their custom type.
Note
The default overload throws an exception if called. User need to properly overload the function to use it.
Source file#
The documentation for this struct was generated from the following file:
opencv2/gapi/s11n/base.hpp