Jpp  15.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "JIO/JFileStreamIO.hh"
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JIO {}
13 namespace JPP { using namespace JIO; }
14 
15 namespace JIO {
16 
17  /**
18  * Auxiliary base class for storing and loading a single object to and from a binary file, respectively.
19  * The implementation of this functionality is based on a static cast of
20  * the given template parameter (known as "curiously recurring template pattern").
21  */
22  template<class T>
23  struct JObjectBinaryIO {
24  /**
25  * Load from input file.
26  *
27  * \param file_name file name
28  */
29  void load(const char* file_name)
30  {
31  JLANG::load<JFileStreamReader>(file_name, static_cast<T&>(*this));
32  }
33 
34 
35  /**
36  * Store to output file.
37  *
38  * \param file_name file name
39  */
40  void store(const char* file_name) const
41  {
42  JLANG::store<JFileStreamWriter>(file_name, static_cast<const T&>(*this));
43  }
44  };
45 }
46 
47 #endif
void load(const char *file_name)
Load from input file.
Auxiliary base class for storing and loading a single object to and from a binary file...
do set_variable OUTPUT_DIRECTORY $WORKDIR T
General methods for loading and storing a single object from and to a file, respectively.
void store(const char *file_name) const
Store to output file.