Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Stroika::Foundation::DataExchange::DefaultSerializer< T > Struct Template Reference

function object which serializes type T to a BLOB (or BLOB like) object More...

#include <DefaultSerializer.h>

Public Member Functions

Memory::BLOB operator() (const T &t) const
 

Detailed Description

template<typename T>
struct Stroika::Foundation::DataExchange::DefaultSerializer< T >

function object which serializes type T to a BLOB (or BLOB like) object

This is (at least originally) intended to be used by Cryptography::Hash<T>, but will probably be useful for many operations that need to treat a type T as a sequence of bytes

NOTE - not always defined - since we dont know how to serialze everthing - callers may need to specialize this

For now, this works with T: o is_trivially_copy_constructible_v (e.g. int, float, uint32_t, etc) o const char* o std::string o Memory::BLOB (just passed throgh, not adpated)

ALSO, MANY other Stroika classes support this by providing their own specialization of DefaultSerializer<> For example: o Characters::String o IO::Network::InternetAddress ...

Example Usage (specializing and USING DefaultSerializer)
Note
Design Note We chose to have this return Memory::BLOB instead of an abstract template type which was often Memory::BLOB but could be something more efficient, because I'm still supporting C++17 (no concepts) and I think Memory::BLOB can be made VERY NEARLY as efficient (by having a constructor which uses block allocation and pre-storages (InlineBuffer) the space for small objects (small strings and ints etc) (maybe do this performance tweak for Stroika 2.1b6?)

Definition at line 62 of file DefaultSerializer.h.

Member Function Documentation

◆ operator()()

template<typename T >
Memory::BLOB DataExchange::DefaultSerializer::operator() ( const T &  t) const

Convert the given t (of type T) to a Memory::BLOB; This should be as quick and efficient as practical.

Definition at line 2076 of file String.cpp.


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