void Token::update_property_isStandardType() { isStandardType(false); if (_str.size() < 3) return; if (stdTypes.find(_str)!=stdTypes.end()) { isStandardType(true); _type = eType; } }
void Token::update_property_isStandardType() { isStandardType(false); if (_str.size() < 3) return; static const char * const stdtype[] = { "bool", "char", "char16_t", "char32_t", "double", "float", "int", "long", "short", "size_t", "void", "wchar_t"}; if (std::binary_search(stdtype, stdtype + sizeof(stdtype) / sizeof(stdtype[0]), _str)) { isStandardType(true); _type = eType; } }
// 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; }