Line data Source code
1 : //--------------------------------------------------------------------------
2 : #ifndef HEPMC_STREAM_HELPERS_H
3 : #define HEPMC_STREAM_HELPERS_H
4 :
5 : //////////////////////////////////////////////////////////////////////////
6 : // garren@fnal.gov, March 2009
7 : //
8 : // This header contains helper functions used by streaming IO
9 : //////////////////////////////////////////////////////////////////////////
10 :
11 : #include <ostream>
12 : #include <istream>
13 :
14 : #include "HepMC/GenEvent.h"
15 : #include "HepMC/TempParticleMap.h"
16 :
17 : namespace HepMC {
18 :
19 : namespace detail {
20 :
21 : /// used by IO_GenEvent constructor
22 : std::ostream & establish_output_stream_info( std::ostream & );
23 : /// used by IO_GenEvent constructor
24 : std::istream & establish_input_stream_info( std::istream & );
25 :
26 : /// get a GenVertex from ASCII input
27 : /// TempParticleMap is used to track the associations of particles with vertices
28 : std::istream & read_vertex( std::istream &, TempParticleMap &, GenVertex * );
29 :
30 : /// get a GenParticle from ASCII input
31 : /// TempParticleMap is used to track the associations of particles with vertices
32 : std::istream & read_particle( std::istream&, TempParticleMap &, GenParticle * );
33 :
34 : /// write a double - for internal use by streaming IO
35 : inline std::ostream & output( std::ostream & os, const double& d ) {
36 0 : if( os ) {
37 0 : if ( d == 0. ) {
38 0 : os << ' ' << (int)0;
39 0 : } else {
40 0 : os << ' ' << d;
41 : }
42 : }
43 0 : return os;
44 : }
45 :
46 : /// write a float - for internal use by streaming IO
47 : inline std::ostream & output( std::ostream & os, const float& d ) {
48 0 : if( os ) {
49 0 : if ( d == 0. ) {
50 0 : os << ' ' << (int)0;
51 0 : } else {
52 0 : os << ' ' << d;
53 : }
54 : }
55 0 : return os;
56 : }
57 :
58 : /// write an int - for internal use by streaming IO
59 : inline std::ostream & output( std::ostream & os, const int& i ) {
60 0 : if( os ) {
61 0 : if ( i == 0. ) {
62 0 : os << ' ' << (int)0;
63 0 : } else {
64 0 : os << ' ' << i;
65 : }
66 : }
67 0 : return os;
68 : }
69 :
70 : /// write a long - for internal use by streaming IO
71 : inline std::ostream & output( std::ostream & os, const long& i ) {
72 0 : if( os ) {
73 0 : if ( i == 0. ) {
74 0 : os << ' ' << (int)0;
75 0 : } else {
76 0 : os << ' ' << i;
77 : }
78 : }
79 0 : return os;
80 : }
81 :
82 : /// write a single char - for internal use by streaming IO
83 : inline std::ostream & output( std::ostream & os, const char& c ) {
84 0 : if( os ) {
85 0 : if ( c ) {
86 0 : os << c;
87 0 : } else {
88 0 : os << ' ' ;
89 : }
90 : }
91 0 : return os;
92 : }
93 :
94 : /// used to read to the end of a bad event
95 : std::istream & find_event_end( std::istream & );
96 :
97 : } // detail
98 :
99 : } // HepMC
100 :
101 : #endif // HEPMC_STREAM_HELPERS_H
102 : //--------------------------------------------------------------------------
|