MADNESS  version 0.9
archive.h
Go to the documentation of this file.
1 /*
2  This file is part of MADNESS.
3 
4  Copyright (C) 2007,2010 Oak Ridge National Laboratory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20  For more information please contact:
21 
22  Robert J. Harrison
23  Oak Ridge National Laboratory
24  One Bethel Valley Road
25  P.O. Box 2008, MS-6367
26 
27  email: harrisonrj@ornl.gov
28  tel: 865-241-3937
29  fax: 865-572-0680
30 
31 
32  $Id$
33 */
34 
35 #ifndef MADNESS_WORLD_ARCHIVE_H__INCLUDED
36 #define MADNESS_WORLD_ARCHIVE_H__INCLUDED
37 
418 #include <complex>
419 #include <iostream>
420 #include <cstdio>
421 #include <vector>
422 #include <map>
423 #include <madness/world/typestuff.h>
424 //#include <madness/world/worldprofile.h>
425 #include <madness/world/enable_if.h>
426 #include <madness/world/worldexc.h>
427 
428 #define ARCHIVE_COOKIE "archive"
429 #define ARCHIVE_MAJOR_VERSION 0
430 #define ARCHIVE_MINOR_VERSION 1
431 
432 //#define MAD_ARCHIVE_DEBUG_ENABLE
433 
434 #ifdef MAD_ARCHIVE_DEBUG_ENABLE
435 #define MAD_ARCHIVE_DEBUG(s) s
436 //using std::endl;
437 #else
438 #define MAD_ARCHIVE_DEBUG(s)
439 #endif
440 
441 namespace madness {
442 
443 
444  // Forward declarations
445  template <typename T> class Tensor;
446 
447  namespace archive {
448 
449  // Forward declarations
450  template <class>
452  template <class T>
453  inline archive_array<T> wrap(const T*, unsigned int);
454  template <class T>
455  inline archive_array<unsigned char> wrap_opaque(const T*, unsigned int);
456  template <class T>
458 
459  // There are 64 empty slots for user types. Free space for
460  // registering user types begins at cookie=128.
461 
462 #ifdef MAD_ARCHIVE_TYPE_NAMES_CC
463  const char *archive_type_names[256];
464 #else
465  extern const char *archive_type_names[256];
466 #endif
468 
469  // Used to enable type checking inside archives
470  template <typename T>
472  static const unsigned char cookie = 255;
473  };
474 
475  // Returns the name of the type, or unknown if not registered.
476  template <typename T>
477  const char* get_type_name() {
478  return archive_type_names[archive_typeinfo<T>::cookie];
479  }
480 
481 
482 #if defined(ARCHIVE_REGISTER_TYPE_INSTANTIATE_HERE) && defined(ARCHIVE_REGISTER_TYPE_IBMBUG)
483 #define ARCHIVE_REGISTER_TYPE_XLC_EXTRA(T) \
484  ; const unsigned char archive_typeinfo< T >::cookie
485 #else
486 #define ARCHIVE_REGISTER_TYPE_XLC_EXTRA(T)
487 #endif
488 
500 
501 #define ARCHIVE_REGISTER_TYPE(T, cooky) \
502  template <> struct archive_typeinfo< T > { \
503  static const unsigned char cookie = cooky; \
504  } \
505  ARCHIVE_REGISTER_TYPE_XLC_EXTRA(T)
506 
507 #define ARCHIVE_REGISTER_TYPE_AND_PTR(T, cooky) \
508  ARCHIVE_REGISTER_TYPE(T, cooky); \
509  ARCHIVE_REGISTER_TYPE(T*, cooky+64)
510 
511 #define ATN ::madness::archive::archive_type_names
512 #define ATI ::madness::archive::archive_typeinfo
513 #define ARCHIVE_REGISTER_TYPE_NAME(T) \
514  if (strcmp(ATN[ATI< T >::cookie],"invalid")) {\
515  std::cout << "archive_register_type_name: slot/cookie already in use! "<< #T << " " << ATN[ATI< T >::cookie]<< std::endl; \
516  MADNESS_EXCEPTION("archive_register_type_name: slot/cookie already in use!", 0); \
517  } \
518  ATN[ATI< T >::cookie] = #T
519 
520 #define ARCHIVE_REGISTER_TYPE_AND_PTR_NAMES(T) \
521  ARCHIVE_REGISTER_TYPE_NAME(T); \
522  ARCHIVE_REGISTER_TYPE_NAME(T*)
523 
524  ARCHIVE_REGISTER_TYPE_AND_PTR(unsigned char,0);
525  ARCHIVE_REGISTER_TYPE_AND_PTR(unsigned short,1);
526  ARCHIVE_REGISTER_TYPE_AND_PTR(unsigned int,2);
527  ARCHIVE_REGISTER_TYPE_AND_PTR(unsigned long,3);
528  ARCHIVE_REGISTER_TYPE_AND_PTR(unsigned long long,4);
529  ARCHIVE_REGISTER_TYPE_AND_PTR(signed char,5);
530  ARCHIVE_REGISTER_TYPE_AND_PTR(char,5); // Needed, but why?
531  ARCHIVE_REGISTER_TYPE_AND_PTR(signed short,6);
532  ARCHIVE_REGISTER_TYPE_AND_PTR(signed int,7);
533  ARCHIVE_REGISTER_TYPE_AND_PTR(signed long,8);
534  ARCHIVE_REGISTER_TYPE_AND_PTR(signed long long,9);
538  ARCHIVE_REGISTER_TYPE_AND_PTR(long double,13);
539  ARCHIVE_REGISTER_TYPE_AND_PTR(std::complex<float>,14);
540  ARCHIVE_REGISTER_TYPE_AND_PTR(std::complex<double>,15);
541 
542  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<char>,20);
543  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<unsigned char>,21);
544  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<short>,22);
545  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<unsigned short>,23);
546  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<int>,24);
547  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<unsigned int>,25);
548  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<long>,26);
549  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<unsigned long>,27);
550  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<bool>,28);
551  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<float>,29);
552  ARCHIVE_REGISTER_TYPE_AND_PTR(std::vector<double>,30);
553 
555 
556  ARCHIVE_REGISTER_TYPE_AND_PTR(Tensor<int>,32);
557  ARCHIVE_REGISTER_TYPE_AND_PTR(Tensor<long>,33);
558  ARCHIVE_REGISTER_TYPE_AND_PTR(Tensor<float>,34);
559  ARCHIVE_REGISTER_TYPE_AND_PTR(Tensor<double>,35);
560  ARCHIVE_REGISTER_TYPE_AND_PTR(Tensor< std::complex<float> >,36);
561  ARCHIVE_REGISTER_TYPE_AND_PTR(Tensor< std::complex<double> >,37);
562 
564  class BaseArchive {
565  public:
566  static const bool is_archive = true;
567  static const bool is_input_archive = false;
568  static const bool is_output_archive = false;
569  static const bool is_parallel_archive = false;
572  }
573  }; // class BaseArchive
574 
576  class BaseInputArchive : public BaseArchive {
577  public:
578  static const bool is_input_archive = true;
579  }; // class BaseInputArchive
580 
581 
584  public:
585  static const bool is_output_archive = true;
586  }; // class BaseOutputArchive
587 
589 
593  template <typename T>
594  struct is_archive : public std::is_base_of<BaseArchive, T> {};
595 
597 
601  template <typename T>
602  struct is_input_archive : public std::is_base_of<BaseInputArchive, T> {};
603 
605 
609  template <typename T>
610  struct is_output_archive : public std::is_base_of<BaseOutputArchive, T> {};
611 
612  // Serialize an array of fundamental stuff
613  template <class Archive, class T>
615  serialize(const Archive& ar, const T* t, unsigned int n) {
616  MAD_ARCHIVE_DEBUG(std::cout << "serialize fund array" << std::endl);
617  ar.store(t,n);
618  }
619 
620 
621  // Deserialize an array of fundamental stuff
622  template <class Archive, class T>
623  typename enable_if_c< is_serializable<T>::value && is_input_archive<Archive>::value >::type
624  serialize(const Archive& ar, const T* t, unsigned int n) {
625  MAD_ARCHIVE_DEBUG(std::cout << "deserialize fund array" << std::endl);
626  ar.load((T*) t,n);
627  }
628 
629 
630  // (de)Serialize an array of non-fundamental stuff
631  template <class Archive, class T>
632  typename enable_if_c< ! is_serializable<T>::value && is_archive<Archive>::value >::type
633  serialize(const Archive& ar, const T* t, unsigned int n) {
634  MAD_ARCHIVE_DEBUG(std::cout << "(de)serialize non-fund array" << std::endl);
635  for (unsigned int i=0; i<n; ++i) ar & t[i];
636  }
637 
638 
640  template <class Archive, class T>
642  static inline void preamble_load(const Archive& ar) {
643  unsigned char ck = archive_typeinfo<T>::cookie;
644  unsigned char cookie;
645  ar.load(&cookie, 1); // cannot use >>
646  if (cookie != ck) {
647  char msg[255];
648  std::sprintf(msg,"InputArchive type mismatch: expected cookie "
649  "%u (%s) but got %u (%s) instead",
650  ck, archive_type_names[ck],
651  cookie,archive_type_names[cookie]);
652  std::cerr << msg << std::endl;
653  MADNESS_EXCEPTION(msg, static_cast<int>(cookie));
654  }
655  else {
656  MAD_ARCHIVE_DEBUG(std::cout << "read cookie " << archive_type_names[cookie] << std::endl);
657  }
658  }
659 
660 
662  static inline void preamble_store(const Archive& ar) {
663  unsigned char ck = archive_typeinfo<T>::cookie;
664  ar.store(&ck, 1); // cannot use <<
665  MAD_ARCHIVE_DEBUG(std::cout << "wrote cookie " << archive_type_names[ck] << std::endl);
666  }
667 
668 
670  static inline void postamble_load(const Archive& /*ar*/) {}
671 
673  static inline void postamble_store(const Archive& /*ar*/) {}
674  };
675 
676 
678  template <class Archive, class T>
680  static inline void serialize(const Archive& ar, T& t) {
681  t.serialize(ar);
682  }
683  };
684 
685 
686  // Redirect \c serialize(ar,t) to \c serialize(ar,&t,1) for fundamental types
687  template <class Archive, class T>
688  inline
689  typename enable_if_c< is_serializable<T>::value && is_archive<Archive>::value >::type
690  serialize(const Archive& ar, const T& t) {
691  MAD_ARCHIVE_DEBUG(std::cout << "serialize(ar,t) -> serialize(ar,&t,1)" << std::endl);
692  serialize(ar,&t,1);
693  }
694 
695 
696  // Redirect \c serialize(ar,t) to \c ArchiveSerializeImpl for non-fundamental types
697  template <class Archive, class T>
698  inline
699  typename enable_if_c< !is_serializable<T>::value && is_archive<Archive>::value >::type
700  serialize(const Archive& ar, const T& t) {
701  MAD_ARCHIVE_DEBUG(std::cout << "serialize(ar,t) -> ArchiveSerializeImpl" << std::endl);
703  }
704 
705 
707  template <class Archive, class T>
709  static inline void store(const Archive& ar, const T& t) {
710  MAD_ARCHIVE_DEBUG(std::cout << "store(ar,t) default" << std::endl);
711  serialize(ar,t);
712  }
713  };
714 
715 
717  template <class Archive, class T>
719  static inline void load(const Archive& ar, const T& t) {
720  MAD_ARCHIVE_DEBUG(std::cout << "load(ar,t) default" << std::endl);
721  serialize(ar,t);
722  }
723  };
724 
725 
727  template <class Archive, class T>
728  struct ArchiveImpl {
729  static inline const Archive& wrap_store(const Archive& ar, const T& t) {
730  MAD_ARCHIVE_DEBUG(std::cout << "wrap_store for default" << std::endl);
734  return ar;
735  }
736 
737  static inline const Archive& wrap_load(const Archive& ar, const T& t) {
738  MAD_ARCHIVE_DEBUG(std::cout << "wrap_load for default" << std::endl);
740  ArchiveLoadImpl<Archive,T>::load(ar,(T&) t); // Loses constness here!
742  return ar;
743  }
744  };
745 
746 
747  // Redirect \c << to ArchiveImpl::wrap_store for output archives
748  template <class Archive, class T>
749  inline
750  typename enable_if<is_output_archive<Archive>, const Archive&>::type
751  operator<<(const Archive& ar, const T& t) {
752  //PROFILE_FUNC;
754  }
755 
756  // Redirect \c >> to ArchiveImpl::wrap_load for input archives
757  template <class Archive, class T>
758  inline
759  typename enable_if<is_input_archive<Archive>, const Archive&>::type
760  operator>>(const Archive& ar, const T& t) {
761  //PROFILE_FUNC;
763  }
764 
765  // Redirect \c & to ArchiveImpl::wrap_store for output archives
766  template <class Archive, class T>
767  inline
768  typename enable_if<is_output_archive<Archive>, const Archive&>::type
769  operator&(const Archive& ar, const T& t) {
770  //PROFILE_FUNC;
772  }
773 
774  // Redirect \c & to ArchiveImpl::wrap_load for input archives
775  template <class Archive, class T>
776  inline
777  typename enable_if<is_input_archive<Archive>, const Archive&>::type
778  operator&(const Archive& ar, const T& t) {
779  //PROFILE_FUNC;
781  }
782 
783 
785 
787  template <class T>
788  class archive_ptr {
789  public:
790  T* ptr;
791 
792  archive_ptr(T* t = 0) : ptr(t) {}
793 
794  T& operator*(){return *ptr;}
795 
796  template <class Archive>
797  void serialize(const Archive& ar) {ar & wrap_opaque(&ptr, 1);}
798  };
799 
800  template <class T>
801  inline
803 
805  template <class T>
806  class archive_array {
807  public:
808  const T* ptr;
809  unsigned int n;
810 
811  archive_array(const T *ptr, unsigned int n) : ptr(ptr), n(n) {}
812 
813  archive_array() : ptr(0), n(0) {}
814  };
815 
816 
818  template <class T>
819  inline
820  archive_array<T> wrap(const T* ptr, unsigned int n) {
821  return archive_array<T>(ptr,n);
822  }
823 
825  template <class T>
826  inline
827  archive_array<unsigned char> wrap_opaque(const T* ptr, unsigned int n) {
828  return archive_array<unsigned char>((unsigned char*) ptr, n*sizeof(T));
829  }
830 
832  template <class T>
833  inline
835  return archive_array<unsigned char>((unsigned char*) &t,sizeof(t));
836  }
837 
839 
841  template <class Archive, class T>
842  struct ArchiveImpl< Archive, archive_array<T> > {
843  static inline const Archive& wrap_store(const Archive& ar, const archive_array<T>& t) {
844  MAD_ARCHIVE_DEBUG(std::cout << "wrap_store for archive_array" << std::endl);
846  //ar << t.n;
847  //ArchivePrePostImpl<Archive,T>::preamble_store(ar);
848  serialize(ar,(T *) t.ptr,t.n);
849  //ArchivePrePostImpl<Archive,T>::postamble_store(ar);
851  return ar;
852  }
853 
854  static inline const Archive& wrap_load(const Archive& ar, const archive_array<T>& t) {
855  MAD_ARCHIVE_DEBUG(std::cout << "wrap_load for archive_array" << std::endl);
857  //unsigned int n;
858  //ar >> n;
859  //if (n != t.n)
860  // MADNESS_EXCEPTION("deserializing archive_array: dimension mismatch", n);
861  //ArchivePrePostImpl<Archive,T>::preamble_load(ar);
862  serialize(ar,(T *) t.ptr,t.n);
863  //ArchivePrePostImpl<Archive,T>::postamble_load(ar);
865  return ar;
866  }
867  };
868 
869 
871  template <class Archive, class T, std::size_t n>
872  struct ArchiveImpl<Archive, T[n]> {
873  static inline const Archive& wrap_store(const Archive& ar, const T(&t)[n]) {
874  MAD_ARCHIVE_DEBUG(std::cout << "wrap_store for array" << std::endl);
875  ar << wrap(&t[0],n);
876  return ar;
877  }
878 
879  static inline const Archive& wrap_load(const Archive& ar, const T(&t)[n]) {
880  MAD_ARCHIVE_DEBUG(std::cout << "wrap_load for array" << std::endl);
881  ar >> wrap(&t[0],n);
882  return ar;
883  }
884  };
885 
886 
888  template <class Archive, typename T>
889  struct ArchiveStoreImpl< Archive, std::complex<T> > {
890  static inline void store(const Archive& ar, const std::complex<T>& c) {
891  MAD_ARCHIVE_DEBUG(std::cout << "serialize complex number" << std::endl);
892  ar & c.real() & c.imag();
893  }
894  };
895 
896 
898  template <class Archive, typename T>
899  struct ArchiveLoadImpl< Archive, std::complex<T> > {
900  static inline void load(const Archive& ar, std::complex<T>& c) {
901  MAD_ARCHIVE_DEBUG(std::cout << "deserialize complex number" << std::endl);
902  T r = 0, i = 0;
903  ar & r & i;
904  c = std::complex<T>(r,i);
905  }
906  };
907 
908 
910  template <class Archive, typename T>
911  struct ArchiveStoreImpl< Archive, std::vector<T> > {
912  static inline void store(const Archive& ar, const std::vector<T>& v) {
913  MAD_ARCHIVE_DEBUG(std::cout << "serialize STL vector" << std::endl);
914  ar & v.size();
915  ar & wrap(&v[0],v.size());
916  }
917  };
918 
919 
921  template <class Archive, typename T>
922  struct ArchiveLoadImpl< Archive, std::vector<T> > {
923  static void load(const Archive& ar, std::vector<T>& v) {
924  MAD_ARCHIVE_DEBUG(std::cout << "deserialize STL vector" << std::endl);
925  std::size_t n = 0ul;
926  ar & n;
927  if (n != v.size()) {
928  v.clear();
929  v.resize(n);
930  }
931  ar & wrap((T *) &v[0],n);
932  }
933  };
934 
936  template <class Archive>
937  struct ArchiveStoreImpl< Archive, std::vector<bool> > {
938  static inline void store(const Archive& ar, const std::vector<bool>& v) {
939  MAD_ARCHIVE_DEBUG(std::cout << "serialize STL vector<bool>" << std::endl);
940  std::size_t n = v.size();
941  bool* b = new bool[n];
942  for (std::size_t i=0; i<n; ++i) b[i] = v[i];
943  ar & n & wrap(b,v.size());
944  delete [] b;
945  }
946  };
947 
948 
950  template <class Archive>
951  struct ArchiveLoadImpl< Archive, std::vector<bool> > {
952  static void load(const Archive& ar, std::vector<bool>& v) {
953  MAD_ARCHIVE_DEBUG(std::cout << "deserialize STL vector" << std::endl);
954  std::size_t n = 0ul;
955  ar & n;
956  if (n != v.size()) {
957  v.clear();
958  v.resize(n);
959  }
960  bool* b = new bool[n];
961  ar & wrap(b,v.size());
962  for (std::size_t i=0; i<n; ++i) v[i] = b[i];
963  delete [] b;
964  }
965  };
966 
968  template <class Archive>
969  struct ArchiveStoreImpl< Archive, std::string > {
970  static void store(const Archive& ar, const std::string& v) {
971  MAD_ARCHIVE_DEBUG(std::cout << "serialize STL string" << std::endl);
972  ar & v.size();
973  ar & wrap((const char*) &v[0],v.size());
974  }
975  };
976 
977 
979  template <class Archive>
980  struct ArchiveLoadImpl< Archive, std::string > {
981  static void load(const Archive& ar, std::string& v) {
982  MAD_ARCHIVE_DEBUG(std::cout << "deserialize STL string" << std::endl);
983  std::size_t n = 0ul;
984  ar & n;
985  if (n != v.size()) {
986  v.clear();
987  v.resize(n);
988  }
989  ar & wrap((char*) &v[0],n);
990  }
991  };
992 
993 
995  template <class Archive, typename T, typename Q>
996  struct ArchiveSerializeImpl< Archive, std::pair<T,Q> > {
997  static inline void serialize(const Archive& ar, std::pair<T,Q>& t) {
998  MAD_ARCHIVE_DEBUG(std::cout << "(de)serialize STL pair" << std::endl);
999  ar & t.first & t.second;
1000  }
1001  };
1002 
1003 
1005  template <class Archive, typename T, typename Q>
1006  struct ArchiveStoreImpl< Archive, std::map<T,Q> > {
1007  static void store(const Archive& ar, const std::map<T,Q>& t) {
1008  MAD_ARCHIVE_DEBUG(std::cout << "serialize STL map" << std::endl);
1009  ar << t.size();
1010  for (typename std::map<T,Q>::const_iterator p = t.begin();
1011  p != t.end(); ++p) {
1012  // Fun and games here since IBM's iterator (const or
1013  // otherwise) gives us a const qualified key
1014  // (p->first) which buggers up the type matching
1015  // unless the user defines pair(T,Q) and pair(const
1016  // T,Q) to have cookie (which is tedious).
1017  std::pair<T,Q> pp = *p;
1018  ar & pp;
1019  }
1020  }
1021  };
1022 
1023 
1025  template <class Archive, typename T, typename Q>
1026  struct ArchiveLoadImpl< Archive, std::map<T,Q> > {
1027  static void load(const Archive& ar, std::map<T,Q>& t) {
1028  MAD_ARCHIVE_DEBUG(std::cout << "deserialize STL map" << std::endl);
1029  std::size_t n = 0;
1030  ar & n;
1031  while (n--) {
1032  std::pair<T,Q> p;
1033  ar & p;
1034  t[p.first] = p.second;
1035  }
1036  }
1037  };
1038 
1039 
1040 
1041  }
1042 }
1043 
1044 #endif // MADNESS_WORLD_ARCHIVE_H__INCLUDED
static const bool is_parallel_archive
Definition: archive.h:569
archive_ptr< T > wrap_ptr(T *p)
Definition: archive.h:802
static void postamble_store(const Archive &)
By default there is no postamble.
Definition: archive.h:673
archive_array()
Definition: archive.h:813
const char * get_type_name()
Definition: archive.h:477
Base class for all archives classes.
Definition: archive.h:564
archive_array< T > wrap(const T *, unsigned int)
Factory function to wrap dynamically allocated pointer as typed archive_array.
Definition: archive.h:820
static const Archive & wrap_store(const Archive &ar, const archive_array< T > &t)
Definition: archive.h:843
::std::string string
Definition: gtest-port.h:872
void archive_initialize_type_names()
Definition: archive_type_names.cc:51
Grossly simplified Boost-like type traits and templates.
Definition: mpreal.h:3066
Default symmetric serialization of a non-fundamental thingy.
Definition: archive.h:679
static void preamble_store(const Archive &ar)
Serialize a cookie for type checking.
Definition: archive.h:662
enable_if< is_input_archive< Archive >, const Archive & >::type operator>>(const Archive &ar, const T &t)
Definition: archive.h:760
static void load(const Archive &ar, std::map< T, Q > &t)
Definition: archive.h:1027
static void store(const Archive &ar, const T &t)
Definition: archive.h:709
Default implementation of pre/postamble.
Definition: archive.h:641
Wrapper for opaque pointer ... bitwise copy of the pointer ... no remapping performed.
Definition: archive.h:788
T & operator*()
Definition: archive.h:794
Default store of a thingy via serialize(ar,t)
Definition: archive.h:708
unsigned int n
Definition: archive.h:809
ARCHIVE_REGISTER_TYPE_AND_PTR(unsigned char, 0)
archive_array(const T *ptr, unsigned int n)
Definition: archive.h:811
const T * ptr
Definition: archive.h:808
static void store(const Archive &ar, const std::map< T, Q > &t)
Definition: archive.h:1007
const char * archive_type_names[256]
static const Archive & wrap_load(const Archive &ar, const T(&t)[n])
Definition: archive.h:879
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
T * ptr
Definition: archive.h:790
static const Archive & wrap_load(const Archive &ar, const T &t)
Definition: archive.h:737
BaseArchive()
Definition: archive.h:570
Checks that T is an output archive type.
Definition: archive.h:610
Base class for output archives classes.
Definition: archive.h:583
Checks that T is an archive type.
Definition: archive.h:594
Default load of a thingy via serialize(ar,t)
Definition: archive.h:718
void serialize(const Archive &ar)
Definition: archive.h:797
static void load(const Archive &ar, const T &t)
Definition: archive.h:719
enable_if< is_output_archive< Archive >, const Archive & >::type operator&(const Archive &ar, const T &t)
Definition: archive.h:769
Base class for input archives classes.
Definition: archive.h:576
static void serialize(const Archive &ar, std::pair< T, Q > &t)
Definition: archive.h:997
enable_if_c from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:46
Default implementation of wrap_store and wrap_load.
Definition: archive.h:728
enable_if_c< is_serializable< T >::value &&is_output_archive< Archive >::value >::type serialize(const Archive &ar, const T *t, unsigned int n)
Definition: archive.h:615
#define MAD_ARCHIVE_DEBUG(s)
Definition: archive.h:438
Wrapper for dynamic arrays and pointers.
Definition: archive.h:451
static void load(const Archive &ar, std::vector< T > &v)
Definition: archive.h:923
static void store(const Archive &ar, const std::vector< T > &v)
Definition: archive.h:912
static const unsigned char cookie
255 indicates unknown type
Definition: archive.h:472
static void load(const Archive &ar, std::string &v)
Definition: archive.h:981
archive_array< unsigned char > wrap_opaque(const T *, unsigned int)
Factory function to wrap pointer to contiguous data as opaque (uchar) archive_array.
Definition: archive.h:827
static void store(const Archive &ar, const std::string &v)
Definition: archive.h:970
archive_ptr(T *t=0)
Definition: archive.h:792
static void preamble_load(const Archive &ar)
Definition: archive.h:642
static const Archive & wrap_store(const Archive &ar, const T &t)
Definition: archive.h:729
Checks that T is an input archive type.
Definition: archive.h:602
Implements MadnessException.
Definition: archive.h:471
static void store(const Archive &ar, const std::complex< T > &c)
Definition: archive.h:890
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
static void load(const Archive &ar, std::complex< T > &c)
Definition: archive.h:900
static const Archive & wrap_store(const Archive &ar, const T(&t)[n])
Definition: archive.h:873
enable_if from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:60
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
enable_if< is_output_archive< Archive >, const Archive & >::type operator<<(const Archive &ar, const T &t)
Definition: archive.h:751
const double c
Definition: gfit.cc:200
FLOAT b(int j, FLOAT z)
Definition: y1.cc:79
Definition: type_traits_bits.h:183
static void store(const Archive &ar, const std::vector< bool > &v)
Definition: archive.h:938
static const Archive & wrap_load(const Archive &ar, const archive_array< T > &t)
Definition: archive.h:854
static void serialize(const Archive &ar, T &t)
Definition: archive.h:680
static void load(const Archive &ar, std::vector< bool > &v)
Definition: archive.h:952
static void postamble_load(const Archive &)
By default there is no postamble.
Definition: archive.h:670