void updateGroupNodesVector(GroupNodeVector &groupNodes, std::string thisGroupPath) { StringVector groupPathComponents = stringSplit(thisGroupPath,"/", false); size_t numGroupPathComponents = groupPathComponents.size(); for (int i = 0; i < numGroupPathComponents; i++) { std::string thisNodeName = groupPathComponents[i]; StringVector thisNodeParents; for (int p = 0; p < i; p++) { thisNodeParents.push_back(groupPathComponents[p]); } int existingGroupNodeIndex = -1; // Check if group node already exists for (int g = 0; g < groupNodes.size(); g++) { GroupNodeStruct thisGroupNode = groupNodes[g]; if ( (thisGroupNode.name == thisNodeName) && (thisGroupNode.parents == thisNodeParents) ) { existingGroupNodeIndex = g; break; } } if (-1 == existingGroupNodeIndex) // Group node does not exist { // Create new group node GroupNodeStruct newGroupNode; newGroupNode.id = groupNodes.size(); newGroupNode.name = thisNodeName; newGroupNode.parents = thisNodeParents; groupNodes.push_back(newGroupNode); } else // Group node already exists { // Do nothing } } }
ML_START_NAMESPACE //*********************************************************************************** GroupNodeVector assembleU3DGroupNodeInfo(U3DObjectInfoVector &_u3dObjectInfoVector) // TODO Make it more robust agains illegal group node definition strings { GroupNodeVector groupNodes; GroupNodeStruct rootNode; rootNode.name = ""; groupNodes.push_back(rootNode); for (U3DObjectInfoVector::size_type i = 0; i < _u3dObjectInfoVector.size(); i++) { U3DObjectInfoStruct thisU3DObjectInfo = _u3dObjectInfoVector[i]; std::string thisGroupPath = thisU3DObjectInfo.GroupPath; mlPDF::PDFTools::updateGroupNodesVector(groupNodes, thisGroupPath); } return groupNodes; }