summaryrefslogtreecommitdiffstats
path: root/src/uscxml/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/util')
-rw-r--r--src/uscxml/util/DOM.cpp22
-rw-r--r--src/uscxml/util/DOM.h140
-rw-r--r--src/uscxml/util/Predicates.cpp52
-rw-r--r--src/uscxml/util/URL.cpp28
-rw-r--r--src/uscxml/util/URL.h2
5 files changed, 122 insertions, 122 deletions
diff --git a/src/uscxml/util/DOM.cpp b/src/uscxml/util/DOM.cpp
index 7793fb5..1de6423 100644
--- a/src/uscxml/util/DOM.cpp
+++ b/src/uscxml/util/DOM.cpp
@@ -236,13 +236,13 @@ void DOMUtils::inPostFixOrder(const std::set<std::string>& elements,
if (root == NULL)
return;
- for (auto childElem = root->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
+ for (auto childElem = root->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
if (!includeEmbeddedDoc && LOCALNAME(childElem) == "scxml")
continue;
inPostFixOrder(elements, childElem, includeEmbeddedDoc, nodes);
}
- for (auto childElem = root->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
+ for (auto childElem = root->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
if (!includeEmbeddedDoc && TAGNAME(childElem) == XML_PREFIX(root).str() + "scxml")
continue;
@@ -271,14 +271,14 @@ void DOMUtils::inDocumentOrder(const std::set<std::string>& elements,
nodes.push_back((DOMElement*)root);
}
- /// @todo: item from getChildNodes is O(N)!
- DOMElement* child = root->getFirstElementChild();
- while(child) {
- if (includeEmbeddedDoc || TAGNAME(child) != XML_PREFIX(root).str() + "scxml") {
- inDocumentOrder(elements, child, includeEmbeddedDoc, nodes);
- }
+ /// @todo: item from getChildNodes is O(N)!
+ DOMElement* child = root->getFirstElementChild();
+ while(child) {
+ if (includeEmbeddedDoc || TAGNAME(child) != XML_PREFIX(root).str() + "scxml") {
+ inDocumentOrder(elements, child, includeEmbeddedDoc, nodes);
+ }
- child = child->getNextElementSibling();
+ child = child->getNextElementSibling();
}
}
@@ -343,7 +343,7 @@ std::list<DOMElement*> DOMUtils::filterChildElements(const std::string& tagName,
if (!node)
return filteredChildElems;
- for (auto childElem = node->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
+ for (auto childElem = node->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
// std::cerr << TAGNAME(childs.item(i)) << std::endl;
if(iequals(TAGNAME(childElem), tagName)) {
filteredChildElems.push_back((DOMElement*)childElem);
@@ -379,7 +379,7 @@ std::list<DOMNode*> DOMUtils::filterChildType(const DOMNode::NodeType type,
if (!node)
return filteredChildTypes;
- for (auto child = node->getFirstChild(); child; child = child->getNextSibling()) {
+ for (auto child = node->getFirstChild(); child; child = child->getNextSibling()) {
if (child->getNodeType() == type)
filteredChildTypes.push_back(child);
if (recurse) {
diff --git a/src/uscxml/util/DOM.h b/src/uscxml/util/DOM.h
index ae5fa60..e8094cf 100644
--- a/src/uscxml/util/DOM.h
+++ b/src/uscxml/util/DOM.h
@@ -159,7 +159,7 @@ public :
}
X(const char* const fromTranscode) {
-
+
// Call the private transcoding method
_localForm = fromTranscode;
_unicodeForm = XERCESC_NS::XMLString::transcode(fromTranscode);
@@ -168,24 +168,24 @@ public :
X(char* fromTranscode) {
- // Call the private transcoding method
+ // Call the private transcoding method
_localForm = fromTranscode;
_unicodeForm = XERCESC_NS::XMLString::transcode(fromTranscode);
_deallocOther = true;
}
X() {
-
+
_unicodeForm = NULL;
_deallocOther = false;
}
~X() {
-
+
if (_deallocOther)
XERCESC_NS::XMLString::release(&_unicodeForm);
}
-
+
const std::string& str() const {
return _localForm;
}
@@ -202,7 +202,7 @@ public :
operator std::string () {
return _localForm;
}
-
+
protected:
friend USCXML_API std::ostream& operator<< (std::ostream& os, const X& data);
@@ -211,76 +211,76 @@ private:
std::string _localForm;
XMLCh* _unicodeForm;
};
-
+
#else
class USCXML_API X {
public :
- X() {
- }
-
- void operator=(X const &other) {
- localForm = other.localForm;
- if (unicodeForm != NULL) {
- XERCESC_NS::XMLString::release(&unicodeForm);
- }
- unicodeForm = XERCESC_NS::XMLString::replicate(other.unicodeForm);
- }
-
- X(X const &other) {
- localForm = other.localForm;
- unicodeForm = XERCESC_NS::XMLString::replicate(other.unicodeForm);
- }
-
- X(const char* const toTranscode) {
- if (toTranscode != NULL) {
- localForm = toTranscode;
- unicodeForm = XERCESC_NS::XMLString::transcode(toTranscode);
- }
- }
-
- X(const XMLCh* toTranscode) {
- if (toTranscode != NULL) {
- unicodeForm = XERCESC_NS::XMLString::replicate(toTranscode);
- localForm = XERCESC_NS::XMLString::transcode(toTranscode);
- }
- }
-
- X(const std::string& toTranscode) {
- localForm = toTranscode;
- unicodeForm = XERCESC_NS::XMLString::transcode(toTranscode.c_str());
- }
-
- ~X() {
- if (unicodeForm != NULL) {
- XERCESC_NS::XMLString::release(&unicodeForm);
- }
- }
-
- operator XMLCh* () const {
- return unicodeForm;
- }
-
- operator const std::string& () {
- return localForm;
- }
-
- const std::string& str() const {
- return localForm;
- }
-
- const XMLCh* unicode() const {
- return unicodeForm;
- }
+ X() {
+ }
+
+ void operator=(X const &other) {
+ localForm = other.localForm;
+ if (unicodeForm != NULL) {
+ XERCESC_NS::XMLString::release(&unicodeForm);
+ }
+ unicodeForm = XERCESC_NS::XMLString::replicate(other.unicodeForm);
+ }
+
+ X(X const &other) {
+ localForm = other.localForm;
+ unicodeForm = XERCESC_NS::XMLString::replicate(other.unicodeForm);
+ }
+
+ X(const char* const toTranscode) {
+ if (toTranscode != NULL) {
+ localForm = toTranscode;
+ unicodeForm = XERCESC_NS::XMLString::transcode(toTranscode);
+ }
+ }
+
+ X(const XMLCh* toTranscode) {
+ if (toTranscode != NULL) {
+ unicodeForm = XERCESC_NS::XMLString::replicate(toTranscode);
+ localForm = XERCESC_NS::XMLString::transcode(toTranscode);
+ }
+ }
+
+ X(const std::string& toTranscode) {
+ localForm = toTranscode;
+ unicodeForm = XERCESC_NS::XMLString::transcode(toTranscode.c_str());
+ }
+
+ ~X() {
+ if (unicodeForm != NULL) {
+ XERCESC_NS::XMLString::release(&unicodeForm);
+ }
+ }
+
+ operator XMLCh* () const {
+ return unicodeForm;
+ }
+
+ operator const std::string& () {
+ return localForm;
+ }
+
+ const std::string& str() const {
+ return localForm;
+ }
+
+ const XMLCh* unicode() const {
+ return unicodeForm;
+ }
protected:
- friend USCXML_API std::ostream& operator<< (std::ostream& os, const X& data);
+ friend USCXML_API std::ostream& operator<< (std::ostream& os, const X& data);
private:
- XMLCh* unicodeForm = NULL;
- std::string localForm;
-
+ XMLCh* unicodeForm = NULL;
+ std::string localForm;
+
};
#endif
@@ -295,14 +295,14 @@ static const X kElementFinalName = X("final");
static const X kElementOnEntryName = X("onentry");
static const X kElementOnExitName = X("onexit");
static const X kElementHistoryName = X("history");
-
+
static const X kElementRaiseName = X("raise");
static const X kElementIfName = X("if");
static const X kElementElseIfName = X("elseif");
static const X kElementElseName = X("else");
static const X kElementForEachName = X("foreach");
static const X kElementLogName = X("log");
-
+
static const X kElementDataModelName = X("datamodel");
static const X kElementDataName = X("data");
static const X kElementAssignName = X("assign");
@@ -310,7 +310,7 @@ static const X kElementContentName = X("content");
static const X kElementParamName = X("param");
static const X kElementScriptName = X("script");
#endif
-
+
USCXML_API std::ostream& operator<< (std::ostream& os, const X& xmlString);
USCXML_API std::ostream& operator<< (std::ostream& os, const XERCESC_NS::DOMNode& node);
diff --git a/src/uscxml/util/Predicates.cpp b/src/uscxml/util/Predicates.cpp
index 006e8dc..af47c68 100644
--- a/src/uscxml/util/Predicates.cpp
+++ b/src/uscxml/util/Predicates.cpp
@@ -27,7 +27,7 @@ using namespace XERCESC_NS;
std::list<DOMElement*> getChildStates(const DOMElement* state, bool properOnly) {
std::list<DOMElement*> children;
- for (auto childElem = state->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
+ for (auto childElem = state->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
if (isState(childElem, properOnly)) {
children.push_back(childElem);
}
@@ -70,14 +70,14 @@ DOMElement* getSourceState(const DOMElement* transition) {
#define VERBOSE_FIND_LCCA 0
DOMElement* findLCCA(const std::list<DOMElement*>& states) {
-
+
std::list<DOMElement*> ancestors = getProperAncestors(states.front(), NULL);
DOMElement* ancestor = NULL;
#if VERBOSE_FIND_LCCA
- std::cout << "states: " << states.size() << std::endl;
- std::cout << "front: " << DOMUtils::xPathForNode(states.front()) << std::endl;
- std::cout << "ancestors: " << ancestors.size() << std::endl;
+ std::cout << "states: " << states.size() << std::endl;
+ std::cout << "front: " << DOMUtils::xPathForNode(states.front()) << std::endl;
+ std::cout << "ancestors: " << ancestors.size() << std::endl;
#endif
for (auto ancIter = ancestors.begin(); ancIter != ancestors.end(); ancIter++) {
@@ -121,8 +121,8 @@ std::list<DOMElement*> getProperAncestors(const DOMElement* s1, const DOMElement
std::list<DOMElement*> ancestors;
if (isState(s1, false)) {
- // is it correct to also consider pseudo-states?
- // gcc bug in findLCCA with test387, test388, test579, test580 otherwise
+ // is it correct to also consider pseudo-states?
+ // gcc bug in findLCCA with test387, test388, test579, test580 otherwise
DOMNode* node = (DOMNode*)s1;
while((node = node->getParentNode())) {
if (node->getNodeType() != DOMNode::ELEMENT_NODE)
@@ -133,8 +133,8 @@ std::list<DOMElement*> getProperAncestors(const DOMElement* s1, const DOMElement
break;
if (!iequals(LOCALNAME(nodeElem), "parallel") &&
- !iequals(LOCALNAME(nodeElem), "state") &&
- !iequals(LOCALNAME(nodeElem), "scxml"))
+ !iequals(LOCALNAME(nodeElem), "state") &&
+ !iequals(LOCALNAME(nodeElem), "scxml"))
break;
if (node == s2)
break;
@@ -172,11 +172,11 @@ std::list<DOMElement*> getExitSet(const DOMElement* transition, const DOMElement
bool conflicts(const DOMElement* t1, const DOMElement* t2, const DOMElement* root) {
return (
- (getSourceState(t1) == getSourceState(t2)) ||
- (DOMUtils::isDescendant(getSourceState(t1), getSourceState(t2))) ||
- (DOMUtils::isDescendant(getSourceState(t2), getSourceState(t1))) ||
- (DOMUtils::hasIntersection(getExitSet(t1, root), getExitSet(t2, root)))
- );
+ (getSourceState(t1) == getSourceState(t2)) ||
+ (DOMUtils::isDescendant(getSourceState(t1), getSourceState(t2))) ||
+ (DOMUtils::isDescendant(getSourceState(t2), getSourceState(t1))) ||
+ (DOMUtils::hasIntersection(getExitSet(t1, root), getExitSet(t2, root)))
+ );
}
bool isState(const DOMElement* state, bool properOnly) {
@@ -290,7 +290,7 @@ DOMElement* getTransitionDomain(const DOMElement* transition, const DOMElement*
BREAK_LOOP:
tStates.push_front(source);
-
+
return findLCCA(tStates);
}
@@ -370,7 +370,7 @@ std::list<DOMElement*> getInitialStates(const DOMElement* state, const DOMElemen
// first child state
std::list<DOMElement*> initStates;
- for (auto childElem = state->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
+ for (auto childElem = state->getFirstElementChild(); childElem; childElem = childElem->getNextElementSibling()) {
if (isState(childElem)) {
initStates.push_back(childElem);
return initStates;
@@ -461,24 +461,24 @@ std::list<DOMElement*> getReachableStates(const DOMElement* root) {
bool areFromSameMachine(const DOMNode* n1, const DOMNode* n2) {
- // we traverse each nodes parent's until we reach an scxml element or null
+ // 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;
+ break;
}
p1 = p1->getParentNode();
}
- const DOMNode* p2 = n2;
- while(p2) {
- if(iequals(LOCALNAME(p2), "scxml")) {
- break;
- }
- p2 = p2->getParentNode();
- }
+ const DOMNode* p2 = n2;
+ while(p2) {
+ if(iequals(LOCALNAME(p2), "scxml")) {
+ break;
+ }
+ p2 = p2->getParentNode();
+ }
- return p1 == p2;
+ return p1 == p2;
}
} \ No newline at end of file
diff --git a/src/uscxml/util/URL.cpp b/src/uscxml/util/URL.cpp
index 23b9854..79a0ad9 100644
--- a/src/uscxml/util/URL.cpp
+++ b/src/uscxml/util/URL.cpp
@@ -118,8 +118,8 @@ URLImpl::URLImpl(const std::string& url) : _orig(url), _handle(NULL), _requestTy
URLImpl::~URLImpl() {
uriFreeUriMembersA(&_uri);
- if (_handle != NULL)
- curl_easy_cleanup(_handle);
+ if (_handle != NULL)
+ curl_easy_cleanup(_handle);
}
URL URLImpl::resolve(URLImpl* relative, URLImpl* absolute) {
@@ -592,7 +592,7 @@ void URLFetcher::fetchURL(URL& url) {
char* header = (char*)malloc(paramIter->first.size() + strlen(value) + 3);
sprintf(header,"%s: %s", paramIter->first.c_str(), value);
headers = curl_slist_append(headers, header);
- free(header);
+ free(header);
// curl_free(key);
// curl_free(value);
paramIter++;
@@ -600,9 +600,9 @@ void URLFetcher::fetchURL(URL& url) {
// Disable "Expect: 100-continue"
headers = curl_slist_append(headers, "Expect:");
- instance->_handlesToHeaders[handle] = headers;
+ instance->_handlesToHeaders[handle] = headers;
- (curlError = curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers)) == CURLE_OK ||
+ (curlError = curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers)) == CURLE_OK ||
LOG(ERROR) << "Cannot headers for " << std::string(url) << ": " << curl_easy_strerror(curlError);
// curl_slist_free_all(headers);
@@ -632,10 +632,10 @@ void URLFetcher::breakURL(URL& url) {
curl_multi_remove_handle(instance->_multiHandle, handle);
instance->_handlesToURLs.erase(handle);
}
- if (instance->_handlesToHeaders.find(handle) != instance->_handlesToHeaders.end()) {
- curl_slist_free_all(instance->_handlesToHeaders[handle]);
- instance->_handlesToHeaders.erase(handle);
- }
+ if (instance->_handlesToHeaders.find(handle) != instance->_handlesToHeaders.end()) {
+ curl_slist_free_all(instance->_handlesToHeaders[handle]);
+ instance->_handlesToHeaders.erase(handle);
+ }
}
void URLFetcher::start() {
@@ -759,13 +759,13 @@ void URLFetcher::perform() {
if (err != CURLM_OK) {
LOG(WARNING) << "curl_multi_remove_handle: " << curl_multi_strerror(err);
}
- break;
+ break;
}
- _handlesToURLs.erase(msg->easy_handle);
- curl_slist_free_all(_handlesToHeaders[msg->easy_handle]);
- _handlesToHeaders.erase(msg->easy_handle);
-
+ _handlesToURLs.erase(msg->easy_handle);
+ curl_slist_free_all(_handlesToHeaders[msg->easy_handle]);
+ _handlesToHeaders.erase(msg->easy_handle);
+
} else {
LOG(ERROR) << "Curl reports info on unfinished download?!";
}
diff --git a/src/uscxml/util/URL.h b/src/uscxml/util/URL.h
index 2b5c9e0..f6da30d 100644
--- a/src/uscxml/util/URL.h
+++ b/src/uscxml/util/URL.h
@@ -325,7 +325,7 @@ protected:
bool _isStarted;
std::map<CURL*, URL> _handlesToURLs;
- std::map<CURL*, curl_slist*> _handlesToHeaders;
+ std::map<CURL*, curl_slist*> _handlesToHeaders;
CURLM* _multiHandle;
char* _envProxy;
};