Permalink
Browse files

Implement XML::hasSimpleContent() and hasComplexContent()

  • Loading branch information...
aajanki authored and alexp-sssup committed Apr 4, 2011
1 parent 8ad888f commit 21c5095e23ea5f153b5c716891ec6ca6bdfdcf81
Showing with 48 additions and 0 deletions.
  1. +44 −0 scripting/toplevel.cpp
  2. +4 −0 scripting/toplevel.h
View
@@ -567,6 +567,8 @@ void XML::sinit(Class_base* c)
c->setMethodByQName("attributes",AS3,Class<IFunction>::getFunction(attributes),true);
c->setMethodByQName("localName",AS3,Class<IFunction>::getFunction(localName),true);
c->setMethodByQName("appendChild",AS3,Class<IFunction>::getFunction(appendChild),true);
c->setMethodByQName("hasSimpleContent",AS3,Class<IFunction>::getFunction(_hasSimpleContent),true);
c->setMethodByQName("hasComplexContent",AS3,Class<IFunction>::getFunction(_hasComplexContent),true);
}
void XML::buildFromString(const string& str)
@@ -756,6 +758,48 @@ ASFUNCTIONBODY(XML,children)
return retObj;
}
ASFUNCTIONBODY(XML,_hasSimpleContent)
{
XML *th=static_cast<XML*>(obj);
return abstract_b(th->hasSimpleContent());
}
ASFUNCTIONBODY(XML,_hasComplexContent)
{
XML *th=static_cast<XML*>(obj);
return abstract_b(th->hasComplexContent());
}
bool XML::hasSimpleContent() const
{
xmlElementType nodetype=node->cobj()->type;
if(nodetype==XML_COMMENT_NODE || nodetype==XML_PI_NODE)
return false;
const xmlpp::Node::NodeList& children=node->get_children();
xmlpp::Node::NodeList::const_iterator it=children.begin();
for(;it!=children.end();++it)
{
if((*it)->cobj()->type==XML_ELEMENT_NODE)
return false;
}
return true;
}
bool XML::hasComplexContent() const
{
const xmlpp::Node::NodeList& children=node->get_children();
xmlpp::Node::NodeList::const_iterator it=children.begin();
for(;it!=children.end();++it)
{
if((*it)->cobj()->type==XML_ELEMENT_NODE)
return true;
}
return false;
}
void XML::recursiveGetDescendantsByQName(XML* root, xmlpp::Node* node, const tiny_string& name, const tiny_string& ns, std::vector<XML*>& ret)
{
assert(root);
View
@@ -685,11 +685,15 @@ class XML: public ASObject
ASFUNCTION(appendChild);
ASFUNCTION(localName);
ASFUNCTION(generator);
ASFUNCTION(_hasSimpleContent);
ASFUNCTION(_hasComplexContent);
static void buildTraits(ASObject* o){};
static void sinit(Class_base* c);
void getDescendantsByQName(const tiny_string& name, const tiny_string& ns, std::vector<XML*>& ret);
ASObject* getVariableByMultiname(const multiname& name, bool skip_impl, ASObject* base=NULL);
tiny_string toString(bool debugMsg=false);
bool hasSimpleContent() const;
bool hasComplexContent() const;
};
class XMLList: public ASObject

0 comments on commit 21c5095

Please sign in to comment.