Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JObjectStreamIO.hh
Go to the documentation of this file.
1#ifndef __JLANG__JOBJECTSTREAMIO__
2#define __JLANG__JOBJECTSTREAMIO__
3
4#include <fstream>
5
6#include "JLang/JObjectIO.hh"
7
8
9/**
10 * \author mdejong
11 */
12
13namespace JLANG {}
14namespace JPP { using namespace JLANG; }
15
16namespace JLANG {
17
18 /**
19 * Auxiliary base class for storing and loading a single object to and from an ASCII file, respectively.
20 * The implementation of this functionality is based on a static cast of
21 * the given template parameter (known as "curiously recurring template pattern").
22 */
23 template<class T>
25 /**
26 * Load from input file.
27 *
28 * \param file_name file name
29 */
30 void load(const char* file_name)
31 {
32 JLANG::load<std::ifstream>(file_name, static_cast<T&>(*this));
33 }
34
35
36 /**
37 * Store to output file.
38 *
39 * \param file_name file name
40 */
41 void store(const char* file_name) const
42 {
43 JLANG::store<std::ofstream>(file_name, static_cast<const T&>(*this));
44 }
45 };
46}
47
48#endif
General methods for loading and storing a single object from and to a file, respectively.
Auxiliary classes and methods for language specific functionality.
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 an ASCII file,...
void store(const char *file_name) const
Store to output file.
void load(const char *file_name)
Load from input file.