|
OpenMS
2.5.0
|
Go to the documentation of this file.
45 #include <xercesc/util/XMLString.hpp>
46 #include <xercesc/sax2/DefaultHandler.hpp>
47 #include <xercesc/sax/Locator.hpp>
48 #include <xercesc/sax2/Attributes.hpp>
56 class ProteinIdentification;
79 XMLCh* ptr(xercesc::XMLString::transcode(str));
81 xercesc::XMLString::release(&ptr);
88 return fromNative_(str.c_str());
94 char* ptr(xercesc::XMLString::transcode(str));
96 xercesc::XMLString::release(&ptr);
103 return toNative_(str.c_str());
117 return fromNative_(str);
123 return fromNative_(str.c_str());
129 return fromNative_(str.c_str());
135 return toNative_(str);
144 static void appendASCII(
const XMLCh * str,
const XMLSize_t length,
String & result);
152 public xercesc::DefaultHandler
162 Exception::BaseException(file, line, function)
179 LD_COUNTS_WITHOPTIONS
198 void fatalError(
const xercesc::SAXParseException &
exception)
override;
199 void error(
const xercesc::SAXParseException &
exception)
override;
200 void warning(
const xercesc::SAXParseException &
exception)
override;
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;
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;
218 virtual void writeTo(std::ostream & );
224 virtual LOADDETAIL getLoadDetail()
const;
227 virtual void setLoadDetail(
const LOADDETAIL d);
251 void checkUniqueIdentifiers_(
const std::vector<ProteinIdentification>& prot_ids);
278 inline bool equal_(
const XMLCh * a,
const XMLCh * b)
const
280 return xercesc::XMLString::compareString(a, b) == 0;
301 OPENMS_PRECONDITION(section < cv_terms_.size(),
"cvStringToEnum_: Index overflow (section number too large)");
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())
306 return it - cv_terms_[section].begin();
310 warning(LOAD,
String(
"Unexpected CV entry '") + message +
"'='" + term +
"'");
311 return result_on_error;
330 error(LOAD,
String(
"Int conversion error of \"") + in +
"\"");
338 return xercesc::XMLString::parseInt(in);
356 error(LOAD,
String(
"UInt conversion error of \"") + in +
"\"");
371 error(LOAD,
String(
"Double conversion error of \"") + in +
"\"");
386 error(LOAD,
String(
"Float conversion error of \"") + in +
"\"");
400 if (in ==
"true" || in ==
"TRUE" || in ==
"True" || in ==
"1")
404 else if (in ==
"false" || in ==
"FALSE" || in ==
"False" || in ==
"0")
410 error(LOAD,
String(
"Boolean conversion error of \"") + in +
"\"");
419 if (date_string !=
"")
425 date_string = date_string.
substr(0, 19);
426 date_time.
set(date_string);
430 error(LOAD,
String(
"DateTime conversion error of \"") + date_string +
"\"");
444 const XMLCh * val = a.getValue(sm_.
convert(name).c_str());
445 if (val ==
nullptr) fatalError(LOAD,
String(
"Required attribute '") + name +
"' not present!");
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);
460 const XMLCh * val = a.getValue(sm_.
convert(name).c_str());
461 if (val ==
nullptr) fatalError(LOAD,
String(
"Required attribute '") + name +
"' not present!");
468 String tmp(expectList_(attributeAsString_(a, name)));
469 return ListUtils::create<double>(tmp.
substr(1, tmp.size() - 2));
475 String tmp(expectList_(attributeAsString_(a, name)));
476 return ListUtils::create<Int>(tmp.
substr(1, tmp.size() - 2));
482 String tmp(expectList_(attributeAsString_(a, name)));
483 return ListUtils::create<String>(tmp.
substr(1, tmp.size() - 2));
493 const XMLCh * val = a.getValue(sm_.
convert(name).c_str());
509 const XMLCh * val = a.getValue(sm_.
convert(name).c_str());
512 value = xercesc::XMLString::parseInt(val);
525 const XMLCh * val = a.getValue(sm_.
convert(name).c_str());
528 value = xercesc::XMLString::parseInt(val);
541 const XMLCh * val = a.getValue(sm_.
convert(name).c_str());
557 const XMLCh * val = a.getValue(sm_.
convert(name).c_str());
560 value = attributeAsDoubleList_(a, name);
573 const XMLCh * val = a.getValue(sm_.
convert(name).c_str());
576 value = attributeAsStringList_(a, name);
589 const XMLCh * val = a.getValue(sm_.
convert(name).c_str());
592 value = attributeAsIntList_(a, name);
601 const XMLCh * val = a.getValue(name);
602 if (val ==
nullptr) fatalError(LOAD,
String(
"Required attribute '") + sm_.
convert(name) +
"' not present!");
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);
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();
625 String tmp(expectList_(attributeAsString_(a, name)));
626 return ListUtils::create<double>(tmp.
substr(1, tmp.size() - 2));
632 String tmp(expectList_(attributeAsString_(a, name)));
633 return ListUtils::create<Int>(tmp.
substr(1, tmp.size() - 2));
639 String tmp(expectList_(attributeAsString_(a, name)));
640 return ListUtils::create<String>(tmp.
substr(1, tmp.size() - 2));
646 const XMLCh * val = a.getValue(name);
650 return !value.empty();
658 const XMLCh * val = a.getValue(name);
661 value = xercesc::XMLString::parseInt(val);
670 const XMLCh * val = a.getValue(name);
673 value = xercesc::XMLString::parseInt(val);
682 const XMLCh * val = a.getValue(name);
685 value = sm_.
convert(val).toDouble();
698 const XMLCh * val = a.getValue(name);
701 value = attributeAsDoubleList_(a, name);
714 const XMLCh * val = a.getValue(name);
717 value = attributeAsIntList_(a, name);
730 const XMLCh * val = a.getValue(name);
733 value = attributeAsStringList_(a, name);
749 fatalError(LOAD,
String(
"List argument is not a string representation of a list!"));
StringList attributeAsStringList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to an StringList.
Definition: XMLHandler.h:480
Definition: XMLHandler.h:177
String version_
Schema version.
Definition: XMLHandler.h:261
Int attributeAsInt_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a Int.
Definition: XMLHandler.h:450
String attributeAsString_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a String.
Definition: XMLHandler.h:599
Loading a file.
Definition: XMLHandler.h:171
StringList attributeAsStringList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a StringList.
Definition: XMLHandler.h:637
XercesString convert(const char *str) const
Transcode the supplied C string to a xerces string.
Definition: XMLHandler.h:115
float asFloat_(const String &in)
Conversion of a String to a float value.
Definition: XMLHandler.h:377
String convert(const XMLCh *str) const
Transcode the supplied XMLCh* to a String.
Definition: XMLHandler.h:133
Base class for XML handlers.
Definition: XMLHandler.h:151
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
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
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
double toDouble() const
Conversion to double.
double attributeAsDouble_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a double.
Definition: XMLHandler.h:615
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
SignedSize cvStringToEnum_(const Size section, const String &term, const char *message, const SignedSize result_on_error=0)
Definition: XMLHandler.h:299
A more convenient string class.
Definition: String.h:58
String toNative_(const XercesString &str) const
Definition: XMLHandler.h:101
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
DoubleList attributeAsDoubleList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a DoubleList.
Definition: XMLHandler.h:623
std::vector< double > DoubleList
Vector of double precision real types.
Definition: ListUtils.h:62
Invalid conversion exception.
Definition: Exception.h:362
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
DateTime asDateTime_(String date_string)
Conversion of a xs:datetime string to a DateTime value.
Definition: XMLHandler.h:416
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
Definition: XMLHandler.h:178
std::basic_string< XMLCh > XercesString
Definition: XMLHandler.h:74
int exception
(Used by various macros. Indicates a rough category of the exception being caught....
static String writeXMLEscape(const String &to_escape)
Escapes a string and returns the escaped string.
Definition: XMLHandler.h:236
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:55
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:136
LOADDETAIL
Definition: XMLHandler.h:175
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
Definition: XMLHandler.h:71
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
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
const String & expectList_(const String &str) const
Definition: XMLHandler.h:745
String error_message_
Error message of the last error.
Definition: XMLHandler.h:255
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
std::vector< std::vector< String > > cv_terms_
Array of CV term lists (one sublist denotes one term and it's children)
Definition: XMLHandler.h:295
bool equal_(const XMLCh *a, const XMLCh *b) const
Returns if two Xerces strings are equal.
Definition: XMLHandler.h:278
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
String toNative_(const XMLCh *str) const
Definition: XMLHandler.h:92
XercesString fromNative_(const char *str) const
Definition: XMLHandler.h:77
UInt asUInt_(const String &in)
Conversion of a String to an unsigned integer value.
Definition: XMLHandler.h:342
bool has(Byte byte) const
true if String contains the byte, false otherwise
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
std::vector< String > open_tags_
Stack of open XML tags.
Definition: XMLHandler.h:271
IntList attributeAsIntList_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a IntList.
Definition: XMLHandler.h:630
XercesString fromNative_(const String &str) const
Definition: XMLHandler.h:86
Exception base class.
Definition: Exception.h:89
bool hasSuffix(const String &string) const
true if String ends with string, false otherwise
Int asInt_(const String &in)
Conversion of a String to an integer value.
Definition: XMLHandler.h:321
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
void set(UInt month, UInt day, UInt year, UInt hour, UInt minute, UInt second)
sets data from six integers
bool find(TFinder &finder, const Pattern< TNeedle, FuzzyAC > &me, PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:884
double attributeAsDouble_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a double.
Definition: XMLHandler.h:458
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
String attributeAsString_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a String.
Definition: XMLHandler.h:442
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
double asDouble_(const String &in)
Conversion of a String to a double value.
Definition: XMLHandler.h:362
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
Parse Error exception.
Definition: Exception.h:622
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...
ActionMode
Action to set the current mode (for error messages)
Definition: XMLHandler.h:169
Int asInt_(const XMLCh *in)
Conversion of a Xerces string to an integer value.
Definition: XMLHandler.h:336
Int attributeAsInt_(const xercesc::Attributes &a, const XMLCh *name) const
Converts an attribute to a Int.
Definition: XMLHandler.h:607
XercesString convert(const String &str) const
Transcode the supplied OpenMS string to a xerces string.
Definition: XMLHandler.h:127
XercesString convert(const std::string &str) const
Transcode the supplied C++ string to a xerces string.
Definition: XMLHandler.h:121
DoubleList attributeAsDoubleList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to a DoubleList.
Definition: XMLHandler.h:466
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
IntList attributeAsIntList_(const xercesc::Attributes &a, const char *name) const
Converts an attribute to an IntList.
Definition: XMLHandler.h:473
StringManager sm_
Helper class for string conversion.
Definition: XMLHandler.h:264
bool asBool_(const String &in)
Conversion of a string to a boolean value.
Definition: XMLHandler.h:398
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
String file_
File name.
Definition: XMLHandler.h:258
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
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
EndParsingSoftly(const char *file, int line, const char *function)
Definition: XMLHandler.h:161
Int toInt() const
Conversion to int.
DateTime Class.
Definition: DateTime.h:54
float toFloat() const
Conversion to float.
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
LOADDETAIL load_detail_
parse only until total number of scans and chroms have been determined from attributes
Definition: XMLHandler.h:274