File indexing completed on 2024-04-06 11:57:32
0001
0002 #ifndef _MISCALIB_READER_FROM_XML_DOM_UTILS_ICC
0003 #define _MISCALIB_READER_FROM_XML_DOM_UTILS_ICC
0004
0005
0006
0007 inline std::string MiscalibReaderFromXMLDomUtils::toString(const XMLCh *str) {
0008 char *name = XERCES_CPP_NAMESPACE::XMLString::transcode(str);
0009 std::string retval(name);
0010 delete[] name;
0011 return retval;
0012 }
0013
0014
0015
0016 inline int MiscalibReaderFromXMLDomUtils::getIntAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attributes,
0017 std::string attr_name,
0018 bool &well_formed_string) {
0019 XMLCh *buffer = XERCES_CPP_NAMESPACE::XMLString::transcode(attr_name.c_str());
0020
0021
0022 char *endptr = nullptr;
0023 int retval = strtol(toString(attributes->getNamedItem(buffer)->getNodeValue()).c_str(), &endptr, 0);
0024 if (*endptr != '\0')
0025 well_formed_string = false;
0026 else
0027 well_formed_string = true;
0028
0029 delete[] buffer;
0030
0031 return retval;
0032 }
0033
0034
0035
0036 inline double MiscalibReaderFromXMLDomUtils::getFloatAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attributes,
0037 std::string attr_name,
0038 bool &well_formed_string) {
0039 XMLCh *buffer = XERCES_CPP_NAMESPACE::XMLString::transcode(attr_name.c_str());
0040
0041 char *endptr = nullptr;
0042 double retval = strtod(toString(attributes->getNamedItem(buffer)->getNodeValue()).c_str(), &endptr);
0043 if (*endptr != '\0')
0044 well_formed_string = false;
0045 else
0046 well_formed_string = true;
0047
0048 delete[] buffer;
0049
0050 return retval;
0051
0052 return retval;
0053 }
0054
0055
0056
0057 inline std::string MiscalibReaderFromXMLDomUtils::getStringAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attributes,
0058 std::string attr_name) {
0059 XMLCh *buffer = XERCES_CPP_NAMESPACE::XMLString::transcode(attr_name.c_str());
0060 std::string retval = toString(attributes->getNamedItem(buffer)->getNodeValue());
0061
0062 delete[] buffer;
0063
0064 return retval;
0065 }
0066
0067
0068
0069 inline bool MiscalibReaderFromXMLDomUtils::hasAttribute(XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attributes,
0070 std::string attr_name) {
0071 bool retval;
0072 XMLCh *buffer = XERCES_CPP_NAMESPACE::XMLString::transcode(attr_name.c_str());
0073 retval = attributes->getNamedItem(buffer) != nullptr;
0074 delete[] buffer;
0075
0076 return retval;
0077 }
0078
0079
0080
0081 #endif