mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:12:59 +00:00
compiler friendly access operator implemantation
svn path=/trunk/; revision=8913
This commit is contained in:
parent
4309d1082e
commit
77684eece7
2 changed files with 11 additions and 24 deletions
|
@ -234,11 +234,11 @@ void NotifyArea::read_config()
|
||||||
|
|
||||||
NotifyIconConfig cfg;
|
NotifyIconConfig cfg;
|
||||||
|
|
||||||
cfg._name = node["name"];
|
cfg._name = node.get("name");
|
||||||
cfg._tipText = node["text"];
|
cfg._tipText = node.get("text");
|
||||||
cfg._windowTitle = node["window"];
|
cfg._windowTitle = node.get("window");
|
||||||
cfg._modulePath = node["module"];
|
cfg._modulePath = node.get("module");
|
||||||
const string& mode = node["show"];
|
const string& mode = node.get("show");
|
||||||
|
|
||||||
if (mode == "show")
|
if (mode == "show")
|
||||||
cfg._mode = NIM_SHOW;
|
cfg._mode = NIM_SHOW;
|
||||||
|
|
|
@ -331,7 +331,7 @@ struct XMLNode : public String
|
||||||
}
|
}
|
||||||
|
|
||||||
/// read only access to an attribute
|
/// read only access to an attribute
|
||||||
String operator[](const String& attr_name) const
|
template<typename T> String get(const T& attr_name) const
|
||||||
{
|
{
|
||||||
AttributeMap::const_iterator found = _attributes.find(attr_name);
|
AttributeMap::const_iterator found = _attributes.find(attr_name);
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ struct XMLNode : public String
|
||||||
const XMLNode* node = find_first(name);
|
const XMLNode* node = find_first(name);
|
||||||
|
|
||||||
if (node)
|
if (node)
|
||||||
return (*node)[attr_name];
|
return node->get(attr_name);
|
||||||
else
|
else
|
||||||
return TEXT("");
|
return TEXT("");
|
||||||
}
|
}
|
||||||
|
@ -366,26 +366,13 @@ struct XMLNode : public String
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
#ifndef __GNUC__ // avoid GCC complaining about: "ISO C++ says that `String XMLStorage::XMLNode::operator[](const char *) const' and `String & XMLStorage::XMLNode::operator[](const String &)' are ambiguous even though the worst conversion for the former is better than the worst conversion for the latter
|
|
||||||
/// read only access to an attribute
|
|
||||||
String operator[](const char* attr_name) const
|
|
||||||
{
|
|
||||||
AttributeMap::const_iterator found = _attributes.find(attr_name);
|
|
||||||
|
|
||||||
if (found != _attributes.end())
|
|
||||||
return found->second;
|
|
||||||
else
|
|
||||||
return TEXT("");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// convenient value access in children node
|
/// convenient value access in children node
|
||||||
String value(const char* name, const char* attr_name) const
|
String value(const char* name, const char* attr_name) const
|
||||||
{
|
{
|
||||||
const XMLNode* node = find_first(name);
|
const XMLNode* node = find_first(name);
|
||||||
|
|
||||||
if (node)
|
if (node)
|
||||||
return (*node)[attr_name];
|
return node->get(attr_name);
|
||||||
else
|
else
|
||||||
return TEXT("");
|
return TEXT("");
|
||||||
}
|
}
|
||||||
|
@ -468,7 +455,7 @@ protected:
|
||||||
for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it) {
|
for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it) {
|
||||||
const XMLNode& node = **it;
|
const XMLNode& node = **it;
|
||||||
|
|
||||||
if (node==name && node[attr_name]==attr_value)
|
if (node==name && node.get(attr_name)==attr_value)
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +478,7 @@ protected:
|
||||||
for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it) {
|
for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it) {
|
||||||
const XMLNode& node = **it;
|
const XMLNode& node = **it;
|
||||||
|
|
||||||
if (node==name && node[attr_name]==attr_value)
|
if (node==name && node.get(attr_name)==attr_value)
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +633,7 @@ struct XMLPos
|
||||||
|
|
||||||
/// attribute access
|
/// attribute access
|
||||||
String& operator[](const String& attr_name) {return (*_cur)[attr_name];}
|
String& operator[](const String& attr_name) {return (*_cur)[attr_name];}
|
||||||
String operator[](const String& attr_name) const {return (*_cur)[attr_name];}
|
template<typename T> String get(const T& attr_name) const {return (*_cur)[attr_name];}
|
||||||
|
|
||||||
/// insert children when building tree
|
/// insert children when building tree
|
||||||
void add_down(XMLNode* child)
|
void add_down(XMLNode* child)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue