Jpp 21.0.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JTOOLS::JDriver< JClass_t > Class Template Reference

Auxiliary class to load and store objects. More...

#include <JDriver.hh>

Static Public Member Functions

static JClass_t * load ()
 Load object.
 
static JClass_t * load (std::istream &in)
 Load object.
 
template<class T >
static void store (std::ostream &out, const T *p)
 Store object.
 

Static Private Member Functions

static JClass_t * load (std::false_type option)
 Load object without input.
 
static JClass_t * load (std::istream &in, std::false_type option)
 Load object without input.
 
static JClass_t * load (std::istream &in, std::true_type option)
 Load object with input.
 
static void store (std::ostream &out, const JClass_t *p, std::false_type option)
 Store object without output.
 
static void store (std::ostream &out, const JClass_t *p, std::true_type option)
 Store object with output.
 

Detailed Description

template<class JClass_t>
class JTOOLS::JDriver< JClass_t >

Auxiliary class to load and store objects.

Definition at line 26 of file JDriver.hh.

Member Function Documentation

◆ load() [1/5]

template<class JClass_t >
static JClass_t * JTOOLS::JDriver< JClass_t >::load ( std::false_type option)
inlinestaticprivate

Load object without input.

Parameters
optionI/O option
Returns
pointer to newly loaded object

Definition at line 34 of file JDriver.hh.

35 {
36 return new JClass_t();
37 }

◆ load() [2/5]

template<class JClass_t >
static JClass_t * JTOOLS::JDriver< JClass_t >::load ( std::istream & in,
std::false_type option )
inlinestaticprivate

Load object without input.

Parameters
ininput stream
optionI/O option
Returns
pointer to newly loaded object

Definition at line 47 of file JDriver.hh.

48 {
49 return load(option);
50 }
static JClass_t * load()
Load object.
Definition JDriver.hh:110

◆ load() [3/5]

template<class JClass_t >
static JClass_t * JTOOLS::JDriver< JClass_t >::load ( std::istream & in,
std::true_type option )
inlinestaticprivate

Load object with input.

Parameters
ininput stream
optionI/O option
Returns
pointer to newly loaded object

Definition at line 60 of file JDriver.hh.

61 {
62 JClass_t* p = load(std::false_type());
63
64 in >> *p;
65
66 if (in.fail()) {
67
68 delete p;
69
70 p = NULL;
71 }
72
73 return p;
74 }

◆ store() [1/3]

template<class JClass_t >
static void JTOOLS::JDriver< JClass_t >::store ( std::ostream & out,
const JClass_t * p,
std::false_type option )
inlinestaticprivate

Store object without output.

This implementation doesn't do anything.

Parameters
outoutput stream
optionI/O option
ppointer to object

Definition at line 85 of file JDriver.hh.

86 {}

◆ store() [2/3]

template<class JClass_t >
static void JTOOLS::JDriver< JClass_t >::store ( std::ostream & out,
const JClass_t * p,
std::true_type option )
inlinestaticprivate

Store object with output.

Parameters
outoutput stream
optionI/O option
ppointer object

Definition at line 96 of file JDriver.hh.

97 {
98 if (p != NULL) {
99 out << *p;
100 }
101 }

◆ load() [4/5]

template<class JClass_t >
static JClass_t * JTOOLS::JDriver< JClass_t >::load ( )
inlinestatic

Load object.

Returns
pointer to newly loaded object

Definition at line 110 of file JDriver.hh.

111 {
112 return load(std::bool_constant<JStreamAvailable<JClass_t>::has_istream>());
113 }
Test availability of stream operators.

◆ load() [5/5]

template<class JClass_t >
static JClass_t * JTOOLS::JDriver< JClass_t >::load ( std::istream & in)
inlinestatic

Load object.

Parameters
ininput stream
Returns
pointer to newly loaded object

Definition at line 122 of file JDriver.hh.

123 {
124 return load(in, std::bool_constant<JStreamAvailable<JClass_t>::has_istream>());
125 }

◆ store() [3/3]

template<class JClass_t >
template<class T >
static void JTOOLS::JDriver< JClass_t >::store ( std::ostream & out,
const T * p )
inlinestatic

Store object.

Parameters
outoutput stream
ppointer to object

Definition at line 135 of file JDriver.hh.

136 {
137 store(out, dynamic_cast<const JClass_t*>(p), std::bool_constant<JStreamAvailable<JClass_t>::has_ostream>());
138 }
static void store(std::ostream &out, const JClass_t *p, std::false_type option)
Store object without output.
Definition JDriver.hh:85

The documentation for this class was generated from the following file: