Jpp 20.0.0-rc.8
the software that should make you happy
Loading...
Searching...
No Matches
JObjectBinaryIO.hh
Go to the documentation of this file.
1#ifndef __JIO__JOBJECTBINARYIO__
2#define __JIO__JOBJECTBINARYIO__
3
4#include "JLang/JObjectIO.hh"
5#include "JLang/JZip.hh"
6
9
10/**
11 * \author mdejong
12 */
13
14namespace JIO {}
15namespace JPP { using namespace JIO; }
16
17namespace JIO {
18
19 /**
20 * Auxiliary base class for storing and loading a single object to and from a binary file, respectively.
21 * The implementation of this functionality is based on a static cast of
22 * the given template parameter (known as "curiously recurring template pattern").
23 */
24 template<class T>
26
27 /**
28 * Load from input file.
29 *
30 * \param file_name file name
31 */
32 void load(const char* file_name)
33 {
34 using namespace JPP;
35
36 if (is_gzipped(file_name))
37 JLANG::load<JGZFileStreamReader>(file_name, static_cast<T&>(*this));
38 else
39 JLANG::load<JFileStreamReader> (file_name, static_cast<T&>(*this));
40 }
41
42
43 /**
44 * Store to output file.
45 *
46 * \param file_name file name
47 */
48 void store(const char* file_name) const
49 {
50 using namespace JPP;
51
52 {
53 JLANG::store<JFileStreamWriter> (file_name, static_cast<const T&>(*this));
54 }
55 }
56 };
57}
58
59#endif
General methods for loading and storing a single object from and to a file, respectively.
gzip auxiliaries.
Auxiliary classes and methods for binary I/O.
void store(const std::string &file_name, const T &object)
Store object to output file.
Definition JObjectIO.hh:68
void load(const std::string &file_name, T &object)
Load object from input file.
Definition JObjectIO.hh:55
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary base class for storing and loading a single object to and from a binary file,...
void store(const char *file_name) const
Store to output file.
void load(const char *file_name)
Load from input file.