ProteoWizard
Serializer_Text.hpp
Go to the documentation of this file.
1 //
2 // $Id: Serializer_Text.hpp 3173 2011-12-13 20:05:03Z broter $
3 //
4 //
5 // Original author: Robert Burke <robert.burke@proteowizard.org>
6 //
7 // Copyright 2007 Spielberg Family Center for Applied Proteomics
8 // Cedars-Sinai Medical Center, Los Angeles, California 90048
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 //
22 
23 
24 #ifndef _SERIALIZER_TEXT_HPP_
25 #define _SERIALIZER_TEXT_HPP_
26 
30 
31 namespace pwiz {
32 namespace identdata {
33 
34 /// \class Serializer_Text
35 ///
36 /// Serializer_Text reads in and writes out an id file in tab format.
37 ///
39 {
40 public:
41  /// List of fields available.
42  enum IdField
43  {
44  None=0,
45  Scan=1,
46  Rt=2,
47  Mz=3,
48  Charge=4,
49  Score=5,
50  ScoreType=6,
53  ProteinDescription=9,
54  Last=ProteinDescription
55  };
56 
57  static const std::string* getIdFieldNames();
58 
59  struct PWIZ_API_DECL Config ///< Controls the format of the text file.
60  {
61  bool headers;
62  std::vector<IdField> fields;
64 
65  std::string recordDelim;
66  std::string fieldDelim;
67 
68  Config();
69  Config(const Config& config);
70  };
71 
72  /// Constructor with Config
73  Serializer_Text(const Config& config = Config());
74 
75  /// writes IdentData object to ostream as a text table
76  void write(std::ostream& os, const IdentData& mzid,
77  const pwiz::util::IterationListenerRegistry* iterationListenerRegistry = 0) const;
78 
79  /// read in IdentData object from a delimited text fromat.
80  void read(boost::shared_ptr<std::istream> is, IdentData& mzid) const;
81 
82  private:
83  class Impl;
84  boost::shared_ptr<Impl> impl_;
86  Serializer_Text& operator=(Serializer_Text&);
87 };
88 
89 
90 } // namespace identdata
91 } // namespace pwiz
92 
93 #endif // _SERIALIZER_TEXT_HPP_