ProteoWizard
KwCVMap.hpp
Go to the documentation of this file.
1 //
2 // $Id: KwCVMap.hpp 2820 2011-06-27 22:51:16Z chambm $
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 _KWCVMAP_HPP_
23 #define _KWCVMAP_HPP_
24 
25 #include <string>
26 #include <vector>
27 #include "boost/shared_ptr.hpp"
28 #include "boost/regex.hpp"
29 #include "pwiz/data/common/cv.hpp"
30 
31 namespace pwiz{
32 namespace identdata{
33 
35 {
36  CVMap();
37  CVMap(const std::string& keyword, cv::CVID cvid,
38  const std::string& path);
39  CVMap(const std::string& keyword, cv::CVID cvid,
40  const std::string& path, const std::string& dependant);
41  virtual ~CVMap() {}
42 
43  std::string keyword;
44  cv::CVID cvid;
45  std::string path;
46  std::string dependant;
47 
48  static CVMap* createMap(const std::vector<std::string>& quad);
49 
50  virtual const char* getTag() const;
51 
52  virtual bool operator()(const std::string& text) const;
53  virtual bool operator==(const CVMap& right) const;
54 };
55 
56 typedef boost::shared_ptr<CVMap> CVMapPtr;
57 
59 {
60  RegexCVMap();
61  RegexCVMap(const std::string& pattern, cv::CVID cvid,
62  const std::string& path);
63  RegexCVMap(const std::string& pattern, cv::CVID cvid,
64  const std::string& path, const std::string& dependant);
65  virtual ~RegexCVMap();
66 
67  void setPattern(const std::string& pattern);
68 
69  virtual boost::cmatch match(std::string& text);
70 
71  virtual const char* getTag() const;
72 
73  virtual bool operator()(const std::string& text) const;
74 
75 protected:
76  boost::regex pattern;
77 };
78 
79 typedef boost::shared_ptr<RegexCVMap> RegexCVMapPtr;
80 
81 //
82 // Part matching classes.
83 //
85 {
86  StringMatchCVMap(const std::string& keyword);
87 
88  virtual bool operator()(const CVMap& right) const;
89  virtual bool operator()(const CVMapPtr& right) const;
90  virtual bool operator==(const CVMap& right) const;
91  virtual bool operator==(const CVMapPtr& right) const;
92 };
93 
95 {
96  CVIDMatchCVMap(cv::CVID cvid);
97 
98  virtual bool operator()(const CVMap& right) const;
99  virtual bool operator()(const CVMapPtr& right) const;
100  virtual bool operator==(const CVMap& right) const;
101  virtual bool operator==(const CVMapPtr& right) const;
102 };
103 
104 
105 //
106 // Useful operators
107 //
108 PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const CVMap& cm);
109 PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const CVMapPtr cmp);
110 PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const CVMap* cmp);
111 
112 PWIZ_API_DECL std::istream& operator>>(std::istream& is, CVMapPtr& cm);
113 
114 PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const std::vector<CVMapPtr>& cmVec);
115 PWIZ_API_DECL std::istream& operator>>(std::istream& is, std::vector<CVMapPtr>& cmVec);
116 
117 } // namespace identdata
118 } // namespace pwiz
119 
120 #endif // _KWCVMAP_HPP_
121