Jpp
software
JLang
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
13
namespace
JLANG
{}
14
namespace
JPP
{
using namespace
JLANG
; }
15
16
namespace
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>
24
struct
JObjectStreamIO
{
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
JLANG::JObjectStreamIO::load
void load(const char *file_name)
Load from input file.
Definition:
JObjectStreamIO.hh:30
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
JObjectIO.hh
JLANG::JObjectStreamIO::store
void store(const char *file_name) const
Store to output file.
Definition:
JObjectStreamIO.hh:41
JLANG::JObjectStreamIO
Auxiliary base class for storing and loading a single object to and from an ASCII file,...
Definition:
JObjectStreamIO.hh:24
JLANG
Auxiliary classes and methods for language specific functionality.
Definition:
JAbstractClass.hh:10
Generated by
1.8.16