Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
SemanticValidator.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Marc Sturm, Andreas Bertsch $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_FORMAT_VALIDATORS_SEMANTICVALIDATOR_H
36 #define OPENMS_FORMAT_VALIDATORS_SEMANTICVALIDATOR_H
37 
38 #include <OpenMS/FORMAT/XMLFile.h>
42 
43 
44 namespace OpenMS
45 {
46  class ControlledVocabulary;
47  namespace Internal
48  {
49 
56  class OPENMS_DLLAPI SemanticValidator :
57  protected Internal::XMLHandler,
58  public Internal::XMLFile
59  {
60 public:
67  SemanticValidator(const CVMappings & mapping, const ControlledVocabulary & cv);
68 
70  virtual ~SemanticValidator();
71 
73  struct CVTerm
74  {
78  bool has_value;
83  };
84 
96  bool validate(const String & filename, StringList & errors, StringList & warnings);
97 
99  bool locateTerm(const String & path, const CVTerm & parsed_term) const;
100 
102  void setTag(const String & tag);
103 
105  void setAccessionAttribute(const String & accession);
106 
108  void setNameAttribute(const String & name);
109 
111  void setValueAttribute(const String & value);
112 
121  void setCheckTermValueTypes(bool check);
122 
130  void setCheckUnits(bool check);
131 
133  void setUnitAccessionAttribute(const String & accession);
134 
136  void setUnitNameAttribute(const String & name);
137 
138 protected:
139 
140  // Docu in base class
141  void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes);
142 
143  // Docu in base class
144  void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname);
145 
146  // Docu in base class
147  void characters(const XMLCh * const chars, const XMLSize_t /*length*/);
148 
150  virtual String getPath_(UInt remove_from_end = 0) const;
151 
153  virtual void getCVTerm_(const xercesc::Attributes & attributes, CVTerm & parsed_term);
154 
155  //~ forward dekl. of a inner struct/class not possible in C++ - or our Library is overtemplated
156  //~ /// make a SemanticValidator::CVTerm from a ControlledVocabulary::CVTerm (without any value or unit), needed for writing only cvs at the right places in the xml (i.e. with cvmapping)
157  //~ virtual void makeCVTerm_(const ControlledVocabulary::CVTerm & lc, CVTerm & parsed_term);
158 
160  virtual void handleTerm_(const String & path, const CVTerm & parsed_term);
161 
164 
167 
170 
173 
176 
179 
184 
185 
187 
197 
198 private:
199 
202 
205 
207  SemanticValidator & operator=(const SemanticValidator & rhs);
208 
209  };
210 
211  } // namespace Internal
212 
213 } // namespace OpenMS
214 
215 #endif // OPENMS_FORMAT_VALIDATORS_SEMANTICVALIDATOR_H
216 
String accession
Definition: SemanticValidator.h:75
String unit_name
Definition: SemanticValidator.h:81
A more convenient string class.
Definition: String.h:57
const ControlledVocabulary & cv_
Reference to the CVs.
Definition: SemanticValidator.h:166
bool has_value
Definition: SemanticValidator.h:78
String value_att_
Definition: SemanticValidator.h:191
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
StringList errors_
Validation errors.
Definition: SemanticValidator.h:169
bool check_units_
Definition: SemanticValidator.h:195
bool check_term_value_types_
Definition: SemanticValidator.h:194
Base class for XML handlers.
Definition: XMLHandler.h:110
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
String unit_accession
Definition: SemanticValidator.h:79
Representation of a controlled vocabulary.
Definition: ControlledVocabulary.h:55
bool has_unit_accession
Definition: SemanticValidator.h:80
Representation of a parsed CV term.
Definition: SemanticValidator.h:73
String accession_att_
Definition: SemanticValidator.h:189
String unit_name_att_
Definition: SemanticValidator.h:193
String name
Definition: SemanticValidator.h:76
String name_att_
Definition: SemanticValidator.h:190
Map< String, Map< String, Map< String, UInt > > > fulfilled_
Definition: SemanticValidator.h:183
String cv_tag_
Definition: SemanticValidator.h:188
const CVMappings & mapping_
Reference to the mappings.
Definition: SemanticValidator.h:163
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:74
String unit_accession_att_
Definition: SemanticValidator.h:192
String value
Definition: SemanticValidator.h:77
Map< String, std::vector< CVMappingRule > > rules_
Rules (location => rule)
Definition: SemanticValidator.h:178
Base class for loading/storing XML files that have a handler derived from XMLHandler.
Definition: XMLFile.h:49
bool has_unit_name
Definition: SemanticValidator.h:82
Semantically validates XML files using CVMappings and a ControlledVocabulary.
Definition: SemanticValidator.h:56
Representation of controlled vocabulary mapping rules (for PSI formats)
Definition: CVMappings.h:57
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:51
StringList open_tags_
List of open tags.
Definition: SemanticValidator.h:175
bool validate(const std::vector< std::string > &file_names)
Validates the given files against the XML schema (if available)
StringList warnings_
Validation warnings.
Definition: SemanticValidator.h:172

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:03 using doxygen 1.8.13