Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JEEP::JContainer< JContainer_t > Struct Template Reference

Auxiliary wrapper for I/O of container with optional comment (see JComment). More...

#include <JContainer.hh>

Inheritance diagram for JEEP::JContainer< JContainer_t >:
JLANG::JObjectStreamIO< T >

Public Types

typedef JContainer_t container_type
 

Public Member Functions

void load (const char *file_name)
 Load from input file.
 
void store (const char *file_name) const
 Store to output file.
 

Public Attributes

JComment comment
 

Friends

std::istream & operator>> (std::istream &in, JContainer &container)
 Read container from input.
 
std::ostream & operator<< (std::ostream &out, const JContainer &container)
 Write container to output.
 

Detailed Description

template<class JContainer_t>
struct JEEP::JContainer< JContainer_t >

Auxiliary wrapper for I/O of container with optional comment (see JComment).

When used in conjunction with the command line parser JPARSER::JParser,
the value at the corresponding option can contain data or be the name of a file.
The I/O of the actual container is handled via the auxiliary methods that are part of JStreamToolkit.hh.

Definition at line 39 of file JContainer.hh.

Member Typedef Documentation

◆ container_type

template<class JContainer_t >
JContainer_t JEEP::JContainer< JContainer_t >::container_type

Definition at line 43 of file JContainer.hh.

Member Function Documentation

◆ load()

template<class T >
void JLANG::JObjectStreamIO< T >::load ( const char * file_name)
inlineinherited

Load from input file.

Parameters
file_namefile name

Definition at line 30 of file JObjectStreamIO.hh.

31 {
32 JLANG::load<std::ifstream>(file_name, static_cast<T&>(*this));
33 }
void load(const std::string &file_name, T &object)
Load object from input file.
Definition JObjectIO.hh:55

◆ store()

template<class T >
void JLANG::JObjectStreamIO< T >::store ( const char * file_name) const
inlineinherited

Store to output file.

Parameters
file_namefile name

Definition at line 41 of file JObjectStreamIO.hh.

42 {
43 JLANG::store<std::ofstream>(file_name, static_cast<const T&>(*this));
44 }
void store(const std::string &file_name, const T &object)
Store object to output file.
Definition JObjectIO.hh:68

Friends And Related Symbol Documentation

◆ operator>>

template<class JContainer_t >
std::istream & operator>> ( std::istream & in,
JContainer< JContainer_t > & container )
friend

Read container from input.

Parameters
ininput stream
containercontainer
Returns
input stream

Definition at line 53 of file JContainer.hh.

54 {
55 using namespace JPP;
56
57 JStringStream is(in);
58
59 if (getFileStatus(is.str().c_str())) {
60 is.load();
61 }
62
63 is >> container.comment;
64
65 readObject(is, static_cast<container_type&>(container));
66
67 return in;
68 }
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JContainer_t container_type
Definition JContainer.hh:43

◆ operator<<

template<class JContainer_t >
std::ostream & operator<< ( std::ostream & out,
const JContainer< JContainer_t > & container )
friend

Write container to output.

Parameters
outoutput stream
containercontainer
Returns
output stream

Definition at line 78 of file JContainer.hh.

79 {
80 using namespace std;
81 using namespace JPP;
82
83 out << container.comment;
84
85 writeObject(out, "", static_cast<const container_type&>(container), '\n');
86
87 return out;
88 }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.

Member Data Documentation

◆ comment

template<class JContainer_t >
JComment JEEP::JContainer< JContainer_t >::comment

Definition at line 90 of file JContainer.hh.


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