Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
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-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: 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  XMLHandler(const String & filename, const String & version);
175  ~XMLHandler() override;
176 
178  void reset();
179 
180 
187  void fatalError(const xercesc::SAXParseException & exception) override;
188  void error(const xercesc::SAXParseException & exception) override;
189  void warning(const xercesc::SAXParseException & exception) override;
191 
193  void fatalError(ActionMode mode, const String & msg, UInt line = 0, UInt column = 0) const;
195  void error(ActionMode mode, const String & msg, UInt line = 0, UInt column = 0) const;
197  void warning(ActionMode mode, const String & msg, UInt line = 0, UInt column = 0) const;
198 
200  void characters(const XMLCh * const chars, const XMLSize_t length) override;
202  void startElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh * const qname, const xercesc::Attributes & attrs) override;
204  void endElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh * const qname) override;
205 
207  virtual void writeTo(std::ostream & /*os*/);
208 
210  String errorString();
211 
219  static String writeXMLEscape(const String& to_escape)
220  {
221  String _copy = to_escape;
222  // has() is cheap, so check before calling substitute(), since substitute() will usually happen rarely
223  if (_copy.has('&')) _copy.substitute("&","&amp;");
224  if (_copy.has('>')) _copy.substitute(">","&gt;");
225  if (_copy.has('"')) _copy.substitute("\"","&quot;");
226  if (_copy.has('<')) _copy.substitute("<","&lt;");
227  if (_copy.has('\'')) _copy.substitute("'","&apos;");
228 
229  return _copy;
230  }
231 
232 protected:
235 
238 
241 
244 
250  std::vector<String> open_tags_;
251 
253  inline bool equal_(const XMLCh * a, const XMLCh * b) const
254  {
255  return xercesc::XMLString::compareString(a, b) == 0;
256  }
257 
259 
260 
262  void writeUserParam_(const String & tag_name, std::ostream & os, const MetaInfoInterface & meta, UInt indent) const;
263 
265 
267 
268 
270  std::vector<std::vector<String> > cv_terms_;
271 
274  inline SignedSize cvStringToEnum_(const Size section, const String & term, const char * message, const SignedSize result_on_error = 0)
275  {
276  OPENMS_PRECONDITION(section < cv_terms_.size(), "cvStringToEnum_: Index overflow (section number too large)");
277 
278  std::vector<String>::const_iterator it = std::find(cv_terms_[section].begin(), cv_terms_[section].end(), term);
279  if (it != cv_terms_[section].end())
280  {
281  return it - cv_terms_[section].begin();
282  }
283  else
284  {
285  warning(LOAD, String("Unexpected CV entry '") + message + "'='" + term + "'");
286  return result_on_error;
287  }
288  }
289 
291 
293 
294 
296  inline Int asInt_(const String & in)
297  {
298  Int res = 0;
299  try
300  {
301  res = in.toInt();
302  }
304  {
305  error(LOAD, String("Int conversion error of \"") + in + "\"");
306  }
307  return res;
308  }
309 
311  inline Int asInt_(const XMLCh * in)
312  {
313  return xercesc::XMLString::parseInt(in);
314  }
315 
317  inline UInt asUInt_(const String & in)
318  {
319  UInt res = 0;
320  try
321  {
322  Int tmp = in.toInt();
323  if (tmp < 0)
324  {
325  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "");
326  }
327  res = UInt(tmp);
328  }
330  {
331  error(LOAD, String("UInt conversion error of \"") + in + "\"");
332  }
333  return res;
334  }
335 
337  inline double asDouble_(const String & in)
338  {
339  double res = 0.0;
340  try
341  {
342  res = in.toDouble();
343  }
345  {
346  error(LOAD, String("Double conversion error of \"") + in + "\"");
347  }
348  return res;
349  }
350 
352  inline float asFloat_(const String & in)
353  {
354  float res = 0.0;
355  try
356  {
357  res = in.toFloat();
358  }
360  {
361  error(LOAD, String("Float conversion error of \"") + in + "\"");
362  }
363  return res;
364  }
365 
373  inline bool asBool_(const String & in)
374  {
375  if (in == "true" || in == "TRUE" || in == "True" || in == "1")
376  {
377  return true;
378  }
379  else if (in == "false" || in == "FALSE" || in == "False" || in == "0")
380  {
381  return false;
382  }
383  else
384  {
385  error(LOAD, String("Boolean conversion error of \"") + in + "\"");
386  }
387  return false;
388  }
389 
391  inline DateTime asDateTime_(String date_string)
392  {
393  DateTime date_time;
394  if (date_string != "")
395  {
396  try
397  {
398  //strip away milliseconds
399  date_string.trim();
400  date_string = date_string.substr(0, 19);
401  date_time.set(date_string);
402  }
403  catch (Exception::ParseError& /*err*/ )
404  {
405  error(LOAD, String("DateTime conversion error of \"") + date_string + "\"");
406  }
407  }
408  return date_time;
409  }
410 
412 
414 
415 
417  inline String attributeAsString_(const xercesc::Attributes & a, const char * name) const
418  {
419  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
420  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + name + "' not present!");
421  return sm_.convert(val);
422  }
423 
425  inline Int attributeAsInt_(const xercesc::Attributes & a, const char * name) const
426  {
427  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
428  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + name + "' not present!");
429  return xercesc::XMLString::parseInt(val);
430  }
431 
433  inline double attributeAsDouble_(const xercesc::Attributes & a, const char * name) const
434  {
435  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
436  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + name + "' not present!");
437  return String(sm_.convert(val)).toDouble();
438  }
439 
441  inline DoubleList attributeAsDoubleList_(const xercesc::Attributes & a, const char * name) const
442  {
443  String tmp(expectList_(attributeAsString_(a, name)));
444  return ListUtils::create<double>(tmp.substr(1, tmp.size() - 2));
445  }
446 
448  inline IntList attributeAsIntList_(const xercesc::Attributes & a, const char * name) const
449  {
450  String tmp(expectList_(attributeAsString_(a, name)));
451  return ListUtils::create<Int>(tmp.substr(1, tmp.size() - 2));
452  }
453 
455  inline StringList attributeAsStringList_(const xercesc::Attributes & a, const char * name) const
456  {
457  String tmp(expectList_(attributeAsString_(a, name)));
458  return ListUtils::create<String>(tmp.substr(1, tmp.size() - 2));
459  }
460 
466  inline bool optionalAttributeAsString_(String & value, const xercesc::Attributes & a, const char * name) const
467  {
468  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
469  if (val != nullptr)
470  {
471  value = sm_.convert(val);
472  return true;
473  }
474  return false;
475  }
476 
482  inline bool optionalAttributeAsInt_(Int & value, const xercesc::Attributes & a, const char * name) const
483  {
484  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
485  if (val != nullptr)
486  {
487  value = xercesc::XMLString::parseInt(val);
488  return true;
489  }
490  return false;
491  }
492 
498  inline bool optionalAttributeAsUInt_(UInt & value, const xercesc::Attributes & a, const char * name) const
499  {
500  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
501  if (val != nullptr)
502  {
503  value = xercesc::XMLString::parseInt(val);
504  return true;
505  }
506  return false;
507  }
508 
514  inline bool optionalAttributeAsDouble_(double & value, const xercesc::Attributes & a, const char * name) const
515  {
516  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
517  if (val != nullptr)
518  {
519  value = String(sm_.convert(val)).toDouble();
520  return true;
521  }
522  return false;
523  }
524 
530  inline bool optionalAttributeAsDoubleList_(DoubleList & value, const xercesc::Attributes & a, const char * name) const
531  {
532  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
533  if (val != nullptr)
534  {
535  value = attributeAsDoubleList_(a, name);
536  return true;
537  }
538  return false;
539  }
540 
546  inline bool optionalAttributeAsStringList_(StringList & value, const xercesc::Attributes & a, const char * name) const
547  {
548  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
549  if (val != nullptr)
550  {
551  value = attributeAsStringList_(a, name);
552  return true;
553  }
554  return false;
555  }
556 
562  inline bool optionalAttributeAsIntList_(IntList & value, const xercesc::Attributes & a, const char * name) const
563  {
564  const XMLCh * val = a.getValue(sm_.convert(name).c_str());
565  if (val != nullptr)
566  {
567  value = attributeAsIntList_(a, name);
568  return true;
569  }
570  return false;
571  }
572 
574  inline String attributeAsString_(const xercesc::Attributes & a, const XMLCh * name) const
575  {
576  const XMLCh * val = a.getValue(name);
577  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + sm_.convert(name) + "' not present!");
578  return sm_.convert(val);
579  }
580 
582  inline Int attributeAsInt_(const xercesc::Attributes & a, const XMLCh * name) const
583  {
584  const XMLCh * val = a.getValue(name);
585  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + sm_.convert(name) + "' not present!");
586  return xercesc::XMLString::parseInt(val);
587  }
588 
590  inline double attributeAsDouble_(const xercesc::Attributes & a, const XMLCh * name) const
591  {
592  const XMLCh * val = a.getValue(name);
593  if (val == nullptr) fatalError(LOAD, String("Required attribute '") + sm_.convert(name) + "' not present!");
594  return String(sm_.convert(val)).toDouble();
595  }
596 
598  inline DoubleList attributeAsDoubleList_(const xercesc::Attributes & a, const XMLCh * name) const
599  {
600  String tmp(expectList_(attributeAsString_(a, name)));
601  return ListUtils::create<double>(tmp.substr(1, tmp.size() - 2));
602  }
603 
605  inline IntList attributeAsIntList_(const xercesc::Attributes & a, const XMLCh * name) const
606  {
607  String tmp(expectList_(attributeAsString_(a, name)));
608  return ListUtils::create<Int>(tmp.substr(1, tmp.size() - 2));
609  }
610 
612  inline StringList attributeAsStringList_(const xercesc::Attributes & a, const XMLCh * name) const
613  {
614  String tmp(expectList_(attributeAsString_(a, name)));
615  return ListUtils::create<String>(tmp.substr(1, tmp.size() - 2));
616  }
617 
619  inline bool optionalAttributeAsString_(String & value, const xercesc::Attributes & a, const XMLCh * name) const
620  {
621  const XMLCh * val = a.getValue(name);
622  if (val != nullptr)
623  {
624  String tmp2 = sm_.convert(val);
625  if (tmp2 != "")
626  {
627  value = tmp2;
628  return true;
629  }
630  }
631  return false;
632  }
633 
635  inline bool optionalAttributeAsInt_(Int & value, const xercesc::Attributes & a, const XMLCh * name) const
636  {
637  const XMLCh * val = a.getValue(name);
638  if (val != nullptr)
639  {
640  value = xercesc::XMLString::parseInt(val);
641  return true;
642  }
643  return false;
644  }
645 
647  inline bool optionalAttributeAsUInt_(UInt & value, const xercesc::Attributes & a, const XMLCh * name) const
648  {
649  const XMLCh * val = a.getValue(name);
650  if (val != nullptr)
651  {
652  value = xercesc::XMLString::parseInt(val);
653  return true;
654  }
655  return false;
656  }
657 
659  inline bool optionalAttributeAsDouble_(double & value, const xercesc::Attributes & a, const XMLCh * name) const
660  {
661  const XMLCh * val = a.getValue(name);
662  if (val != nullptr)
663  {
664  value = String(sm_.convert(val)).toDouble();
665  return true;
666  }
667  return false;
668  }
669 
675  inline bool optionalAttributeAsDoubleList_(DoubleList & value, const xercesc::Attributes & a, const XMLCh * name) const
676  {
677  const XMLCh * val = a.getValue(name);
678  if (val != nullptr)
679  {
680  value = attributeAsDoubleList_(a, name);
681  return true;
682  }
683  return false;
684  }
685 
691  inline bool optionalAttributeAsIntList_(IntList & value, const xercesc::Attributes & a, const XMLCh * name) const
692  {
693  const XMLCh * val = a.getValue(name);
694  if (val != nullptr)
695  {
696  value = attributeAsIntList_(a, name);
697  return true;
698  }
699  return false;
700  }
701 
707  inline bool optionalAttributeAsStringList_(StringList & value, const xercesc::Attributes & a, const XMLCh * name) const
708  {
709  const XMLCh * val = a.getValue(name);
710  if (val != nullptr)
711  {
712  value = attributeAsStringList_(a, name);
713  return true;
714  }
715  return false;
716  }
717 
719 
720 private:
722  XMLHandler();
723 
724  inline String expectList_(const String& str) const
725  {
726  String tmp(str);
727  if (!(tmp.hasPrefix('[') && tmp.hasSuffix(']')))
728  {
729  fatalError(LOAD, String("List argument is not a string representation of a list!"));
730  }
731  return tmp;
732  }
733 
734  };
735 
736  } // namespace Internal
737 } // namespace OpenMS
738 
739 
bool equal_(const XMLCh *a, const XMLCh *b) const
Returns if two Xerces strings are equal.
Definition: XMLHandler.h:253
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:675
std::vector< String > open_tags_
Stack of open XML tags.
Definition: XMLHandler.h:250
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:482
IntList attributeAsIntList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to an IntList.
Definition: XMLHandler.h:448
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:311
String version_
Schema version.
Definition: XMLHandler.h:240
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:455
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:274
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:691
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:106
String expectList_(const String &str) const
Definition: XMLHandler.h:724
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:514
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:391
UInt asUInt_(const String &in)
Conversion of a String to an unsigned integer value.
Definition: XMLHandler.h:317
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:433
Definition: XMLHandler.h:68
Int attributeAsInt_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a Int.
Definition: XMLHandler.h:582
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:530
Int attributeAsInt_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a Int.
Definition: XMLHandler.h:425
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:219
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:562
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:659
String error_message_
Error message of the last error.
Definition: XMLHandler.h:234
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:619
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:598
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:352
IntList attributeAsIntList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a IntList.
Definition: XMLHandler.h:605
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:707
bool asBool_(const String &in)
Conversion of a string to a boolean value.
Definition: XMLHandler.h:373
String attributeAsString_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a String.
Definition: XMLHandler.h:417
String attributeAsString_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a String.
Definition: XMLHandler.h:574
float toFloat() const
Conversion to float.
String file_
File name.
Definition: XMLHandler.h:237
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:337
StringManager sm_
Helper class for string conversion.
Definition: XMLHandler.h:243
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:647
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:296
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.
StringList attributeAsStringList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a StringList.
Definition: XMLHandler.h:612
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:270
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:498
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:635
double attributeAsDouble_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a double.
Definition: XMLHandler.h:590
DoubleList attributeAsDoubleList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a DoubleList.
Definition: XMLHandler.h:441
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:546
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:466
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

OpenMS / TOPP release 2.3.0 Documentation generated on Wed Apr 18 2018 19:29:09 using doxygen 1.8.14