1 #ifndef MELAOUTPUTSTREAMER_H
2 #define MELAOUTPUTSTREAMER_H
16 #include "TLorentzVector.h"
27 MELAOutputStreamer(
const char* fname, std::ios_base::openmode fmode = std::ios_base::out,
bool printError=
false);
37 std::streamsize
width()
const;
38 std::streamsize
width(std::streamsize wide);
41 char fill(
char fillch);
43 void open(
const char* fname, std::ios_base::openmode fmode = std::ios_base::out);
46 template<
typename T>
void writeCentered(
const T& val,
char fillch=
' ', std::streamsize gapsize=0);
56 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned short>(
unsigned short const& val);
58 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned int>(
unsigned int const& val);
60 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned long>(
unsigned long const& val);
62 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned long long>(
unsigned long long const& val);
63 template MELAOutputStreamer& MELAOutputStreamer::operator<< <long long>(
long long const& val);
65 template MELAOutputStreamer& MELAOutputStreamer::operator<< <double>(
double const& val);
66 template MELAOutputStreamer& MELAOutputStreamer::operator<< <long double>(
long double const& val);
69 template MELAOutputStreamer& MELAOutputStreamer::operator<< <char const*>(
char const*
const& val);
71 template MELAOutputStreamer& MELAOutputStreamer::operator<< <signed char*>(
signed char*
const& val);
72 template MELAOutputStreamer& MELAOutputStreamer::operator<< <signed char const*>(
signed char const*
const& val);
73 template MELAOutputStreamer& MELAOutputStreamer::operator<< <signed char>(
signed char const& val);
74 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned char*>(
unsigned char*
const& val);
75 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned char const*>(
unsigned char const*
const& val);
76 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned char>(
unsigned char const& val);
78 template<>
MELAOutputStreamer& MELAOutputStreamer::operator<< <TLorentzVector>(TLorentzVector
const& val);
80 template MELAOutputStreamer& MELAOutputStreamer::operator<< <std::string>(std::string
const& val);
81 template MELAOutputStreamer& MELAOutputStreamer::operator<< <TString>(TString
const& val);
82 template MELAOutputStreamer& MELAOutputStreamer::operator<< <std::streambuf*>(std::streambuf*
const& val);
91 *
this <<
"(" << val.first <<
", " << val.second <<
")";
98 for (
typename std::vector<T>::const_iterator it=val.cbegin(); it!=val.cend(); it++){
100 if (it!=val.cend()-1) *
this <<
", ";
104 template MELAOutputStreamer& MELAOutputStreamer::operator<< <bool>(std::vector<bool>
const& val);
105 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned short>(std::vector<unsigned short>
const& val);
106 template MELAOutputStreamer& MELAOutputStreamer::operator<< <short>(std::vector<short>
const& val);
107 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned int>(std::vector<unsigned int>
const& val);
108 template MELAOutputStreamer& MELAOutputStreamer::operator<< <int>(std::vector<int>
const& val);
109 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned long>(std::vector<unsigned long>
const& val);
110 template MELAOutputStreamer& MELAOutputStreamer::operator<< <long>(std::vector<long>
const& val);
111 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned long long>(std::vector<unsigned long long>
const& val);
112 template MELAOutputStreamer& MELAOutputStreamer::operator<< <long long>(std::vector<long long>
const& val);
113 template MELAOutputStreamer& MELAOutputStreamer::operator<< <float>(std::vector<float>
const& val);
114 template MELAOutputStreamer& MELAOutputStreamer::operator<< <double>(std::vector<double>
const& val);
115 template MELAOutputStreamer& MELAOutputStreamer::operator<< <long double>(std::vector<long double>
const& val);
117 template MELAOutputStreamer& MELAOutputStreamer::operator<< <char*>(std::vector<char*>
const& val);
118 template MELAOutputStreamer& MELAOutputStreamer::operator<< <char const*>(std::vector<char const*>
const& val);
119 template MELAOutputStreamer& MELAOutputStreamer::operator<< <char>(std::vector<char>
const& val);
120 template MELAOutputStreamer& MELAOutputStreamer::operator<< <signed char*>(std::vector<signed char*>
const& val);
121 template MELAOutputStreamer& MELAOutputStreamer::operator<< <signed char const*>(std::vector<signed char const*>
const& val);
122 template MELAOutputStreamer& MELAOutputStreamer::operator<< <signed char>(std::vector<signed char>
const& val);
123 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned char*>(std::vector<unsigned char*>
const& val);
124 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned char const*>(std::vector<unsigned char const*>
const& val);
125 template MELAOutputStreamer& MELAOutputStreamer::operator<< <unsigned char>(std::vector<unsigned char>
const& val);
127 template MELAOutputStreamer& MELAOutputStreamer::operator<< <std::string>(std::vector<std::string>
const& val);
128 template MELAOutputStreamer& MELAOutputStreamer::operator<< <TString>(std::vector<TString>
const& val);
132 char deffillch = this->
fill(fillch);
134 std::stringstream tmpss;
136 std::string tmpstr = tmpss.str();
137 std::streamsize strlength = (std::streamsize) tmpstr.length();
139 if (strlength>gapsize) *
this << std::setw(gapsize) <<
"";
141 std::streamsize leftgap = (gapsize+strlength)/2;
142 std::streamsize rightgap = gapsize-leftgap;
143 *
this << std::setw(leftgap) << tmpstr << std::setw(rightgap) <<
"";
146 this->
fill(deffillch);
148 template void MELAOutputStreamer::writeCentered<bool>(
const bool& val,
char fillch, std::streamsize gapsize);
149 template void MELAOutputStreamer::writeCentered<unsigned short>(
const unsigned short& val,
char fillch, std::streamsize gapsize);
150 template void MELAOutputStreamer::writeCentered<short>(
const short& val,
char fillch, std::streamsize gapsize);
151 template void MELAOutputStreamer::writeCentered<unsigned int>(
const unsigned int& val,
char fillch, std::streamsize gapsize);
152 template void MELAOutputStreamer::writeCentered<int>(
const int& val,
char fillch, std::streamsize gapsize);
153 template void MELAOutputStreamer::writeCentered<unsigned long>(
const unsigned long& val,
char fillch, std::streamsize gapsize);
154 template void MELAOutputStreamer::writeCentered<long>(
const long& val,
char fillch, std::streamsize gapsize);
155 template void MELAOutputStreamer::writeCentered<unsigned long long>(
const unsigned long long& val,
char fillch, std::streamsize gapsize);
156 template void MELAOutputStreamer::writeCentered<long long>(
const long long& val,
char fillch, std::streamsize gapsize);
157 template void MELAOutputStreamer::writeCentered<float>(
const float& val,
char fillch, std::streamsize gapsize);
158 template void MELAOutputStreamer::writeCentered<double>(
const double& val,
char fillch, std::streamsize gapsize);
159 template void MELAOutputStreamer::writeCentered<long double>(
const long double& val,
char fillch, std::streamsize gapsize);
161 template void MELAOutputStreamer::writeCentered<char*>(
char*
const& val,
char fillch, std::streamsize gapsize);
162 template void MELAOutputStreamer::writeCentered<char const*>(
char const*
const& val,
char fillch, std::streamsize gapsize);
163 template void MELAOutputStreamer::writeCentered<char>(
char const& val,
char fillch, std::streamsize gapsize);
164 template void MELAOutputStreamer::writeCentered<signed char*>(
signed char*
const& val,
char fillch, std::streamsize gapsize);
165 template void MELAOutputStreamer::writeCentered<signed char const*>(
signed char const*
const& val,
char fillch, std::streamsize gapsize);
166 template void MELAOutputStreamer::writeCentered<signed char>(
signed char const& val,
char fillch, std::streamsize gapsize);
167 template void MELAOutputStreamer::writeCentered<unsigned char*>(
unsigned char*
const& val,
char fillch, std::streamsize gapsize);
168 template void MELAOutputStreamer::writeCentered<unsigned char const*>(
unsigned char const*
const& val,
char fillch, std::streamsize gapsize);
169 template void MELAOutputStreamer::writeCentered<unsigned char>(
unsigned char const& val,
char fillch, std::streamsize gapsize);
171 template void MELAOutputStreamer::writeCentered<std::string>(std::string
const& val,
char fillch, std::streamsize gapsize);
172 template void MELAOutputStreamer::writeCentered<TString>(TString
const& val,
char fillch, std::streamsize gapsize);