23 #ifndef _TRADATA_TEXTWRITER_HPP_
24 #define _TRADATA_TEXTWRITER_HPP_
29 #include "boost/lexical_cast.hpp"
48 :
os_(os), depth_(depth), indent_(depth*2,
' ')
55 os_ << indent_ << text << std::endl;
62 if (!cvParam.
value.empty())
72 os_ << indent_ <<
"userParam: " << userParam.
name;
74 if (!userParam.
type.empty())
os_ <<
", " << userParam.
type;
80 template<
typename object_type>
81 TextWriter& operator()(
const std::string& label,
const std::vector<object_type>& v)
84 for_each(v.begin(), v.end(), child());
88 template<
typename object_type>
89 TextWriter& operator()(
const std::string& label,
const object_type& v)
91 (*this)(label)(boost::lexical_cast<std::string>(v));
99 child()(
"version: " + msd.
version());
100 if (!msd.
cvs.empty())
101 child()(
"cvList: ", msd.
cvs);
137 for_each(paramContainer.
cvParams.begin(), paramContainer.
cvParams.end(), *
this);
144 (*this)(
"publication:");
146 (
"id: " + publication.
id)
147 (static_cast<const ParamContainer&>(publication));
153 (*this)(
"software:");
155 (
"id: " + software.
id)
156 (
"version: " + software.
version)
170 (*this)(
"retentionTime:");
174 child()(
"softwareRef: " + retentionTime.
softwarePtr->id);
180 (*this)(
"prediction:");
187 (*this)(
"evidence:");
194 (*this)(
"validation:");
202 child()(
"id: " + protein.
id)
210 (*this)(
"modification:");
211 child()(
"location: ",
lexical_cast<
string>(modification.location))
212 (
"monoisotopicMassDelta: " +
lexical_cast<
string>(modification.monoisotopicMassDelta))
213 (
"averageMassDelta: " +
lexical_cast<
string>(modification.averageMassDelta));
221 child()(
"id: " + peptide.id)
225 if (!peptide.proteinPtrs.empty())
226 child()(
"proteinRefs:", peptide.proteinPtrs);
229 if (!peptide.retentionTimes.empty())
230 child()(
"retentionTimes:", peptide.retentionTimes);
238 (*this)(
"compound:");
239 child()(
"id: " + compound.
id)
247 (*this)(
"precursor:");
261 (*this)(
"transition:");
262 child()(
"id: ", transition.
id);
274 child()(
"peptideRef: " + transition.
peptidePtr->id);
276 child()(
"compoundRef: " + transition.
compoundPtr->id);
283 child()(
"id: ", target.
id);
289 child()(
"peptideRef: " + target.
peptidePtr->id);
297 (*this)(
"targetList:");
307 template<
typename object_type>
308 TextWriter& operator()(
const boost::shared_ptr<object_type>& p)
310 return p.get() ? (*this)(*p) : *
this;
324 #endif // _TRADATA_TEXTWRITER_HPP_