summaryrefslogtreecommitdiffstats
path: root/src/uscxml/util
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2016-06-16 14:51:27 (GMT)
committerStefan Radomski <github@mintwerk.de>2016-06-16 14:51:27 (GMT)
commitfa6b4f074d4be04d913d8b7dc062920341c34ecb (patch)
tree83ae475b184a3b1bccca2a69addcefb6c12d924e /src/uscxml/util
parented6aee05e2843be65c4ab445d79e70dc8dacc07b (diff)
downloaduscxml-fa6b4f074d4be04d913d8b7dc062920341c34ecb.zip
uscxml-fa6b4f074d4be04d913d8b7dc062920341c34ecb.tar.gz
uscxml-fa6b4f074d4be04d913d8b7dc062920341c34ecb.tar.bz2
Fixed issue86 and some more bug fixes
Diffstat (limited to 'src/uscxml/util')
-rw-r--r--src/uscxml/util/DOM.h5
-rw-r--r--src/uscxml/util/Predicates.cpp25
-rw-r--r--src/uscxml/util/Predicates.h2
3 files changed, 23 insertions, 9 deletions
diff --git a/src/uscxml/util/DOM.h b/src/uscxml/util/DOM.h
index 3ab27a3..0b35f40 100644
--- a/src/uscxml/util/DOM.h
+++ b/src/uscxml/util/DOM.h
@@ -118,6 +118,11 @@ protected:
#define XML_PREFIX(element) X(element->getPrefix() ? X(element->getPrefix()).str() + ":" : "")
#if 1
+/**
+ * @todo: More performant XercesStrings
+ * https://alfps.wordpress.com/2010/05/27/cppx-xerces-strings-simplified-by-ownership-part-i/
+ */
+
class USCXML_API X {
public :
diff --git a/src/uscxml/util/Predicates.cpp b/src/uscxml/util/Predicates.cpp
index cd41089..006e8dc 100644
--- a/src/uscxml/util/Predicates.cpp
+++ b/src/uscxml/util/Predicates.cpp
@@ -460,16 +460,25 @@ std::list<DOMElement*> getReachableStates(const DOMElement* root) {
}
-bool isInEmbeddedDocument(const DOMNode* node) {
- // a node is in an embedded document if there is a content element in its parents
- const DOMNode* parent = node;
- while(parent) {
- if(iequals(LOCALNAME(parent), "content")) {
- return true;
+bool areFromSameMachine(const DOMNode* n1, const DOMNode* n2) {
+ // we traverse each nodes parent's until we reach an scxml element or null
+ const DOMNode* p1 = n1;
+ while(p1) {
+ if(iequals(LOCALNAME(p1), "scxml")) {
+ break;
}
- parent = parent->getParentNode();
+ p1 = p1->getParentNode();
}
- return false;
+
+ const DOMNode* p2 = n2;
+ while(p2) {
+ if(iequals(LOCALNAME(p2), "scxml")) {
+ break;
+ }
+ p2 = p2->getParentNode();
+ }
+
+ return p1 == p2;
}
} \ No newline at end of file
diff --git a/src/uscxml/util/Predicates.h b/src/uscxml/util/Predicates.h
index 7bc4a9c..6204d6a 100644
--- a/src/uscxml/util/Predicates.h
+++ b/src/uscxml/util/Predicates.h
@@ -39,7 +39,7 @@ std::list<XERCESC_NS::DOMElement*> getTargetStates(const XERCESC_NS::DOMElement*
std::list<XERCESC_NS::DOMElement*> getEffectiveTargetStates(const XERCESC_NS::DOMElement* transition);
XERCESC_NS::DOMElement* getTransitionDomain(const XERCESC_NS::DOMElement* transition, const XERCESC_NS::DOMElement* root);
-bool isInEmbeddedDocument(const XERCESC_NS::DOMNode* node);
+bool areFromSameMachine(const XERCESC_NS::DOMNode* n1, const XERCESC_NS::DOMNode* n2);
std::list<XERCESC_NS::DOMElement*> getStates(const std::list<std::string>& stateIds, const XERCESC_NS::DOMElement* root);
XERCESC_NS::DOMElement* getState(const std::string& stateId, const XERCESC_NS::DOMElement* root);