MADNESS  0.10.1
Classes | Namespaces | Macros | Functions | Variables

Interface templates for the archives (serialization). More...

#include <algorithm>
#include <type_traits>
#include <complex>
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstddef>
#include <cstring>
#include <array>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <optional>
#include <tuple>
#include <madness/config.h>
#include <madness/world/type_traits.h>
#include <madness/world/madness_exception.h>
Include dependency graph for archive.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  madness::archive::archive_array< T >
 Wrapper for dynamic arrays and pointers. More...
 
class  madness::archive::archive_ptr< T >
 Wrapper for an opaque pointer for serialization purposes. More...
 
struct  madness::archive::archive_typeinfo< T >
 Used to enable type checking inside archives. More...
 
struct  madness::archive::ArchiveImpl< Archive, T, Enabler >
 Default implementations of wrap_store and wrap_load. More...
 
struct  madness::archive::ArchiveImpl< Archive, archive_array< T > >
 Partial specialization of ArchiveImpl for archive_array. More...
 
struct  madness::archive::ArchiveImpl< Archive, T[n], std::enable_if_t<!std::is_same_v< T, char > &&is_serializable_v< Archive, T > > >
 Partial specialization of ArchiveImpl for fixed-dimension arrays that redirects to archive_array. More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, T, Enabler >
 Default load of an object via serialize(ar, t). More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, std::allocator< T >, std::enable_if_t<!is_future< T >::value &&is_serializable_v< Archive, T > > >
 Deserialize a std::allocator. More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, std::array< T, N >, std::enable_if_t< is_serializable_v< Archive, T > > >
 Deserialize a std::array. MADNESS_ASSERT 's that the size matches. More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, std::complex< T >, std::enable_if_t< is_serializable_v< Archive, T > > >
 Deserialize a complex number. More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, std::list< T, Alloc >, std::enable_if_t<!is_future< T >::value &&is_serializable_v< Archive, T > > >
 Deserialize a std::list. Clears and resizes as necessary. More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, std::map< T, Q, Compare, Alloc >, std::enable_if_t< is_serializable_v< Archive, T > &&is_serializable_v< Archive, Q > > >
 Deserialize an std::map. The map is not cleared; duplicate elements are replaced. More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, std::set< T, Compare, Alloc >, std::enable_if_t<!is_future< T >::value &&is_serializable_v< Archive, T > > >
 Deserialize a std::set. Clears and resizes as necessary. More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, std::string >
 Deserialize a std::string. Clears and resizes as necessary. More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, std::vector< bool, Alloc > >
 Deserialize a std::vector<bool>. Clears and resizes as necessary. More...
 
struct  madness::archive::ArchiveLoadImpl< Archive, std::vector< T, Alloc >, std::enable_if_t<!is_future< T >::value &&is_serializable_v< Archive, T > > >
 Deserialize a std::vector. Clears and resizes as necessary. More...
 
struct  madness::archive::ArchivePrePostImpl< Archive, T >
 Default implementation of the pre/postamble for type checking. More...
 
struct  madness::archive::ArchiveSerializeImpl< Archive, T, Enabler >
 Default symmetric serialization of a non-fundamental type that has serialize method. More...
 
struct  madness::archive::ArchiveSerializeImpl< Archive, resT(*)(paramT...), std::enable_if_t<!is_default_serializable_v< Archive, resT(*)(paramT...)> > >
 Serialize a function pointer. More...
 
struct  madness::archive::ArchiveSerializeImpl< Archive, resT(objT::*)(paramT...) const, std::enable_if_t<!is_default_serializable_v< Archive, resT(objT::*)(paramT...) const > > >
 Serialize a const member function pointer. More...
 
struct  madness::archive::ArchiveSerializeImpl< Archive, resT(objT::*)(paramT...), std::enable_if_t<!is_default_serializable_v< Archive, resT(objT::*)(paramT...)> > >
 Serialize a member function pointer. More...
 
struct  madness::archive::ArchiveSerializeImpl< Archive, std::optional< T >, std::enable_if_t< is_serializable_v< Archive, T > > >
 Serialize (deserialize) an std::optional. More...
 
struct  madness::archive::ArchiveSerializeImpl< Archive, std::pair< T, Q >, std::enable_if_t< is_serializable_v< Archive, T > &&is_serializable_v< Archive, Q > > >
 Serialize (deserialize) an std::pair. More...
 
struct  madness::archive::ArchiveSerializeImpl< Archive, std::tuple< Types... >, std::enable_if_t<(is_serializable_v< Archive, Types > &&...) > >
 Serialize (deserialize) a std::tuple. More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, T, Enabler >
 Default store of an object via serialize(ar, t). More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, std::allocator< T >, std::enable_if_t<!is_future< T >::value &&is_serializable_v< Archive, T > > >
 Serialize a std::allocator. More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, std::array< T, N >, std::enable_if_t< is_serializable_v< Archive, T > > >
 Serialize a std::array. More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, std::complex< T >, std::enable_if_t< is_serializable_v< Archive, T > > >
 Serialize a complex number. More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, std::list< T, Alloc >, std::enable_if_t<!is_future< T >::value &&is_serializable_v< Archive, T > > >
 Serialize a std::list. More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, std::map< T, Q, Compare, Alloc >, std::enable_if_t< is_serializable_v< Archive, T > &&is_serializable_v< Archive, Q > > >
 Serialize an std::map. More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, std::set< T, Compare, Alloc >, std::enable_if_t<!is_future< T >::value &&is_serializable_v< Archive, T > > >
 Serialize a std::set. More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, std::string >
 Serialize a 'std::string'. More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, std::vector< bool, Alloc > >
 Serialize a std::vector<bool> (as a plain array of bool). More...
 
struct  madness::archive::ArchiveStoreImpl< Archive, std::vector< T, Alloc >, std::enable_if_t<!is_future< T >::value &&is_serializable_v< Archive, T > > >
 Serialize a std::vector. More...
 
class  madness::archive::BaseArchive
 Base class for all archive classes. More...
 
class  madness::archive::BaseInputArchive
 Base class for input archive classes. More...
 
class  madness::archive::BaseOutputArchive
 Base class for output archive classes. More...
 

Namespaces

 madness
 File holds all helper structures necessary for the CC_Operator and CC2 class.
 
 madness::archive
 Namespace for I/O tools.
 

Macros

#define ARCHIVE_COOKIE   "archive"
 
#define ARCHIVE_MAJOR_VERSION   0
 Major version number for archive. More...
 
#define ARCHIVE_MINOR_VERSION   1
 Minor version number for archive. More...
 
#define ARCHIVE_REGISTER_TYPE(T, cooky)
 Used to associate a type with a cookie value inside archive. More...
 
#define ARCHIVE_REGISTER_TYPE_AND_PTR(T, cooky)
 Used to associate a type and a pointer to the type with a cookie value inside archive. More...
 
#define ARCHIVE_REGISTER_TYPE_AND_PTR_NAMES(T)
 Used to associate names with types and pointers to that type. More...
 
#define ARCHIVE_REGISTER_TYPE_NAME(T)
 Used to associate names with types. More...
 
#define ATI   ::madness::archive::archive_typeinfo
 Alias for archive_typeinfo. More...
 
#define ATN   ::madness::archive::archive_type_names
 Alias for archive_type_names. More...
 
#define MAD_ARCHIVE_DEBUG(s)
 Macro for helping debug archive tools. More...
 

Functions

void madness::archive::archive_initialize_type_names ()
 Initializes the type names for the archives. More...
 
template<class Archive , class T >
std::enable_if_t< is_default_serializable< Archive, T >::value &&is_archive< Archive >::value, void > madness::archive::default_serialize (const Archive &ar, const T &t)
 Redirect serialize(ar, t) to serialize(ar, &t, 1) for fundamental types. More...
 
template<class Archive , class T >
std::enable_if_t< is_output_archive< Archive >::value &&is_default_serializable< Archive, T >::value &&is_function_pointer_v< T >, void > madness::archive::default_serialize (const Archive &ar, const T *t, unsigned int n)
 Serialize an array of fundamental stuff. More...
 
template<class Archive , class T >
std::enable_if_t< is_output_archive< Archive >::value &&is_default_serializable< Archive, T >::value &&std::is_member_function_pointer< T >::value, void > madness::archive::default_serialize (const Archive &ar, const T *t, unsigned int n)
 
template<class Archive , class T >
std::enable_if_t< is_output_archive< Archive >::value &&!(is_function_pointer_v< T >||std::is_member_function_pointer< T >::value) &&is_default_serializable< Archive, T >::value, void > madness::archive::default_serialize (const Archive &ar, const T *t, unsigned int n)
 
template<class Archive , class T >
std::enable_if_t< is_input_archive< Archive >::value &&is_default_serializable< Archive, T >::value &&is_function_pointer_v< T >, void > madness::archive::default_serialize (const Archive &ar, const T *t, unsigned int n)
 Deserialize an array of fundamental stuff. More...
 
template<class Archive , class T >
std::enable_if_t< is_input_archive< Archive >::value &&is_default_serializable< Archive, T >::value &&std::is_member_function_pointer< T >::value, void > madness::archive::default_serialize (const Archive &ar, const T *t, unsigned int n)
 
template<class Archive , class T >
std::enable_if_t< is_input_archive< Archive >::value &&is_default_serializable< Archive, T >::value &&!(is_function_pointer_v< T >||std::is_member_function_pointer< T >::value), void > madness::archive::default_serialize (const Archive &ar, const T *t, unsigned int n)
 
template<typename T >
const char * madness::archive::get_type_name ()
 Returns the name of the type, or unknown if not registered. More...
 
template<class Archive , class T >
std::enable_if_t< is_output_archive_v< Archive >, const Archive & > madness::archive::operator& (const Archive &ar, const T &t)
 Redirect & to ArchiveImpl::wrap_store for output archives. More...
 
template<class Archive , class T >
std::enable_if_t< is_input_archive_v< Archive >, const Archive & > madness::archive::operator& (const Archive &ar, const T &t)
 Redirect & to ArchiveImpl::wrap_load for input archives. More...
 
template<class Archive , class T >
std::enable_if_t< is_output_archive_v< Archive >, const Archive & > madness::archive::operator<< (const Archive &ar, const T &t)
 Redirect << to ArchiveImpl::wrap_store for output archives. More...
 
template<class Archive , class T >
std::enable_if_t< is_input_archive_v< Archive >, const Archive & > madness::archive::operator>> (const Archive &ar, const T &t)
 Redirect >> to ArchiveImpl::wrap_load for input archives. More...
 
template<class Archive , class T >
std::enable_if_t<(!is_default_serializable< Archive, T >::value &&has_nonmember_serialize_v< T, Archive >) &&is_archive< Archive >::value, void > madness::archive::serialize (const Archive &ar, const T &t)
 Redirect serialize(ar,t) to ArchiveSerializeImpl for non-fundamental types. More...
 
template<class Archive , class T >
std::enable_if_t< ! is_default_serializable< Archive, T >::value &&is_archive< Archive >::value, void > madness::archive::serialize (const Archive &ar, const T *t, unsigned int n)
 Serialize (or deserialize) an array of non-fundamental stuff. More...
 
template<class T >
archive_array< Tmadness::archive::wrap (const T *ptr, unsigned int n)
 Factory function to wrap a dynamically allocated pointer as a typed archive_array. More...
 
template<class T >
archive_array< unsigned char > madness::archive::wrap_opaque (const T &t)
 Factory function to wrap a contiguous scalar as an opaque (uchar) archive_array. More...
 
template<class T >
archive_array< unsigned char > madness::archive::wrap_opaque (const T *ptr, unsigned int n)
 Factory function to wrap a pointer to contiguous data as an opaque (uchar) archive_array. More...
 
template<class T >
archive_ptr< Tmadness::archive::wrap_ptr (T *p)
 Wrapper for pointers. More...
 
function pointer serialization
Note
relative function pointers are represented by std::ptrdiff_t , with member function pointers represented by std::array<std::ptrdiff_t, N> (with N=2 on most common platforms, and a type-dependent constant on some (Microsoft))
Returns
function pointer to serve as the reference for computing relative pointers
Note
the value returned by this function is a pointer to a non-virtual member function, this helps on the platforms that use the parity to distinguish non-virtual and virtual pointers (e.g. Itanium ABI)
std::ptrdiff_t madness::archive::fn_ptr_origin ()
 
template<typename T , typename = std::enable_if_t<is_function_pointer_v<T>>>
T madness::archive::to_abs_fn_ptr (std::ptrdiff_t rel_fn_ptr)
 converts relative free or static member function pointer to the absolute function pointer More...
 
template<typename T , std::size_t N, typename = std::enable_if_t<std::is_member_function_pointer<std::remove_reference_t<T>>::value>>
auto madness::archive::to_abs_memfn_ptr (std::array< std::ptrdiff_t, N > rel_fn_ptr)
 converts relative (nonstatic) member function pointer to the absolute function pointer More...
 
template<typename T , typename = std::enable_if_t<std::is_function<T>::value || is_function_pointer<T>::value>>
std::ptrdiff_t madness::archive::to_rel_fn_ptr (const T &fn)
 converts function or (free or static member) function pointer to the relative function pointer More...
 
template<typename T , typename = std::enable_if_t<std::is_member_function_pointer<T>::value>>
auto madness::archive::to_rel_memfn_ptr (const T &fn)
 converts nonstatic member function pointer to the relative equivalent More...
 

Variables

const char * madness::archive::archive_type_names [256]
 The list of type names for use in archives. More...
 

Detailed Description

Interface templates for the archives (serialization).

Macro Definition Documentation

◆ ARCHIVE_COOKIE

#define ARCHIVE_COOKIE   "archive"
Todo:
Brief description needed.

◆ ARCHIVE_MAJOR_VERSION

#define ARCHIVE_MAJOR_VERSION   0

Major version number for archive.

◆ ARCHIVE_MINOR_VERSION

#define ARCHIVE_MINOR_VERSION   1

Minor version number for archive.

◆ MAD_ARCHIVE_DEBUG

#define MAD_ARCHIVE_DEBUG (   s)

Macro for helping debug archive tools.