X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_Common.cpp;h=8ffc9e126b6938135b3cde07239281aae9969115;hb=68420e410a9846ec7dcb2f4645030455bc374288;hp=9c4df7f57c539174f1496979685e7d8b48c113e9;hpb=6c11e01149120ed3cbdb92d39ceb34e49e6670ae;p=modules%2Fshaper.git diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index 9c4df7f57..8ffc9e126 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -27,7 +27,6 @@ bool isElementNode(xmlNodePtr theNode) bool isNode(xmlNodePtr theNode, const char* theNodeName, ...) { - bool result = false; const xmlChar* aName = theNode->name; if (!aName || !isElementNode(theNode)) { return false; @@ -50,19 +49,44 @@ bool isNode(xmlNodePtr theNode, const char* theNodeName, ...) return false; } +bool isAttributeNode(xmlNodePtr theNode) +{ + if(!isElementNode(theNode)) + return false; + // it's parent is "feature" or "source" or page ("case" or "box") + if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, + WDG_TOOLBOX_BOX, WDG_SWITCH_CASE, NULL)) + return false; + + //it should not be a "source" or a "validator" node + bool isLogical = isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL); + bool isPagedContainer = isNode(theNode, WDG_TOOLBOX, WDG_TOOLBOX_BOX, + WDG_SWITCH, WDG_SWITCH_CASE, NULL); + return !isLogical && !isPagedContainer; +} + bool isWidgetNode(xmlNodePtr theNode) { if(!isElementNode(theNode)) return false; // it's parent is "feature" or "source" - xmlNodePtr aParentNode = theNode->parent; - if(!isNode(aParentNode, NODE_FEATURE, NODE_SOURCE, NULL)) + if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, + WDG_TOOLBOX_BOX, WDG_SWITCH_CASE, NULL)) return false; //it should not be a "source" or a "validator" node return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL); } +// widget api? +bool isCaseNode(xmlNodePtr theNode) +{ + if(!isElementNode(theNode)) + return false; + + return isNode(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL); +} + bool hasChild(xmlNodePtr theNode) { xmlNodePtr aNode = theNode->children; @@ -74,6 +98,48 @@ bool hasChild(xmlNodePtr theNode) return false; } +bool hasParent(xmlNodePtr theNode) +{ + xmlNodePtr aNode = theNode->parent; + if (!aNode) { + return false; + } + for (; aNode; aNode = aNode->next) { + if (isElementNode(theNode)) { + return true; + } + } + return false; +} + +bool hasParent(xmlNodePtr theNode, const char* theNodeName, ...) +{ + if (!hasParent(theNode)) { + return false; // have no parents at all + } + xmlNodePtr aNode = theNode->parent; + const xmlChar* aName = aNode->name; + if (!aName || !isElementNode(aNode)) { + return false; + } + if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) { + return true; + } + va_list args; // define argument list variable + va_start(args, theNodeName); // init list; point to last defined argument + while (true) { + char *anArg = va_arg (args, char*); // get next argument + if (anArg == NULL) + break; + if (!xmlStrcmp(aName, (const xmlChar *) anArg)) { + va_end(args); // cleanup the system stack + return true; + } + } + va_end(args); // cleanup the system stack + return false; +} + bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId, std::list& outValidatorParameters) {