// construct an ebucore skeleton ebucoreParser::ElementStruct ebucoreParser::constructSchema(xercesc::DOMElement * el) { // prepare the element information std::string str (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("name")))); std::string type (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("type")))); std::string ref (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("ref")))); std::string minimum (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("minOccurs")))); std::string maximum (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("maxOccurs")))); // instantiate a new root ebucoreParser::ElementStruct root; // grab the name, the cardinalities, the type, attributes and children root.name = (str.size()>0)?str:ref; root.minCardinality = ((minimum.size()>0)?atoi(minimum.c_str()):1); root.maxCardinality = ((maximum.size()>0)?isUnbounded(maximum):1); root.type = ((type.size()>0)?type:"undefined"); // store the current element type inside the stack to avoid infinite loops ebucoreStack.push_back(root.type); // generate the attributes of the current element root.attribute = ebucoreParser::generateAttributes(removePrefix (type, ":"), el); // generate the children of the current element root.children = generateChildren(removePrefix (type, ":"), el,1); // pop the current element type outside of the stack ebucoreStack.pop_back(); return root; }
double QPsolver_qpOASES::getObjVal( ) const { if ( isUnbounded( ) == true ) return -INFTY; if ( ( isSolved( ) == false ) || ( qp == 0 ) ) return INFTY; return qp->getObjVal( ); }
SimplexData::StepResult SimplexData::simpleSimplexStep(void) { printf("*** BEGIN STEP ***\n"); printTable(); if (isOptimal()) { printf("Optimal, stopping.\n"); return Optimal; } int pivotcol = pickPivotColumn(); if (pivotcol < 0) { printf("Internal error picking pivot column, should never get here!\n"); return InternalError; } printf("Pivot column picked: %d, entering variable x%d\n", pivotcol + 1, collabels[pivotcol]); if (isUnbounded(pivotcol)) { printf("Unbounded, stopping.\n"); return Unbounded; } int pivotrow = pickPivotRow(pivotcol); if (pivotrow < 0) { printf("Internal error picking pivot row, should never get here!\n"); return InternalError; } printf ("Pivot row picked: %d, exit variable x%d\n", pivotrow + 1, rowlabels[pivotrow]); #ifdef ALTERNATE_PIVOT *this = doPivot2(pivotrow, pivotcol); #else *this = doPivot(pivotrow, pivotcol); #endif printTable(); printf("*** END STEP ***\n"); return Continue; }
// include external elements (from groups) void ebucoreParser::generateGroupChildren(std::list<ElementStruct> children, std::string father, xercesc::DOMElement * el) { // store the current position of xercesc pointer xercesc::DOMElement * tmpEl = el; // looking for the group who contains the other elements with the father name while (tmpEl != 0 && !((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) == "group" && xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name"))) == removePrefix(father,":") )) { tmpEl = tmpEl->getNextElementSibling(); } // enter inside the group tmpEl=tmpEl->getFirstElementChild(); // looking for the sequence while (tmpEl != 0 && (std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) != "sequence") { tmpEl = tmpEl->getNextElementSibling(); } // if pointer not null, grab the first child if (tmpEl != 0) { tmpEl=tmpEl->getFirstElementChild(); } // while xerces pointer not null, while (tmpEl != 0) { // if it's an element if ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) == "element") { // prepare the element informations std::string name (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name")))); std::string type (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("type")))); std::string ref (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("ref")))); std::string minimum (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("minOccurs")))); std::string maximum (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("maxOccurs")))); // instantiate the list of children ebucoreParser::ElementStruct internalChildren; // identify the element name internalChildren.name = (name.size()>0)?name:ref; // identify the cardinality and type internalChildren.minCardinality = ((minimum.size()>0)?atoi(minimum.c_str()):1); internalChildren.maxCardinality = ((maximum.size()>0)?isUnbounded(maximum):1); internalChildren.type = ( (type.size()>0) ? type : "" ); // if it is not a standard type if (!isStandardType(type)) { // and if type is not null if (type.size()>0) { // generate attributes internalChildren.attribute = (isDCSimpleType(type)) ? DCAttr : generateAttributes(removePrefix(internalChildren.type, ":"), tmpEl); // and correct the type is required internalChildren.type = ( (isDCSimpleType(type)) ? DCType() : internalChildren.type ); } else { // generate attributes and correct the type is required internalChildren.attribute = (isDCSimpleType(internalChildren.name))? DCAttr : generateAttributes("", tmpEl); internalChildren.type = ( (isDCSimpleType(internalChildren.name)) ? DCType() : "") ; } } // if it is an ebucore element and the type of this element is not present in the element type stack if (isEBUCoreType(internalChildren.type) && !groupExist(internalChildren.type)) { // push the type ebucoreStack.push_back(internalChildren.type); // generate children internalChildren.children = generateChildren(removePrefix(internalChildren.type,":"), el, 1); // pop the type ebucoreStack.pop_back(); } //push the internal child children.push_back(internalChildren); } // next tmpEl = tmpEl->getNextElementSibling(); } }
// generate the children of an elements std::list<ebucoreParser::ElementStruct> ebucoreParser::generateChildren(std::string father, xercesc::DOMElement * el, int level) { // instantiate the children list std::list<ebucoreParser::ElementStruct> children; // copy the current position of xercesc pointer xercesc::DOMElement * tmpEl = el; // while xercesc pointer not null, element different of complexType with the proper name while (tmpEl != 0 && ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) != "complexType" || xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name"))) != father )) { tmpEl = tmpEl->getNextElementSibling();// next } // grab the first child of proper element tmpEl=tmpEl->getFirstElementChild(); // looking for the sequence of elements while (tmpEl != 0 && (std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) != "sequence") { tmpEl = tmpEl->getNextElementSibling(); // next } // if pointer not null, grab the first child of the current element if (tmpEl != 0) { tmpEl=tmpEl->getFirstElementChild(); } // while xerces point not null, loop while (tmpEl != 0) { // if current tag kind is element if ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) == "element") { // prepare the element information std::string name (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name")))); std::string type (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("type")))); std::string ref (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("ref")))); std::string minimum (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("minOccurs")))); std::string maximum (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("maxOccurs")))); // instantiate the children struct ebucoreParser::ElementStruct internalChildren; // grab the right name/references internalChildren.name = (name.size()>0)?name:ref; // identify the cardinality and the type of element internalChildren.minCardinality = ((minimum.size()>0)?atoi(minimum.c_str()):1); internalChildren.maxCardinality = ((maximum.size()>0)?isUnbounded(maximum):1); internalChildren.type = ( (type.size()>0) ? type : "" ); // if type is not standard if (!isStandardType(type)) { // if type is not null if (type.size()>0) { //generate the attribute list of the current element internalChildren.attribute = (isDCSimpleType(type)) ? DCAttr : generateAttributes(removePrefix(internalChildren.type, ":"), tmpEl); // and correct his type if required internalChildren.type = ( (isDCSimpleType(type)) ? DCType() : internalChildren.type ); } else { // generate the attribute list of the current element and correct his type if required internalChildren.attribute = (isDCSimpleType(internalChildren.name))? DCAttr : generateAttributes("", tmpEl); internalChildren.type = ( (isDCSimpleType(internalChildren.name)) ? DCType() : "") ; } } // if element type is ebucore and the type not present in the stack, then if (isEBUCoreType(internalChildren.type) && !groupExist(internalChildren.type)) { ebucoreStack.push_back(internalChildren.type); // push the type // generate the children internalChildren.children = generateChildren(removePrefix(internalChildren.type,":"), el, level+1); ebucoreStack.pop_back(); // pop the type } // push the children list children.push_back(internalChildren); // if the current tag king is group, then } else if ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) == "group") { // generate the children of this group and then add it to current list of children generateGroupChildren(children, xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("ref"))), el); } tmpEl = tmpEl->getNextElementSibling(); // next } return children; }
const NAString ElemDDLFileAttrMaxSize::displayLabel1() const { return NAString("Is unbounded? ") + YesNo(isUnbounded()); }