| OpenMS 2.5.0

XMLHandler.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-2020.
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: Chris Bielow $
32 // $Authors: Marc Sturm, Chris Bielow $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/CONCEPT/Types.h>
38 #include <OpenMS/CONCEPT/Macros.h>
39
40 #include <OpenMS/DATASTRUCTURES/ListUtils.h> // StringList
41 #include <OpenMS/DATASTRUCTURES/DateTime.h>
42 #include <OpenMS/DATASTRUCTURES/ListUtils.h>
43 #include <OpenMS/METADATA/MetaInfoInterface.h>
44
45 #include <xercesc/util/XMLString.hpp>
46 #include <xercesc/sax2/DefaultHandler.hpp>
47 #include <xercesc/sax/Locator.hpp>
48 #include <xercesc/sax2/Attributes.hpp>
49
50 #include <algorithm>
51 #include <iosfwd>
52 #include <string>
53
54 namespace OpenMS
55 {
56 class ProteinIdentification;
57
58
59 namespace Internal
60 {
61
62 /*
63 * @brief Helper class for XML parsing that handles the conversions of Xerces strings
64 *
65 * It provides the convert() function which internally calls
66 * XMLString::transcode and ensures that the memory is released properly
67 * through XMLString::release internally. It returns a std::string or
68 * std::basic_string<XMLCh> to the caller who takes ownership of the data.
69 *
70 */
71 class OPENMS_DLLAPI StringManager
72 {
73
74 typedef std::basic_string<XMLCh> XercesString;
75
76 // Converts from a narrow-character string to a wide-character string.
77 inline XercesString fromNative_(const char* str) const
78 {
79 XMLCh* ptr(xercesc::XMLString::transcode(str));
80 XercesString result(ptr);
81 xercesc::XMLString::release(&ptr);
82 return result;
83 }
84
85 // Converts from a narrow-character string to a wide-character string.
86 inline XercesString fromNative_(const String& str) const
87 {
88 return fromNative_(str.c_str());
89 }
90
91 // Converts from a wide-character string to a narrow-character string.
92 inline String toNative_(const XMLCh* str) const
93 {
94 char* ptr(xercesc::XMLString::transcode(str));
95 String result(ptr);
96 xercesc::XMLString::release(&ptr);
97 return result;
98 }
99
100 // Converts from a wide-character string to a narrow-character string.
101 inline String toNative_(const XercesString& str) const
102 {
103 return toNative_(str.c_str());
104 }
105
106
107 public:
109 StringManager();
110
112 ~StringManager();
113
115 inline XercesString convert(const char * str) const
116 {
117 return fromNative_(str);
118 }
119
121 inline XercesString convert(const std::string & str) const
122 {
123 return fromNative_(str.c_str());
124 }
125
127 inline XercesString convert(const String & str) const
128 {
129 return fromNative_(str.c_str());
130 }
131
133 inline String convert(const XMLCh * str) const
134 {
135 return toNative_(str);
136 }
137
144 static void appendASCII(const XMLCh * str, const XMLSize_t length, String & result);
145
146 };
147
151 class OPENMS_DLLAPI XMLHandler :
152 public xercesc::DefaultHandler
153 {
154 public:
155
157 class OPENMS_DLLAPI EndParsingSoftly :
158 public Exception::BaseException
159 {
160 public:
161 EndParsingSoftly(const char * file, int line, const char * function) :
162 Exception::BaseException(file, line, function)
163 {
164 }
165
166 };
167
169 enum ActionMode
170 {
171 LOAD,
172 STORE
173 };
174
175 enum LOADDETAIL
176 {
177 LD_ALLDATA, // default; load all data
178 LD_RAWCOUNTS, // only count the total number of spectra and chromatograms (usually very fast)
179 LD_COUNTS_WITHOPTIONS // count the number of spectra, while respecting PeakFileOptions (msLevel and RTRange) and chromatograms (fast)
180 };
181
182
184 XMLHandler(const String & filename, const String & version);
186 ~XMLHandler() override;
187
189 void reset();
190
191
198 void fatalError(const xercesc::SAXParseException & exception) override;
199 void error(const xercesc::SAXParseException & exception) override;
200 void warning(const xercesc::SAXParseException & exception) override;
202
204 void fatalError(ActionMode mode, const String & msg, UInt line = 0, UInt column = 0) const;
206 void error(ActionMode mode, const String & msg, UInt line = 0, UInt column = 0) const;
208 void warning(ActionMode mode, const String & msg, UInt line = 0, UInt column = 0) const;
209
211 void characters(const XMLCh * const chars, const XMLSize_t length) override;
213 void startElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh * const qname, const xercesc::Attributes & attrs) override;
215 void endElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh * const qname) override;
216
218 virtual void writeTo(std::ostream & /*os*/);
219
221 String errorString();
222
224 virtual LOADDETAIL getLoadDetail() const;
225
227 virtual void setLoadDetail(const LOADDETAIL d);
228
236 static String writeXMLEscape(const String& to_escape)
237 {
238 String _copy = to_escape;
239 // has() is cheap, so check before calling substitute(), since substitute() will usually happen rarely
240 if (_copy.has('&')) _copy.substitute("&","&amp;");
241 if (_copy.has('>')) _copy.substitute(">","&gt;");
242 if (_copy.has('"')) _copy.substitute("\"","&quot;");
243 if (_copy.has('<')) _copy.substitute("<","&lt;");
244 if (_copy.has('\'')) _copy.substitute("'","&apos;");
245
246 return _copy;
247 }
248
251 void checkUniqueIdentifiers_(const std::vector<ProteinIdentification>& prot_ids);
252
253 protected:
255 mutable String error_message_;
256
258 String file_;
259
261 String version_;
262
264 StringManager sm_;
265
271 std::vector<String> open_tags_;
272
274 LOADDETAIL load_detail_;
275
276
278 inline bool equal_(const XMLCh * a, const XMLCh * b) const
279 {
280 return xercesc::XMLString::compareString(a, b) == 0;
281 }
282
284
285
287 void writeUserParam_(const String & tag_name, std::ostream & os, const MetaInfoInterface & meta, UInt indent) const;
288
290
292
293
295 std::vector<std::vector<String> > cv_terms_;
296
299 inline SignedSize cvStringToEnum_(const Size section, const String & term, const char * message, const SignedSize result_on_error = 0)
300 {
301 OPENMS_PRECONDITION(section < cv_terms_.size(), "cvStringToEnum_: Index overflow (section number too large)");
302
303 std::vector<String>::const_iterator it = std::find(cv_terms_[section].begin(), cv_terms_[section].end(), term);
304 if (it != cv_terms_[section].end())
305 {
306 return it - cv_terms_[section].begin();
307 }
308 else
309 {
310 warning(LOAD, String("Unexpected CV entry '") + message + "'='" + term + "'");
311 return result_on_error;
312 }
313 }
314
316
318
319
321 inline Int asInt_(const String & in)
322 {
323 Int res = 0;
324 try
325 {
326 res = in.toInt();
327 }
328 catch (Exception::ConversionError&)
329 {
330 error(LOAD, String("Int conversion error of \"") + in + "\"");
331 }
332 return res;
333 }
334
336 inline Int asInt_(const XMLCh * in)
337 {
338 return xercesc::XMLString::parseInt(in);
339 }
340
342 inline UInt asUInt_(const String & in)
343 {
344 UInt res = 0;
345 try
346 {
347 Int tmp = in.toInt();
348 if (tmp < 0)
349 {
350 throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "");
351 }
352 res = UInt(tmp);
353 }
354 catch (Exception::ConversionError& )
355 {
356 error(LOAD, String("UInt conversion error of \"") + in + "\"");
357 }
358 return res;
359 }
360
362 inline double asDouble_(const String & in)
363 {
364 double res = 0.0;
365 try
366 {
367 res = in.toDouble();
368 }
369 catch (Exception::ConversionError& )
370 {
371 error(LOAD, String("Double conversion error of \"") + in + "\"");
372 }
373 return res;
374 }
375
377 inline float asFloat_(const String & in)
378 {
379 float res = 0.0;
380 try
381 {
382 res = in.toFloat();
383 }
384 catch (Exception::ConversionError& )
385 {
386 error(LOAD, String("Float conversion error of \"") + in + "\"");
387 }
388 return res;
389 }
390
398 inline bool asBool_(const String & in)
399 {
400 if (in == "true" || in == "TRUE" || in == "True" || in == "1")
401 {
402 return true;
403 }
404 else if (in == "false" || in == "FALSE" || in == "False" || in == "0")
405 {
406 return false;
407 }
408 else
409 {
410 error(LOAD, String("Boolean conversion error of \"") + in + "\"");
411 }
412 return false;
413 }
414
416 inline DateTime asDateTime_(String date_string)
417 {
418 DateTime date_time;
419 if (date_string != "")
420 {
421 try
422 {
423 //strip away milliseconds
424 date_string.trim();
425 date_string = date_string.substr(0, 19);
426 date_time.set(date_string);
427 }
428 catch (Exception::ParseError& /*err*/ )
429 {
430 error(LOAD, String("DateTime conversion error of \"") + date_string + "\"");
431 }
432 }
433 return date_time;
434 }
435
437
439
440
442 inline String attributeAsString_(const xercesc::Attributes & a, const char * name) const
443 {
444 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
445 if (val == nullptr) fatalError(LOAD, String("Required attribute '") + name + "' not present!");
446 return sm_.convert(val);
447 }
448
450 inline Int attributeAsInt_(const xercesc::Attributes & a, const char * name) const
451 {
452 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
453 if (val == nullptr) fatalError(LOAD, String("Required attribute '") + name + "' not present!");
454 return xercesc::XMLString::parseInt(val);
455 }
456
458 inline double attributeAsDouble_(const xercesc::Attributes & a, const char * name) const
459 {
460 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
461 if (val == nullptr) fatalError(LOAD, String("Required attribute '") + name + "' not present!");
462 return String(sm_.convert(val)).toDouble();
463 }
464
466 inline DoubleList attributeAsDoubleList_(const xercesc::Attributes & a, const char * name) const
467 {
468 String tmp(expectList_(attributeAsString_(a, name)));
469 return ListUtils::create<double>(tmp.substr(1, tmp.size() - 2));
470 }
471
473 inline IntList attributeAsIntList_(const xercesc::Attributes & a, const char * name) const
474 {
475 String tmp(expectList_(attributeAsString_(a, name)));
476 return ListUtils::create<Int>(tmp.substr(1, tmp.size() - 2));
477 }
478
480 inline StringList attributeAsStringList_(const xercesc::Attributes & a, const char * name) const
481 {
482 String tmp(expectList_(attributeAsString_(a, name)));
483 return ListUtils::create<String>(tmp.substr(1, tmp.size() - 2));
484 }
485
491 inline bool optionalAttributeAsString_(String & value, const xercesc::Attributes & a, const char * name) const
492 {
493 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
494 if (val != nullptr)
495 {
496 value = sm_.convert(val);
497 return true;
498 }
499 return false;
500 }
501
507 inline bool optionalAttributeAsInt_(Int & value, const xercesc::Attributes & a, const char * name) const
508 {
509 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
510 if (val != nullptr)
511 {
512 value = xercesc::XMLString::parseInt(val);
513 return true;
514 }
515 return false;
516 }
517
523 inline bool optionalAttributeAsUInt_(UInt & value, const xercesc::Attributes & a, const char * name) const
524 {
525 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
526 if (val != nullptr)
527 {
528 value = xercesc::XMLString::parseInt(val);
529 return true;
530 }
531 return false;
532 }
533
539 inline bool optionalAttributeAsDouble_(double & value, const xercesc::Attributes & a, const char * name) const
540 {
541 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
542 if (val != nullptr)
543 {
544 value = String(sm_.convert(val)).toDouble();
545 return true;
546 }
547 return false;
548 }
549
555 inline bool optionalAttributeAsDoubleList_(DoubleList & value, const xercesc::Attributes & a, const char * name) const
556 {
557 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
558 if (val != nullptr)
559 {
560 value = attributeAsDoubleList_(a, name);
561 return true;
562 }
563 return false;
564 }
565
571 inline bool optionalAttributeAsStringList_(StringList & value, const xercesc::Attributes & a, const char * name) const
572 {
573 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
574 if (val != nullptr)
575 {
576 value = attributeAsStringList_(a, name);
577 return true;
578 }
579 return false;
580 }
581
587 inline bool optionalAttributeAsIntList_(IntList & value, const xercesc::Attributes & a, const char * name) const
588 {
589 const XMLCh * val = a.getValue(sm_.convert(name).c_str());
590 if (val != nullptr)
591 {
592 value = attributeAsIntList_(a, name);
593 return true;
594 }
595 return false;
596 }
597
599 inline String attributeAsString_(const xercesc::Attributes & a, const XMLCh * name) const
600 {
601 const XMLCh * val = a.getValue(name);
602 if (val == nullptr) fatalError(LOAD, String("Required attribute '") + sm_.convert(name) + "' not present!");
603 return sm_.convert(val);
604 }
605
607 inline Int attributeAsInt_(const xercesc::Attributes & a, const XMLCh * name) const
608 {
609 const XMLCh * val = a.getValue(name);
610 if (val == nullptr) fatalError(LOAD, String("Required attribute '") + sm_.convert(name) + "' not present!");
611 return xercesc::XMLString::parseInt(val);
612 }
613
615 inline double attributeAsDouble_(const xercesc::Attributes & a, const XMLCh * name) const
616 {
617 const XMLCh * val = a.getValue(name);
618 if (val == nullptr) fatalError(LOAD, String("Required attribute '") + sm_.convert(name) + "' not present!");
619 return sm_.convert(val).toDouble();
620 }
621
623 inline DoubleList attributeAsDoubleList_(const xercesc::Attributes & a, const XMLCh * name) const
624 {
625 String tmp(expectList_(attributeAsString_(a, name)));
626 return ListUtils::create<double>(tmp.substr(1, tmp.size() - 2));
627 }
628
630 inline IntList attributeAsIntList_(const xercesc::Attributes & a, const XMLCh * name) const
631 {
632 String tmp(expectList_(attributeAsString_(a, name)));
633 return ListUtils::create<Int>(tmp.substr(1, tmp.size() - 2));
634 }
635
637 inline StringList attributeAsStringList_(const xercesc::Attributes & a, const XMLCh * name) const
638 {
639 String tmp(expectList_(attributeAsString_(a, name)));
640 return ListUtils::create<String>(tmp.substr(1, tmp.size() - 2));
641 }
642
644 inline bool optionalAttributeAsString_(String& value, const xercesc::Attributes & a, const XMLCh * name) const
645 {
646 const XMLCh * val = a.getValue(name);
647 if (val != nullptr)
648 {
649 value = sm_.convert(val);
650 return !value.empty();
651 }
652 return false;
653 }
654
656 inline bool optionalAttributeAsInt_(Int & value, const xercesc::Attributes & a, const XMLCh * name) const
657 {
658 const XMLCh * val = a.getValue(name);
659 if (val != nullptr)
660 {
661 value = xercesc::XMLString::parseInt(val);
662 return true;
663 }
664 return false;
665 }
666
668 inline bool optionalAttributeAsUInt_(UInt & value, const xercesc::Attributes & a, const XMLCh * name) const
669 {
670 const XMLCh * val = a.getValue(name);
671 if (val != nullptr)
672 {
673 value = xercesc::XMLString::parseInt(val);
674 return true;
675 }
676 return false;
677 }
678
680 inline bool optionalAttributeAsDouble_(double & value, const xercesc::Attributes & a, const XMLCh * name) const
681 {
682 const XMLCh * val = a.getValue(name);
683 if (val != nullptr)
684 {
685 value = sm_.convert(val).toDouble();
686 return true;
687 }
688 return false;
689 }
690
696 inline bool optionalAttributeAsDoubleList_(DoubleList & value, const xercesc::Attributes & a, const XMLCh * name) const
697 {
698 const XMLCh * val = a.getValue(name);
699 if (val != nullptr)
700 {
701 value = attributeAsDoubleList_(a, name);
702 return true;
703 }
704 return false;
705 }
706
712 inline bool optionalAttributeAsIntList_(IntList & value, const xercesc::Attributes & a, const XMLCh * name) const
713 {
714 const XMLCh * val = a.getValue(name);
715 if (val != nullptr)
716 {
717 value = attributeAsIntList_(a, name);
718 return true;
719 }
720 return false;
721 }
722
728 inline bool optionalAttributeAsStringList_(StringList & value, const xercesc::Attributes & a, const XMLCh * name) const
729 {
730 const XMLCh * val = a.getValue(name);
731 if (val != nullptr)
732 {
733 value = attributeAsStringList_(a, name);
734 return true;
735 }
736 return false;
737 }
738
740
741 private:
743 XMLHandler();
744
745 inline const String& expectList_(const String& str) const
746 {
747 if (!(str.hasPrefix('[') && str.hasSuffix(']')))
748 {
749 fatalError(LOAD, String("List argument is not a string representation of a list!"));
750 }
751 return str;
752 }
753
754 };
755
756 } // namespace Internal
757 } // namespace OpenMS
758
759
OpenMS::Internal::XMLHandler::ActionMode
ActionMode
Action to set the current mode (for error messages)
Definition: XMLHandler.h:169
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
OpenMS::Internal::XMLHandler::optionalAttributeAsIntList_
bool optionalAttributeAsIntList_(IntList &value, const xercesc::Attributes &a, const char *name) const
Assigns the attribute content to the IntList value if the attribute is present.
Definition: XMLHandler.h:587
OpenMS::Exception::BaseException
Exception base class.
Definition: Exception.h:89
OpenMS::Internal::XMLHandler::optionalAttributeAsDoubleList_
bool optionalAttributeAsDoubleList_(DoubleList &value, const xercesc::Attributes &a, const XMLCh *name) const
Assigns the attribute content to the DoubleList value if the attribute is present.
Definition: XMLHandler.h:696
OpenMS::Internal::StringManager::XercesString
std::basic_string< XMLCh > XercesString
Definition: XMLHandler.h:74
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::Internal::XMLHandler::cv_terms_
std::vector< std::vector< String > > cv_terms_
Array of CV term lists (one sublist denotes one term and it&#39;s children)
Definition: XMLHandler.h:295
OpenMS::DateTime::set
void set(UInt month, UInt day, UInt year, UInt hour, UInt minute, UInt second)
sets data from six integers
OpenMS::Internal::XMLHandler::attributeAsInt_
Int attributeAsInt_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a Int.
Definition: XMLHandler.h:450
OpenMS::String::hasSuffix
bool hasSuffix(const String &string) const
true if String ends with string, false otherwise
OpenMS::Internal::XMLHandler::optionalAttributeAsUInt_
bool optionalAttributeAsUInt_(UInt &value, const xercesc::Attributes &a, const XMLCh *name) const
Assigns the attribute content to the UInt value if the attribute is present.
Definition: XMLHandler.h:668
OpenMS::IntList
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:55
OpenMS::Internal::XMLHandler::optionalAttributeAsInt_
bool optionalAttributeAsInt_(Int &value, const xercesc::Attributes &a, const XMLCh *name) const
Assigns the attribute content to the Int value if the attribute is present.
Definition: XMLHandler.h:656
OpenMS::Internal::XMLHandler::asFloat_
float asFloat_(const String &in)
Conversion of a String to a float value.
Definition: XMLHandler.h:377
OpenMS::Internal::XMLHandler::asBool_
bool asBool_(const String &in)
Conversion of a string to a boolean value.
Definition: XMLHandler.h:398
OpenMS::Internal::XMLHandler::open_tags_
std::vector< String > open_tags_
Stack of open XML tags.
Definition: XMLHandler.h:271
OpenMS::Internal::XMLHandler::optionalAttributeAsString_
bool optionalAttributeAsString_(String &value, const xercesc::Attributes &a, const char *name) const
Assigns the attribute content to the String value if the attribute is present.
Definition: XMLHandler.h:491
OpenMS::Internal::XMLHandler::attributeAsString_
String attributeAsString_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a String.
Definition: XMLHandler.h:442
OpenMS::Internal::XMLHandler::attributeAsIntList_
IntList attributeAsIntList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a IntList.
Definition: XMLHandler.h:630
OpenMS::Internal::XMLHandler::optionalAttributeAsString_
bool optionalAttributeAsString_(String &value, const xercesc::Attributes &a, const XMLCh *name) const
Assigns the attribute content to the String value if the attribute is present.
Definition: XMLHandler.h:644
OpenMS::Internal::XMLHandler::optionalAttributeAsDouble_
bool optionalAttributeAsDouble_(double &value, const xercesc::Attributes &a, const XMLCh *name) const
Assigns the attribute content to the double value if the attribute is present.
Definition: XMLHandler.h:680
OpenMS::String::substitute
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
OpenMS::Internal::XMLHandler::asUInt_
UInt asUInt_(const String &in)
Conversion of a String to an unsigned integer value.
Definition: XMLHandler.h:342
OpenMS::Internal::StringManager::toNative_
String toNative_(const XMLCh *str) const
Definition: XMLHandler.h:92
OpenMS::Internal::XMLHandler::error_message_
String error_message_
Error message of the last error.
Definition: XMLHandler.h:255
OpenMS::String::hasPrefix
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
OpenMS::Internal::XMLHandler::asInt_
Int asInt_(const XMLCh *in)
Conversion of a Xerces string to an integer value.
Definition: XMLHandler.h:336
OpenMS::Internal::XMLHandler::equal_
bool equal_(const XMLCh *a, const XMLCh *b) const
Returns if two Xerces strings are equal.
Definition: XMLHandler.h:278
OpenMS::Internal::StringManager::convert
String convert(const XMLCh *str) const
Transcode the supplied XMLCh* to a String.
Definition: XMLHandler.h:133
OpenMS::Internal::XMLHandler::LD_ALLDATA
Definition: XMLHandler.h:177
Types.h
OpenMS::Internal::XMLHandler::optionalAttributeAsDoubleList_
bool optionalAttributeAsDoubleList_(DoubleList &value, const xercesc::Attributes &a, const char *name) const
Assigns the attribute content to the DoubleList value if the attribute is present.
Definition: XMLHandler.h:555
OpenMS::Internal::XMLHandler::file_
String file_
File name.
Definition: XMLHandler.h:258
OpenMS::Internal::XMLHandler::optionalAttributeAsStringList_
bool optionalAttributeAsStringList_(StringList &value, const xercesc::Attributes &a, const char *name) const
Assigns the attribute content to the StringList value if the attribute is present.
Definition: XMLHandler.h:571
OpenMS::String::has
bool has(Byte byte) const
true if String contains the byte, false otherwise
OpenMS::Internal::XMLHandler::cvStringToEnum_
SignedSize cvStringToEnum_(const Size section, const String &term, const char *message, const SignedSize result_on_error=0)
Definition: XMLHandler.h:299
OpenMS::Internal::XMLHandler::writeXMLEscape
static String writeXMLEscape(const String &to_escape)
Escapes a string and returns the escaped string.
Definition: XMLHandler.h:236
OpenMS::Internal::XMLHandler::attributeAsDouble_
double attributeAsDouble_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a double.
Definition: XMLHandler.h:615
OpenMS::String::toInt
Int toInt() const
Conversion to int.
DateTime.h
OPENMS_PRECONDITION
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:136
OpenMS::String::toDouble
double toDouble() const
Conversion to double.
OpenMS::Internal::XMLHandler::asDateTime_
DateTime asDateTime_(String date_string)
Conversion of a xs:datetime string to a DateTime value.
Definition: XMLHandler.h:416
OpenMS::DoubleList
std::vector< double > DoubleList
Vector of double precision real types.
Definition: ListUtils.h:62
OpenMS::Internal::XMLHandler::attributeAsStringList_
StringList attributeAsStringList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a StringList.
Definition: XMLHandler.h:637
OpenMS::Internal::XMLHandler::optionalAttributeAsIntList_
bool optionalAttributeAsIntList_(IntList &value, const xercesc::Attributes &a, const XMLCh *name) const
Assigns the attribute content to the IntList value if the attribute is present.
Definition: XMLHandler.h:712
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Internal::XMLHandler::attributeAsString_
String attributeAsString_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a String.
Definition: XMLHandler.h:599
OpenMS::Exception::ParseError
Parse Error exception.
Definition: Exception.h:622
OpenMS::Internal::XMLHandler::EndParsingSoftly::EndParsingSoftly
EndParsingSoftly(const char *file, int line, const char *function)
Definition: XMLHandler.h:161
OpenMS::DateTime
DateTime Class.
Definition: DateTime.h:54
OpenMS::Internal::XMLHandler::asDouble_
double asDouble_(const String &in)
Conversion of a String to a double value.
Definition: XMLHandler.h:362
OpenMS::Internal::StringManager::fromNative_
XercesString fromNative_(const char *str) const
Definition: XMLHandler.h:77
OpenMS::Internal::XMLHandler::LOAD
Loading a file.
Definition: XMLHandler.h:171
OpenMS::Internal::XMLHandler::asInt_
Int asInt_(const String &in)
Conversion of a String to an integer value.
Definition: XMLHandler.h:321
OpenMS::Internal::XMLHandler::LOADDETAIL
LOADDETAIL
Definition: XMLHandler.h:175
OpenMS::Internal::StringManager
Definition: XMLHandler.h:71
OpenMS::Internal::XMLHandler::load_detail_
LOADDETAIL load_detail_
parse only until total number of scans and chroms have been determined from attributes ...
Definition: XMLHandler.h:274
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
seqan::find
bool find(TFinder &finder, const Pattern< TNeedle, FuzzyAC > &me, PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:884
OpenMS::Internal::XMLHandler::attributeAsDoubleList_
DoubleList attributeAsDoubleList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a DoubleList.
Definition: XMLHandler.h:466
OpenMS::Internal::XMLHandler::LD_RAWCOUNTS
Definition: XMLHandler.h:178
OpenMS::String::substr
String substr(size_t pos=0, size_t n=npos) const
Wrapper for the STL substr() method. Returns a String object with its contents initialized to a subst...
OpenMS::Internal::XMLHandler::attributeAsStringList_
StringList attributeAsStringList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to an StringList.
Definition: XMLHandler.h:480
OpenMS::Internal::XMLHandler::attributeAsDoubleList_
DoubleList attributeAsDoubleList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a DoubleList.
Definition: XMLHandler.h:623
OpenMS::Internal::StringManager::convert
XercesString convert(const char *str) const
Transcode the supplied C string to a xerces string.
Definition: XMLHandler.h:115
OpenMS::Internal::StringManager::fromNative_
XercesString fromNative_(const String &str) const
Definition: XMLHandler.h:86
OpenMS::Internal::XMLHandler::attributeAsDouble_
double attributeAsDouble_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a double.
Definition: XMLHandler.h:458
OpenMS::Internal::StringManager::convert
XercesString convert(const String &str) const
Transcode the supplied OpenMS string to a xerces string.
Definition: XMLHandler.h:127
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::Internal::XMLHandler::optionalAttributeAsUInt_
bool optionalAttributeAsUInt_(UInt &value, const xercesc::Attributes &a, const char *name) const
Assigns the attribute content to the UInt value if the attribute is present.
Definition: XMLHandler.h:523
OpenMS::Internal::XMLHandler::EndParsingSoftly
Exception that is thrown if the parsing is ended by some event (e.g. if only a prefix of the XML file...
Definition: XMLHandler.h:157
int
OpenMS::Exception::ConversionError
Invalid conversion exception.
Definition: Exception.h:362
OpenMS::Internal::StringManager::toNative_
String toNative_(const XercesString &str) const
Definition: XMLHandler.h:101
Macros.h
MetaInfoInterface.h
OpenMS::Internal::StringManager::convert
XercesString convert(const std::string &str) const
Transcode the supplied C++ string to a xerces string.
Definition: XMLHandler.h:121
OpenMS::String::toFloat
float toFloat() const
Conversion to float.
OpenMS::Internal::XMLHandler::optionalAttributeAsDouble_
bool optionalAttributeAsDouble_(double &value, const xercesc::Attributes &a, const char *name) const
Assigns the attribute content to the double value if the attribute is present.
Definition: XMLHandler.h:539
ListUtils.h
OpenMS::Internal::XMLHandler::attributeAsInt_
Int attributeAsInt_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a Int.
Definition: XMLHandler.h:607
OpenMS::Internal::XMLHandler::attributeAsIntList_
IntList attributeAsIntList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to an IntList.
Definition: XMLHandler.h:473
OpenMS::Internal::XMLHandler::optionalAttributeAsInt_
bool optionalAttributeAsInt_(Int &value, const xercesc::Attributes &a, const char *name) const
Assigns the attribute content to the Int value if the attribute is present.
Definition: XMLHandler.h:507
OpenMS::Internal::XMLHandler
Base class for XML handlers.
Definition: XMLHandler.h:151
OpenMS::Internal::XMLHandler::version_
String version_
Schema version.
Definition: XMLHandler.h:261
OpenMS::MetaInfoInterface
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:60
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::Internal::XMLHandler::optionalAttributeAsStringList_
bool optionalAttributeAsStringList_(StringList &value, const xercesc::Attributes &a, const XMLCh *name) const
Assigns the attribute content to the StringList value if the attribute is present.
Definition: XMLHandler.h:728
OpenMS::Internal::XMLHandler::sm_
StringManager sm_
Helper class for string conversion.
Definition: XMLHandler.h:264
OpenMS::Internal::ClassTest::exception
int exception
(Used by various macros. Indicates a rough category of the exception being caught.)
OpenMS::Internal::XMLHandler::expectList_
const String & expectList_(const String &str) const
Definition: XMLHandler.h:745
OpenMS::String::trim
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...