File indexing completed on 2025-04-19 09:13:41
0001
0002
0003
0004
0005
0006 #ifndef YODA_IO_h
0007 #define YODA_IO_h
0008
0009 #include "YODA/Writer.h"
0010 #include "YODA/Reader.h"
0011
0012 namespace YODA {
0013
0014
0015
0016
0017
0018
0019 inline void write(const std::string& filename, const AnalysisObject& ao, int precision=-1) {
0020 Writer& w = mkWriter(filename);
0021 if (precision > 0) w.setPrecision(precision);
0022 w.write(filename, ao);
0023 }
0024
0025
0026 template <typename RANGE>
0027 inline void write(const std::string& filename, const RANGE& aos, int precision=-1) {
0028 Writer& w = mkWriter(filename);
0029 if (precision > 0) w.setPrecision(precision);
0030 w.write(filename, aos);
0031 }
0032
0033
0034
0035 template <typename AOITER>
0036 inline void write(const std::string& filename, const AOITER& begin, const AOITER& end, int precision=-1) {
0037 Writer& w = mkWriter(filename);
0038 if (precision > 0) w.setPrecision(precision);
0039 w.write(filename, begin, end);
0040 }
0041
0042
0043
0044
0045
0046
0047
0048
0049 inline void write(std::ostream& os, const AnalysisObject& ao, const std::string& fmt, int precision=-1) {
0050 Writer& w = mkWriter(fmt);
0051 if (precision > 0) w.setPrecision(precision);
0052 w.write(os, ao);
0053 }
0054
0055
0056 template <typename RANGE>
0057 inline void write(std::ostream& os, const RANGE& aos, const std::string& fmt, int precision=-1) {
0058 Writer& w = mkWriter(fmt);
0059 if (precision > 0) w.setPrecision(precision);
0060 w.write(os, aos);
0061 }
0062
0063
0064
0065 template <typename AOITER>
0066 inline void write(std::ostream& os, const AOITER& begin, const AOITER& end, const std::string& fmt, int precision=-1) {
0067 Writer& w = mkWriter(fmt);
0068 if (precision > 0) w.setPrecision(precision);
0069 w.write(os, begin, end);
0070 }
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 inline void read(const std::string& filename, std::vector<AnalysisObject*>& aos,
0086 const std::string& match = "",
0087 const std::string& unmatch = "") {
0088 Reader& r = mkReader(filename);
0089 r.read(filename, aos, match, unmatch);
0090 }
0091
0092
0093
0094
0095
0096
0097
0098 inline std::vector<AnalysisObject*> read(const std::string& filename,
0099 const std::string& match = "",
0100 const std::string& unmatch = "") {
0101 std::vector<AnalysisObject*> rtn;
0102 read(filename, rtn, match, unmatch);
0103 return rtn;
0104 }
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118 inline void read(std::istream& is, std::vector<AnalysisObject*>& aos, const std::string& fmt,
0119 const std::string& match = "", const std::string& unmatch = "") {
0120 Reader& r = mkReader(fmt);
0121 r.read(is, aos, match, unmatch);
0122 }
0123
0124
0125
0126
0127
0128
0129 inline std::vector<AnalysisObject*> read(std::istream& is, const std::string& fmt,
0130 const std::string& match = "",
0131 const std::string& unmatch = "") {
0132 std::vector<AnalysisObject*> rtn;
0133 read(is, rtn, fmt, match, unmatch);
0134 return rtn;
0135 }
0136
0137
0138
0139
0140 }
0141
0142 #endif