ProteoWizard
DelimWriter.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4// Original author: Robert Burke <robert.burke@proteowizard.org>
5//
6// Copyright 2010 Spielberg Family Center for Applied Proteomics
7// University of Southern California, Los Angeles, California 90033
8//
9// Licensed under the Apache License, Version 2.0 (the "License");
10// you may not use this file except in compliance with the License.
11// You may obtain a copy of the License at
12//
13// http://www.apache.org/licenses/LICENSE-2.0
14//
15// Unless required by applicable law or agreed to in writing, software
16// distributed under the License is distributed on an "AS IS" BASIS,
17// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18// See the License for the specific language governing permissions and
19// limitations under the License.
20//
21
22#ifndef _DELIMWRITER_HPP_
23#define _DELIMWRITER_HPP_
24
25#include "IdentData.hpp"
27
28#include <string>
29#include <vector>
30
31namespace pwiz {
32namespace identdata {
33
35{
36public:
37 typedef std::vector<std::string> line_type;
38 //typedef std::vector<line_type> file_type;
39
40 DelimWriter(std::ostream* os = 0, char delim = '\t', bool headers = false)
41 : os_(os), delim_(delim), headers_(headers)
42 {}
43
44 template<typename T>
45 std::ostream* operator()(const T& t)
46 {
47 return this->write(t);
48 }
49
50 template<typename object_type>
51 std::ostream* write(const std::vector<object_type>& v)
52 {
53 std::for_each(v.begin(), v.end(), (*this));
54 return os_;
55 }
56
57 template<typename object_type>
58 std::ostream* write(const boost::shared_ptr<object_type>& pob)
59 {
60 if (pob.get())
61 return (*this)(*pob);
62
63 return os_;
64 }
65
66 std::ostream* writeHeaders();
67
68 std::ostream* write(const IdentData& mzid);
69
70 std::ostream* write(const SpectrumIdentificationList& sir);
71
72 std::ostream* write(const SpectrumIdentificationResult& sir);
73
74 std::ostream* write(const SpectrumIdentificationItem& sii);
75
76 std::ostream* write(const PeptideEvidence& pe);
77
78 std::ostream* write(const line_type& line);
79
80 operator bool() const;
81
82private:
83 std::ostream* os_;
84 char delim_;
86
88};
89
90} // namespace identdata
91} // namespace pwiz
92
93#endif // _DELIMWRITER_HPP_
94
#define PWIZ_API_DECL
Definition Export.hpp:32
std::ostream * operator()(const T &t)
std::ostream * write(const boost::shared_ptr< object_type > &pob)
std::ostream * write(const SpectrumIdentificationList &sir)
std::ostream * write(const SpectrumIdentificationResult &sir)
std::vector< std::string > line_type
std::ostream * writeHeaders()
DelimWriter(std::ostream *os=0, char delim='\t', bool headers=false)
std::ostream * write(const line_type &line)
std::ostream * write(const SpectrumIdentificationItem &sii)
std::ostream * write(const std::vector< object_type > &v)
std::ostream * write(const PeptideEvidence &pe)
std::ostream * write(const IdentData &mzid)
Implementation of the MzIdentMLType from the mzIdentML schema.
Implementation of PeptideEvidenceType from the mzIdentML schema.
Implementation of SpectrumIdentificationItemType from the mzIdentML schema.
Implementation of SpectrumIdentificationListType from the mzIdentML schema.
Implementation of SpectrumIdentificationResultType from the mzIdentML schema.