ProteoWizard
TabReader.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Robert Burke <robert.burke@proteowizard.org>
6//
7// Copyright 2008 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 _TABREADER_HPP_
25#define _TABREADER_HPP_
26
27
28#include "Export.hpp"
29#include "boost/shared_ptr.hpp"
30#include <string>
31#include <vector>
32#include <iostream>
33
34
35namespace pwiz {
36namespace util {
37
39{
40 virtual ~TabHandler() {}
41
42 virtual bool getHeaders() = 0;
43
44 virtual char useComment() const = 0;
45
46 virtual bool open() = 0;
47
48 virtual bool updateLine(const std::string& line) = 0;
49
50 virtual bool updateRecord(const std::vector<std::string>& fields) = 0;
51
52 virtual bool close() = 0;
53};
54
56{
57 public:
58
59 DefaultTabHandler(bool need_headers = true,
60 char comment_char='#');
61
63
64 virtual ~DefaultTabHandler() {}
65
66 virtual bool getHeaders();
67
68 virtual char useComment() const;
69
70 virtual bool open();
71
72 virtual bool updateLine(const std::string& line);
73
74 virtual bool updateRecord(const std::vector<std::string>& fields);
75
76 virtual size_t columns() const;
77
78 virtual size_t getHeader(const std::string& name) const;
79
80 virtual std::string getHeader(size_t index) const;
81
82 virtual bool close();
83
84 protected:
85
86 class Impl;
87 boost::shared_ptr<Impl> pimpl;
88};
89
91{
92 public:
93
94 typedef std::vector< std::vector<std::string> >::const_iterator const_iterator;
95 typedef std::vector< std::vector<std::string> >::iterator iterator;
96
99
100 virtual ~VectorTabHandler() {}
101
102 virtual const_iterator begin() const;
103 virtual const_iterator end() const;
104};
105
107{
108 public:
110 virtual ~TabReader() {}
111
112 virtual void setHandler(TabHandler* handler);
113 virtual const TabHandler* getHandler();
114
115 virtual bool process(const char* filename);
116
117 //virtual const std::vector< std::vector<std::string> >& records();
118
119 private:
120
121 class Impl;
122 boost::shared_ptr<Impl> pimpl;
123};
124
125} // namespace pwiz
126} // namespace utility
127
128#endif // _TABREADER_HPP_
129
#define PWIZ_API_DECL
Definition Export.hpp:32
DefaultTabHandler(const DefaultTabHandler &c)
virtual bool updateLine(const std::string &line)
virtual bool updateRecord(const std::vector< std::string > &fields)
DefaultTabHandler(bool need_headers=true, char comment_char='#')
virtual std::string getHeader(size_t index) const
virtual size_t getHeader(const std::string &name) const
boost::shared_ptr< Impl > pimpl
Definition TabReader.hpp:87
virtual size_t columns() const
virtual char useComment() const
virtual const TabHandler * getHandler()
virtual void setHandler(TabHandler *handler)
boost::shared_ptr< Impl > pimpl
virtual bool process(const char *filename)
virtual const_iterator begin() const
VectorTabHandler(const DefaultTabHandler &c)
std::vector< std::vector< std::string > >::iterator iterator
Definition TabReader.hpp:95
virtual const_iterator end() const
std::vector< std::vector< std::string > >::const_iterator const_iterator
Definition TabReader.hpp:94
virtual bool close()=0
virtual bool updateRecord(const std::vector< std::string > &fields)=0
virtual bool getHeaders()=0
virtual char useComment() const =0
virtual bool updateLine(const std::string &line)=0
virtual bool open()=0