/*! This is called by parseSourceFile() to do the actual parsing and tree building. It only processes qdoc comments. It skips everything else. */ bool PureDocParser::processQdocComments() { QSet<QString> topicCommandsAllowed = topicCommands(); QSet<QString> otherMetacommandsAllowed = otherMetaCommands(); QSet<QString> metacommandsAllowed = topicCommandsAllowed + otherMetacommandsAllowed; while (tok != Tok_Eoi) { if (tok == Tok_Doc) { /* lexeme() returns an entire qdoc comment. */ QString comment = lexeme(); Location start_loc(location()); readToken(); Doc::trimCStyleComment(start_loc,comment); Location end_loc(location()); /* Doc parses the comment. */ Doc doc(start_loc,end_loc,comment,metacommandsAllowed); QString topic; ArgList args; QSet<QString> topicCommandsUsed = topicCommandsAllowed & doc.metaCommandsUsed(); /* There should be one topic command in the set, or none. If the set is empty, then the comment should be a function description. */ if (topicCommandsUsed.count() > 0) { topic = *topicCommandsUsed.begin(); args = doc.metaCommandArgs(topic); } NodeList nodes; QList<Doc> docs; if (topic.isEmpty()) { doc.location().warning(tr("This qdoc comment contains no topic command " "(e.g., '\\%1', '\\%2').") .arg(COMMAND_MODULE).arg(COMMAND_PAGE)); } else { /* There is a topic command. Process it. */ if ((topic == COMMAND_QMLPROPERTY) || (topic == COMMAND_QMLATTACHEDPROPERTY)) { Doc nodeDoc = doc; Node* node = processTopicCommandGroup(nodeDoc,topic,args); if (node != 0) { nodes.append(node); docs.append(nodeDoc); } } else { ArgList::ConstIterator a = args.begin(); while (a != args.end()) { Doc nodeDoc = doc; Node* node = processTopicCommand(nodeDoc,topic,*a); if (node != 0) { nodes.append(node); docs.append(nodeDoc); } ++a; } } } Node* treeRoot = QDocDatabase::qdocDB()->treeRoot(); NodeList::Iterator n = nodes.begin(); QList<Doc>::Iterator d = docs.begin(); while (n != nodes.end()) { processOtherMetaCommands(*d, *n); (*n)->setDoc(*d); checkModuleInclusion(*n); if ((*n)->isInnerNode() && ((InnerNode *)*n)->includes().isEmpty()) { InnerNode *m = static_cast<InnerNode *>(*n); while (m->parent() && m->parent() != treeRoot) m = m->parent(); if (m == *n) ((InnerNode *)*n)->addInclude((*n)->name()); else ((InnerNode *)*n)->setIncludes(m->includes()); } ++d; ++n; } } else { readToken(); } } return true; }
Geostat_grid* Log_data_grid_geometry_xml_io:: read_grid_geometry(QDir dir,const QDomElement& elem, std::string* errors) const { std::string grid_name = elem.attribute("name").toStdString(); QDomElement elemGeom = elem.firstChildElement("Geometry"); QString grid_size_str = elemGeom.attribute("size"); bool ok_size; int size = grid_size_str.toInt(&ok_size); if(!ok_size) { errors->append("Failed to get the size of the grid"); return 0; } SmartPtr<Named_interface> ni = Root::instance()->new_interface( "log_grid://" + grid_name+"::"+grid_size_str.toStdString(), gridModels_manager + "/" + grid_name); Log_data_grid* grid = dynamic_cast<Log_data_grid*>( ni.raw_ptr() ); if(grid==0) return 0; QFile file( dir.absolutePath()+"/coordinates.sgems" ); if( !file.open( QIODevice::ReadOnly ) ) { errors->append("Could not open file coordinates.sgems"); return grid; } QDataStream stream( &file ); #if QT_VERSION >= 0x040600 stream.setFloatingPointPrecision(QDataStream::SinglePrecision); #endif std::vector<Point_set::location_type > coords; for( unsigned int k = 0; k < size; k ++ ) { GsTLCoord x,y,z; stream >> x >> y >> z; coords.push_back( Point_set::location_type( x,y,z) ); } grid->point_locations( coords ); //Read the geometry of each log // typedef std::vector< std::pair< int, std::pair<GsTLPoint ,GsTLPoint > > > segment_geometry_vectorT; // segment_geometry_vectorT log_segments; // std::map<std::string, segment_geometry_vectorT> dh_log_segments; std::vector<Log_data::Segment_geometry> segment_geometries; std::map<std::string,std::vector<Log_data::Segment_geometry> > grid_geometries; QDomElement elemLog = elemGeom.firstChildElement("Log_Geometry"); for( ; !elemLog.isNull(); elemLog = elemLog.nextSiblingElement("Log_Geometry") ){ std::vector<Log_data::Segment_geometry> segment_vector; std::string log_name = elemLog.attribute("name").toStdString(); grid_geometries[log_name] = segment_vector; std::map<std::string, std::vector<Log_data::Segment_geometry> >::iterator it = grid_geometries.find(log_name); QDomElement elemSegment = elemLog.firstChildElement("Segment"); for( ; !elemSegment.isNull(); elemSegment = elemSegment.nextSiblingElement("Segment") ){ int nodeid = elemSegment.attribute("nodeid").toInt(); QStringList start_str = elemSegment.attribute("start").split(","); QStringList end_str = elemSegment.attribute("end").split(","); GsTLPoint start_loc(start_str.at(0).toDouble(),start_str.at(1).toDouble(),start_str.at(2).toDouble()); GsTLPoint end_loc(end_str.at(0).toDouble(),end_str.at(1).toDouble(),end_str.at(2).toDouble()); double from = elemSegment.attribute("from").toDouble(); double to = elemSegment.attribute("to").toDouble(); Log_data::Segment_geometry test(nodeid, start_loc, end_loc, from,to); it->second.push_back( Log_data::Segment_geometry(nodeid, start_loc, end_loc, from,to) ); } } grid->set_log_geometry(grid_geometries); return grid; }