36 #ifndef MADNESS_WORLD_TEXTFSAR_H__INCLUDED
37 #define MADNESS_WORLD_TEXTFSAR_H__INCLUDED
51 mutable std::ofstream os;
65 sprintf(tag,
"<t%d>", cookie);
66 os << tag << std::endl;
74 sprintf(tag,
"</t%d>",cookie);
75 os << tag << std::endl;
81 for (
long i=0; i<n; ++i)
82 os << t[i] << std::endl;
85 void store(
const char* t,
long )
const;
87 void store(
const unsigned char* t,
long n)
const {
88 for (
long i=0; i<n; ++i)
89 os << (
unsigned int) t[i] << std::endl;
110 mutable std::ifstream is;
113 void eat_eol()
const;
117 std::ios_base::openmode mode = std::ios_base::in)
120 open(filename, mode);
125 char tag[256], ftag[256];
126 is.getline(ftag,256);
129 sprintf(tag,
"</t%d>",cookie);
131 sprintf(tag,
"<t%d>",cookie);
133 if (strcmp(tag,ftag) != 0) {
134 std::cout <<
"TextFstreamInputArchive: type mismatch: expected=" << tag
138 <<
" got=" << ftag << std::endl;
139 MADNESS_EXCEPTION(
"TextFstreamInputArchive: check_tag: types do not match/corrupt file", 1);
145 check_start_tag<T>(
true);
151 for (
long i=0; i<n; ++i) is >> t[i];
155 void load(
unsigned char* t,
long n)
const;
157 void load(
char* t,
long n)
const;
159 void open(
const char* filename,
160 std::ios_base::openmode mode = std::ios_base::in);
189 #endif // MADNESS_WORLD_TEXTFSAR_H__INCLUDED
Wraps an archive around a text file stream for output.
Definition: textfsar.h:50
void store_end_tag() const
Definition: textfsar.h:71
void close()
Definition: textfsar.cc:83
TextFstreamOutputArchive(const char *filename=0, std::ios_base::openmode mode=std::ios_base::binary|std::ios_base::out|std::ios_base::trunc)
Definition: textfsar.h:54
static void postamble_store(const TextFstreamOutputArchive &ar)
Definition: textfsar.h:172
Interface templates for the archives (serialization)
void check_end_tag() const
Definition: textfsar.h:144
TextFstreamInputArchive(const char *filename=0, std::ios_base::openmode mode=std::ios_base::in)
Definition: textfsar.h:116
Wraps an archive around a text file stream for input.
Definition: textfsar.h:108
Default implementation of pre/postamble.
Definition: archive.h:641
madness::enable_if< madness::is_serializable< T > >::type store(const T *t, long n) const
Definition: textfsar.h:80
void flush()
Definition: textfsar.h:96
void store(const unsigned char *t, long n) const
Definition: textfsar.h:87
void open(const char *filename, std::ios_base::openmode mode=std::ios_base::out|std::ios_base::trunc)
Definition: textfsar.cc:63
void close()
Definition: textfsar.h:162
const char * archive_type_names[256]
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
madness::enable_if< madness::is_serializable< T > >::type load(T *t, long n) const
Definition: textfsar.h:150
Base class for output archives classes.
Definition: archive.h:583
void check_start_tag(bool end=false) const
Definition: textfsar.h:124
static void preamble_store(const TextFstreamOutputArchive &ar)
Definition: textfsar.h:169
const mpreal trunc(const mpreal &v)
Definition: mpreal.h:2618
#define MAD_ARCHIVE_DEBUG(s)
Definition: archive.h:438
~TextFstreamOutputArchive()
Definition: textfsar.h:101
void open(const char *filename, std::ios_base::openmode mode=std::ios_base::in)
Definition: textfsar.cc:137
void store_start_tag() const
Definition: textfsar.h:62
static void preamble_load(const TextFstreamInputArchive &ar)
Definition: textfsar.h:179
Definition: archive.h:471
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
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
static void postamble_load(const TextFstreamInputArchive &ar)
Definition: textfsar.h:182