#include "XMLUtils.h"
#include "IPAddressResolver.h"
Functions | |
const cXMLElement * | getUniqueChild (const cXMLElement *node, const char *name) |
const cXMLElement * | getUniqueChildIfExists (const cXMLElement *node, const char *name) |
bool | parseBool (const char *text) |
void | checkTags (const cXMLElement *node, const char *allowed) |
const char * | getParameterStrValue (const cXMLElement *ptr, const char *name, const char *def) |
bool | getParameterBoolValue (const cXMLElement *ptr, const char *name, bool def) |
bool | getParameterBoolValue (const cXMLElement *ptr, const char *name) |
const char * | getParameterStrValue (const cXMLElement *ptr, const char *name) |
int | getParameterIntValue (const cXMLElement *ptr, const char *name, int def) |
int | getParameterIntValue (const cXMLElement *ptr, const char *name) |
IPAddress | getParameterIPAddressValue (const cXMLElement *ptr, const char *name, IPAddress def) |
IPAddress | getParameterIPAddressValue (const cXMLElement *ptr, const char *name) |
double | getParameterDoubleValue (const cXMLElement *ptr, const char *name, double def) |
double | getParameterDoubleValue (const cXMLElement *ptr, const char *name) |
|
00056 { 00057 std::vector<const char *> tags; 00058 00059 cStringTokenizer st(allowed, " "); 00060 const char *nt; 00061 while((nt = st.nextToken())!=NULL) 00062 tags.push_back(nt); 00063 00064 for(cXMLElement *child=node->getFirstChild(); child; child=child->getNextSibling()) 00065 { 00066 unsigned int i; 00067 for(i = 0; i < tags.size(); i++) 00068 if(!strcmp(child->getTagName(), tags[i])) 00069 break; 00070 if(i == tags.size()) 00071 opp_error("subtag <%s> not expected in <%s>", child->getTagName(), node->getTagName()); 00072 } 00073 }
|
|
00094 { 00095 const cXMLElement *xvalue = getUniqueChild(ptr, name); 00096 return parseBool(xvalue->getNodeValue()); 00097 }
|
|
00085 { 00086 const cXMLElement *xvalue = getUniqueChildIfExists(ptr, name); 00087 if(xvalue) 00088 return parseBool(xvalue->getNodeValue()); 00089 else 00090 return def; 00091 }
|
|
00145 { 00146 const cXMLElement *xvalue = getUniqueChild(ptr, name); 00147 return strtod(xvalue->getNodeValue(), NULL); 00148 }
|
|
00136 { 00137 const cXMLElement *xvalue = getUniqueChildIfExists(ptr, name); 00138 if(xvalue) 00139 return strtod(xvalue->getNodeValue(), NULL); 00140 else 00141 return def; 00142 }
|
|
00115 { 00116 const cXMLElement *xvalue = getUniqueChild(ptr, name); 00117 return atoi(xvalue->getNodeValue()); 00118 }
|
|
00106 { 00107 const cXMLElement *xvalue = getUniqueChildIfExists(ptr, name); 00108 if(xvalue) 00109 return atoi(xvalue->getNodeValue()); 00110 else 00111 return def; 00112 }
|
|
00130 { 00131 const cXMLElement *xvalue = getUniqueChild(ptr, name); 00132 return IPAddressResolver().resolve(xvalue->getNodeValue()).get4(); 00133 }
|
|
00121 { 00122 const cXMLElement *xvalue = getUniqueChildIfExists(ptr, name); 00123 if(xvalue) 00124 return IPAddress(xvalue->getNodeValue()); 00125 else 00126 return def; 00127 }
|
|
00100 { 00101 const cXMLElement *xvalue = getUniqueChild(ptr, name); 00102 return xvalue->getNodeValue(); 00103 }
|
|
00076 { 00077 const cXMLElement *xvalue = getUniqueChildIfExists(ptr, name); 00078 if(xvalue) 00079 return xvalue->getNodeValue(); 00080 else 00081 return def; 00082 }
|
|
00010 { 00011 const cXMLElement *child = getUniqueChildIfExists(node, name); 00012 if(!child) 00013 throw new cException("xml error: exactly one %s element expected", name); 00014 00015 return child; 00016 }
|
|
00019 { 00020 cXMLElementList list = node->getChildrenByTagName(name); 00021 if(list.size() > 1) 00022 throw new cException("xml error: at most one %s element expected", name); 00023 else if(list.size() == 1) 00024 return (*list.begin()); 00025 else 00026 return NULL; 00027 }
|
|
00030 { 00031 if(!strcasecmp(text, "down")) 00032 return false; 00033 else if(!strcasecmp(text, "off")) 00034 return false; 00035 else if(!strcasecmp(text, "false")) 00036 return false; 00037 else if(!strcasecmp(text, "no")) 00038 return false; 00039 else if(!strcasecmp(text, "0")) 00040 return false; 00041 else if(!strcasecmp(text, "up")) 00042 return true; 00043 else if(!strcasecmp(text, "on")) 00044 return true; 00045 else if(!strcasecmp(text, "true")) 00046 return true; 00047 else if(!strcasecmp(text, "yes")) 00048 return true; 00049 else if(!strcasecmp(text, "1")) 00050 return true; 00051 else 00052 throw new cException("unknown bool constant: %s", text); 00053 }
|