OpenMS  2.4.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-2018.
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
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  namespace Internal
57  {
58 
59  /*
60  * @brief Helper class for XML parsing that handles the conversions of Xerces strings
61  *
62  * It provides the convert() function which internally calls
63  * XMLString::transcode and ensures that the memory is released properly
64  * through XMLString::release internally. It returns a std::string or
65  * std::basic_string<XMLCh> to the caller who takes ownership of the data.
66  *
67  */
68  class OPENMS_DLLAPI StringManager
69  {
70 
71  typedef std::basic_string<XMLCh> XercesString;
72 
73  // Converts from a narrow-character string to a wide-character string.
74  inline XercesString fromNative_(const char* str) const
75  {
76  XMLCh* ptr(xercesc::XMLString::transcode(str));
77  XercesString result(ptr);
78  xercesc::XMLString::release(&ptr);
79  return result;
80  }
81 
82  // Converts from a narrow-character string to a wide-character string.
83  inline XercesString fromNative_(const String& str) const
84  {
85  return fromNative_(str.c_str());
86  }
87 
88  // Converts from a wide-character string to a narrow-character string.
89  inline String toNative_(const XMLCh* str) const
90  {
91  char* ptr(xercesc::XMLString::transcode(str));
92  String result(ptr);
93  xercesc::XMLString::release(&ptr);
94  return result;
95  }
96 
97  // Converts from a wide-character string to a narrow-character string.
98  inline String toNative_(const XercesString& str) const
99  {
100  return toNative_(str.c_str());
101  }
102 
103 
104 public:
106  StringManager();
107 
109  ~StringManager();
110 
112  inline XercesString convert(const char * str) const
113  {
114  return fromNative_(str);
115  }
116 
118  inline XercesString convert(const std::string & str) const
119  {
120  return fromNative_(str.c_str());
121  }
122 
124  inline XercesString convert(const String & str) const
125  {
126  return fromNative_(str.c_str());
127  }
128 
130  inline String convert(const XMLCh * str) const
131  {
132  return toNative_(str);
133  }
134 
141  static void appendASCII(const XMLCh * str, const XMLSize_t length, String & result);
142 
143  };
144 
148  class OPENMS_DLLAPI XMLHandler :
149  public xercesc::DefaultHandler
150  {
151 public:
152 
154  class OPENMS_DLLAPI EndParsingSoftly :
156  {
157  public:
158  EndParsingSoftly(const char * file, int line, const char * function) :
159  Exception::BaseException(file, line, function)
160  {
161  }
162 
163  };
164 
167  {
169  STORE
170  };
171 
173  {
174  LD_ALLDATA, // default; load all data
175  LD_RAWCOUNTS, // only count the total number of spectra and chromatograms (usually very fast)
176  LD_COUNTS_WITHOPTIONS // count the number of spectra, while respecting PeakFileOptions (msLevel and RTRange) and chromatograms (fast)
177  };
178 
179 
181  XMLHandler(const String & filename, const String & version);
183  ~XMLHandler() override;
184 
186  void reset();
187 
188 
195  void fatalError(const xercesc::SAXParseException & exception) override;
196  void error(const xercesc::SAXParseException & exception) override;
197  void warning(const xercesc::SAXParseException & exception) override;
199 
201  void fatalError(ActionMode mode, const String & msg, UInt line = 0, UInt column = 0) const;
203  void error(ActionMode mode, const String & msg, UInt line = 0, UInt column = 0) const;
205  void warning(ActionMode mode, const String & msg, UInt line = 0, UInt column = 0) const;
206 
208  void characters(const XMLCh * const chars, const XMLSize_t length) override;
210  void startElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh * const qname, const xercesc::Attributes & attrs) override;
212  void endElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh * const qname) override;
213 
215  virtual void writeTo(std::ostream & /*os*/);
216 
218  String errorString();
219 
221  virtual LOADDETAIL getLoadDetail() const;
222 
224  virtual void setLoadDetail(const LOADDETAIL d);
225 
233  static String writeXMLEscape(const String& to_escape)
234  {
235  String _copy = to_escape;
236  // has() is cheap, so check before calling substitute(), since substitute() will usually happen rarely
237  if (_copy.has('&')) _copy.substitute("&","&amp;");
238  if (_copy.has('>')) _copy.substitute(">","&gt;");
239  if (_copy.has('"')) _copy.substitute("\"","&quot;");
240  if (_copy.has('<')) _copy.substitute("<","&lt;");
241  if (_copy.has('\'')) _copy.substitute("'","&apos;");
242 
243  return _copy;
244  }
245 
246 protected:
249 
252 
255 
258 
264  std::vector<String> open_tags_;
265 
268 
269 
271  inline bool equal_(const XMLCh * a, const XMLCh * b) const
272  {
273  return xercesc::XMLString::compareString(a, b) == 0;
274  }
275 
277 
278 
280  void writeUserParam_(const String & tag_name, std::ostream & os, const MetaInfoInterface & meta, UInt indent) const;
281 
283 
285 
286 
288  std::vector<std::vector<String> > cv_terms_;
289 
292  inline SignedSize cvStringToEnum_(const Size section, const String & term, const char * message, const SignedSize result_on_error = 0)
293  {
294  OPENMS_PRECONDITION(section < cv_terms_.size(), "cvStringToEnum_: Index overflow (section number too large)");
295 
296  std::vector<String>::const_iterator it = std::find(cv_terms_[section].begin(), cv_terms_[section].end(), term);
297  if (it != cv_terms_[section].end())
298  {
299  return it - cv_terms_[section].begin();
300  }
301  else
302  {
303  warning(LOAD, String("Unexpected CV entry '") + message + "'='" + term + "'");
304  return result_on_error;
305  }
306  }
307 
309 
311 
312 
314  inline Int asInt_(const String & in)
315  {
316  Int res = 0;
317  try
318  {
319  res = in.toInt();
320  }
322  {
323  error(LOAD, String("Int conversion error of \"") + in + "\"");
324  }
325  return res;
326  }
327 
329  inline Int asInt_(const XMLCh * in)
330  {
331  return xercesc::XMLString::parseInt(in);
332  }
333 
335  inline UInt asUInt_(const String & in)
336  {
337  UInt res = 0;
338  try
339  {
340  Int tmp = in.toInt();
341  if (tmp < 0)
342  {
343  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "");
344  }
345  res = UInt(tmp);
346  }
348  {
349  error(LOAD, String("UInt conversion error of \"") + in + "\"");
350  }
351  return res;
352  }
353 
355  inline double asDouble_(const String & in)
356  {
357  double res = 0.0;
358  try
359  {
360  res = in.toDouble();
361  }
363  {
364  error(LOAD, String("Double conversion error of \"") + in + "\"");
365  }
366  return res;
367  }
368 
370  inline float asFloat_(const String & in)
371  {
372  float res = 0.0;
373  try
374  {
375  res = in.toFloat();
376  }
378  {
379  error(LOAD, String("Float conversion error of \"") + in + "\"");
380  }
381  return res;
382  }
383 
391  inline bool asBool_(const String & in)
392  {
393  if (in == "true" || in == "TRUE" || in == "True" || in == "1")
394  {
395  return true;
396  }
397  else if (in == "false" || in == "FALSE" || in == "False" || in == "0")
398  {
399  return false;
400  }
401  else
402  {
403  error(LOAD, String("Boolean conversion error of \"") + in + "\"");
404  }
405  return false;
406  }
407 
409  inline DateTime asDateTime_(String date_string)
410  {
411  DateTime date_time;
412  if (date_string != "")
413  {
414  try
415  {
416  //strip away milliseconds
417  date_string.trim();
418  date_string = date_string.substr(0, 19);
419  date_time.set(date_string);
420  }
421  catch (Exception::ParseError& /*err*/ )
422  {
423  error(LOAD, String("DateTime conversion error of \"") + date_string + "\"");
424  }
425  }
426  return date_time;
427  }
428 
430 
432 
433 
435  inline String attributeAsString_(const xercesc::Attributes & a, const char * name) const
436  {
437  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
438  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + name + "' not present!");
439  return sm_.convert(val);
440  }
441 
443  inline Int attributeAsInt_(const xercesc::Attributes & a, const char * name) const
444  {
445  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
446  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + name + "' not present!");
447  return xercesc::XMLString::parseInt(val);
448  }
449 
451  inline double attributeAsDouble_(const xercesc::Attributes & a, const char * name) const
452  {
453  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
454  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + name + "' not present!");
455  return String(sm_.convert(val)).toDouble();
456  }
457 
459  inline DoubleList attributeAsDoubleList_(const xercesc::Attributes & a, const char * name) const
460  {
461  String tmp(expectList_(attributeAsString_(a, name)));
462  return ListUtils::create<double>(tmp.substr(1, tmp.size() - 2));
463  }
464 
466  inline IntList attributeAsIntList_(const xercesc::Attributes & a, const char * name) const
467  {
468  String tmp(expectList_(attributeAsString_(a, name)));
469  return ListUtils::create<Int>(tmp.substr(1, tmp.size() - 2));
470  }
471 
473  inline StringList attributeAsStringList_(const xercesc::Attributes & a, const char * name) const
474  {
475  String tmp(expectList_(attributeAsString_(a, name)));
476  return ListUtils::create<String>(tmp.substr(1, tmp.size() - 2));
477  }
478 
484  inline bool optionalAttributeAsString_(String & value, const xercesc::Attributes & a, const char * name) const
485  {
486  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
487  if (val != nullptr)
488  {
489  value = sm_.convert(val);
490  return true;
491  }
492  return false;
493  }
494 
500  inline bool optionalAttributeAsInt_(Int & value, const xercesc::Attributes & a, const char * name) const
501  {
502  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
503  if (val != nullptr)
504  {
505  value = xercesc::XMLString::parseInt(val);
506  return true;
507  }
508  return false;
509  }
510 
516  inline bool optionalAttributeAsUInt_(UInt & value, const xercesc::Attributes & a, const char * name) const
517  {
518  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
519  if (val != nullptr)
520  {
521  value = xercesc::XMLString::parseInt(val);
522  return true;
523  }
524  return false;
525  }
526 
532  inline bool optionalAttributeAsDouble_(double & value, const xercesc::Attributes & a, const char * name) const
533  {
534  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
535  if (val != nullptr)
536  {
537  value = String(sm_.convert(val)).toDouble();
538  return true;
539  }
540  return false;
541  }
542 
548  inline bool optionalAttributeAsDoubleList_(DoubleList & value, const xercesc::Attributes & a, const char * name) const
549  {
550  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
551  if (val != nullptr)
552  {
553  value = attributeAsDoubleList_(a, name);
554  return true;
555  }
556  return false;
557  }
558 
564  inline bool optionalAttributeAsStringList_(StringList & value, const xercesc::Attributes & a, const char * name) const
565  {
566  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
567  if (val != nullptr)
568  {
569  value = attributeAsStringList_(a, name);
570  return true;
571  }
572  return false;
573  }
574 
580  inline bool optionalAttributeAsIntList_(IntList & value, const xercesc::Attributes & a, const char * name) const
581  {
582  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
583  if (val != nullptr)
584  {
585  value = attributeAsIntList_(a, name);
586  return true;
587  }
588  return false;
589  }
590 
592  inline String attributeAsString_(const xercesc::Attributes & a, const XMLCh * name) const
593  {
594  const XMLCh * val = a.getValue(name);
595  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + sm_.convert(name) + "' not present!");
596  return sm_.convert(val);
597  }
598 
600  inline Int attributeAsInt_(const xercesc::Attributes & a, const XMLCh * name) const
601  {
602  const XMLCh * val = a.getValue(name);
603  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + sm_.convert(name) + "' not present!");
604  return xercesc::XMLString::parseInt(val);
605  }
606 
608  inline double attributeAsDouble_(const xercesc::Attributes & a, const XMLCh * name) const
609  {
610  const XMLCh * val = a.getValue(name);
611  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + sm_.convert(name) + "' not present!");
612  return String(sm_.convert(val)).toDouble();
613  }
614 
616  inline DoubleList attributeAsDoubleList_(const xercesc::Attributes & a, const XMLCh * name) const
617  {
618  String tmp(expectList_(attributeAsString_(a, name)));
619  return ListUtils::create<double>(tmp.substr(1, tmp.size() - 2));
620  }
621 
623  inline IntList attributeAsIntList_(const xercesc::Attributes & a, const XMLCh * name) const
624  {
625  String tmp(expectList_(attributeAsString_(a, name)));
626  return ListUtils::create<Int>(tmp.substr(1, tmp.size() - 2));
627  }
628 
630  inline StringList attributeAsStringList_(const xercesc::Attributes & a, const XMLCh * name) const
631  {
632  String tmp(expectList_(attributeAsString_(a, name)));
633  return ListUtils::create<String>(tmp.substr(1, tmp.size() - 2));
634  }
635 
637  inline bool optionalAttributeAsString_(String & value, const xercesc::Attributes & a, const XMLCh * name) const
638  {
639  const XMLCh * val = a.getValue(name);
640  if (val != nullptr)
641  {
642  String tmp2 = sm_.convert(val);
643  if (tmp2 != "")
644  {
645  value = tmp2;
646  return true;
647  }
648  }
649  return false;
650  }
651 
653  inline bool optionalAttributeAsInt_(Int & value, const xercesc::Attributes & a, const XMLCh * name) const
654  {
655  const XMLCh * val = a.getValue(name);
656  if (val != nullptr)
657  {
658  value = xercesc::XMLString::parseInt(val);
659  return true;
660  }
661  return false;
662  }
663 
665  inline bool optionalAttributeAsUInt_(UInt & value, const xercesc::Attributes & a, const XMLCh * name) const
666  {
667  const XMLCh * val = a.getValue(name);
668  if (val != nullptr)
669  {
670  value = xercesc::XMLString::parseInt(val);
671  return true;
672  }
673  return false;
674  }
675 
677  inline bool optionalAttributeAsDouble_(double & value, const xercesc::Attributes & a, const XMLCh * name) const
678  {
679  const XMLCh * val = a.getValue(name);
680  if (val != nullptr)
681  {
682  value = String(sm_.convert(val)).toDouble();
683  return true;
684  }
685  return false;
686  }
687 
693  inline bool optionalAttributeAsDoubleList_(DoubleList & value, const xercesc::Attributes & a, const XMLCh * name) const
694  {
695  const XMLCh * val = a.getValue(name);
696  if (val != nullptr)
697  {
698  value = attributeAsDoubleList_(a, name);
699  return true;
700  }
701  return false;
702  }
703 
709  inline bool optionalAttributeAsIntList_(IntList & value, const xercesc::Attributes & a, const XMLCh * name) const
710  {
711  const XMLCh * val = a.getValue(name);
712  if (val != nullptr)
713  {
714  value = attributeAsIntList_(a, name);
715  return true;
716  }
717  return false;
718  }
719 
725  inline bool optionalAttributeAsStringList_(StringList & value, const xercesc::Attributes & a, const XMLCh * name) const
726  {
727  const XMLCh * val = a.getValue(name);
728  if (val != nullptr)
729  {
730  value = attributeAsStringList_(a, name);
731  return true;
732  }
733  return false;
734  }
735 
737 
738 private:
740  XMLHandler();
741 
742  inline String expectList_(const String& str) const
743  {
744  String tmp(str);
745  if (!(tmp.hasPrefix('[') && tmp.hasSuffix(']')))
746  {
747  fatalError(LOAD, String("List argument is not a string representation of a list!"));
748  }
749  return tmp;
750  }
751 
752  };
753 
754  } // namespace Internal
755 } // namespace OpenMS
756 
757 
bool equal_(const XMLCh *a, const XMLCh *b) const
Returns if two Xerces strings are equal.
Definition: XMLHandler.h:271
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:693
std::vector< String > open_tags_
Stack of open XML tags.
Definition: XMLHandler.h:264
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:500
IntList attributeAsIntList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to an IntList.
Definition: XMLHandler.h:466
bool has(Byte byte) const
true if String contains the byte, false otherwise
A more convenient string class.
Definition: String.h:57
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:154
Int asInt_(const XMLCh *in)
Conversion of a Xerces string to an integer value.
Definition: XMLHandler.h:329
String version_
Schema version.
Definition: XMLHandler.h:254
std::vector< double > DoubleList
Vector of double precision real types.
Definition: ListUtils.h:65
StringList attributeAsStringList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to an StringList.
Definition: XMLHandler.h:473
void set(UInt month, UInt day, UInt year, UInt hour, UInt minute, UInt second)
sets data from six integers
SignedSize cvStringToEnum_(const Size section, const String &term, const char *message, const SignedSize result_on_error=0)
Definition: XMLHandler.h:292
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:709
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:106
String expectList_(const String &str) const
Definition: XMLHandler.h:742
XercesString fromNative_(const String &str) const
Definition: XMLHandler.h:83
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
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:532
String toNative_(const XMLCh *str) const
Definition: XMLHandler.h:89
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:58
Base class for XML handlers.
Definition: XMLHandler.h:148
DateTime asDateTime_(String date_string)
Conversion of a xs:datetime string to a DateTime value.
Definition: XMLHandler.h:409
UInt asUInt_(const String &in)
Conversion of a String to an unsigned integer value.
Definition: XMLHandler.h:335
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
ActionMode
Action to set the current mode (for error messages)
Definition: XMLHandler.h:166
double attributeAsDouble_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a double.
Definition: XMLHandler.h:451
Definition: XMLHandler.h:68
Int attributeAsInt_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a Int.
Definition: XMLHandler.h:600
LOADDETAIL load_detail_
parse only until total number of scans and chroms have been determined from attributes ...
Definition: XMLHandler.h:267
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:548
Int attributeAsInt_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a Int.
Definition: XMLHandler.h:443
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
static String writeXMLEscape(const String &to_escape)
Escapes a string and returns the escaped string.
Definition: XMLHandler.h:233
bool find(TFinder &finder, const Pattern< TNeedle, FuzzyAC > &me, PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:884
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:580
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...
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:677
String error_message_
Error message of the last error.
Definition: XMLHandler.h:248
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:637
EndParsingSoftly(const char *file, int line, const char *function)
Definition: XMLHandler.h:158
DoubleList attributeAsDoubleList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a DoubleList.
Definition: XMLHandler.h:616
Int toInt() const
Conversion to int.
String convert(const XMLCh *str) const
Transcode the supplied XMLCh* to a String.
Definition: XMLHandler.h:130
double toDouble() const
Conversion to double.
int exception
(Used by various macros. Indicates a rough category of the exception being caught.)
float asFloat_(const String &in)
Conversion of a String to a float value.
Definition: XMLHandler.h:370
IntList attributeAsIntList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a IntList.
Definition: XMLHandler.h:623
XercesString fromNative_(const char *str) const
Definition: XMLHandler.h:74
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
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:725
bool asBool_(const String &in)
Conversion of a string to a boolean value.
Definition: XMLHandler.h:391
String attributeAsString_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a String.
Definition: XMLHandler.h:435
String attributeAsString_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a String.
Definition: XMLHandler.h:592
float toFloat() const
Conversion to float.
String file_
File name.
Definition: XMLHandler.h:251
XercesString convert(const std::string &str) const
Transcode the supplied C++ string to a xerces string.
Definition: XMLHandler.h:118
Exception base class.
Definition: Exception.h:89
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:55
Invalid conversion exception.
Definition: Exception.h:362
Loading a file.
Definition: XMLHandler.h:168
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:73
double asDouble_(const String &in)
Conversion of a String to a double value.
Definition: XMLHandler.h:355
StringManager sm_
Helper class for string conversion.
Definition: XMLHandler.h:257
Definition: XMLHandler.h:174
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:665
std::basic_string< XMLCh > XercesString
Definition: XMLHandler.h:71
Int asInt_(const String &in)
Conversion of a String to an integer value.
Definition: XMLHandler.h:314
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
DateTime Class.
Definition: DateTime.h:54
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
Definition: XMLHandler.h:175
StringList attributeAsStringList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a StringList.
Definition: XMLHandler.h:630
XercesString convert(const String &str) const
Transcode the supplied OpenMS string to a xerces string.
Definition: XMLHandler.h:124
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:288
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:516
LOADDETAIL
Definition: XMLHandler.h:172
int Int
Signed integer type.
Definition: Types.h:102
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:653
double attributeAsDouble_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a double.
Definition: XMLHandler.h:608
DoubleList attributeAsDoubleList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a DoubleList.
Definition: XMLHandler.h:459
bool hasSuffix(const String &string) const
true if String ends with string, false otherwise
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:564
Parse Error exception.
Definition: Exception.h:622
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:484
String toNative_(const XercesString &str) const
Definition: XMLHandler.h:98
XercesString convert(const char *str) const
Transcode the supplied C string to a xerces string.
Definition: XMLHandler.h:112