OpenCV 5.0.0-pre
Open Source Computer Vision
Loading...
Searching...
No Matches
cv::gapi::s11n::detail::S11N< T > Struct Template Reference

This structure allows to implement serialization routines for custom types. More...

#include <opencv2/gapi/s11n/base.hpp>

Collaboration diagram for cv::gapi::s11n::detail::S11N< T >:

Static Public Member Functions

static T deserialize (IIStream &)
 This function allows user to deserialize their custom type.
 
static void serialize (IOStream &, const T &)
 This function allows user to serialize their custom type.
 

Detailed Description

template<typename T>
struct cv::gapi::s11n::detail::S11N< T >

This structure allows to implement serialization routines for custom types.

The default S11N for custom types is not implemented.

Note
When providing an overloaded implementation for S11N with your type don't inherit it from NotImplemented structure.
There are lots of overloaded >> and << operators for basic and OpenCV/G-API types which can be utilized when serializing a custom type.

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

Member Function Documentation

◆ deserialize()

template<typename T >
static T cv::gapi::s11n::detail::S11N< T >::deserialize ( IIStream & )
inlinestatic

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()

template<typename T >
static void cv::gapi::s11n::detail::S11N< T >::serialize ( IOStream & ,
const T &  )
inlinestatic

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.

The documentation for this struct was generated from the following file: