]>
Commit | Line | Data |
---|---|---|
0ca57c2f | 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 | if( os ) { | |
37 | if ( d == 0. ) { | |
38 | os << ' ' << (int)0; | |
39 | } else { | |
40 | os << ' ' << d; | |
41 | } | |
42 | } | |
43 | 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 | if( os ) { | |
49 | if ( d == 0. ) { | |
50 | os << ' ' << (int)0; | |
51 | } else { | |
52 | os << ' ' << d; | |
53 | } | |
54 | } | |
55 | 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 | if( os ) { | |
61 | if ( i == 0. ) { | |
62 | os << ' ' << (int)0; | |
63 | } else { | |
64 | os << ' ' << i; | |
65 | } | |
66 | } | |
67 | 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 | if( os ) { | |
73 | if ( i == 0. ) { | |
74 | os << ' ' << (int)0; | |
75 | } else { | |
76 | os << ' ' << i; | |
77 | } | |
78 | } | |
79 | 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 | if( os ) { | |
85 | if ( c ) { | |
86 | os << c; | |
87 | } else { | |
88 | os << ' ' ; | |
89 | } | |
90 | } | |
91 | 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 | //-------------------------------------------------------------------------- |