//************************************************************************* // Method: onGetChildNodeCount // Description: called when the pane needs to get the number of child nodes // of a particular node // // Parameters: // node - the node to get the child count of // // Return Value: the child count of the node, 0 if failed //************************************************************************* int LogPaneDataArray::onGetChildNodeCount(TreeListNode *node) { try { IndexerNode *indexerNode = TagToIndexerNode(node->Tag); if (!indexerNode || !indexerNode->children) return 0; return GetChildNodeCount(indexerNode); } catch(...) { return 0; } }
//************************************************************************* // Method: GetChildNodeCount // Description: gets the number of child nodes of a particular node // // Parameters: // node - the node to get the child count of // // Return Value: the child count of the node, 0 if failed //************************************************************************* int LogPaneDataArray::GetChildNodeCount(IndexerNode *node) { int result = 0; if (node && node->children) { for (unsigned int i = 0; i < node->children->GetLength(); i++) { IndexerNode *childNode = (*node->children)[i]; //don't count nodes that won't display if (childNode && (childNode->filePosition == 0)) continue; result += GetChildNodeCount(childNode) + 1; } } return result; }
void MapRequest::setData( const std::string& value ) { _data = value; /// @todo Throw an exception if xml parsing fails XMLNode dataNode = XMLNode::parseString (_data.c_str (), "data"); // Fill in local registries XMLNode citiesNode = GetChildNode (dataNode, "cities", 0); int nbCities = GetChildNodeCount (citiesNode, "city"); for (int i=0; i<nbCities; ++i) { XMLNode cityNode = GetChildNode (citiesNode, "city", i); _temporaryEnvironment.getEditableRegistry<City>().add (pt::XmlBuilder::CreateCity (cityNode)); } XMLNode connectionPlacesNode = GetChildNode (dataNode, "connectionPlaces", 0); int nbConnectionPlaces = GetChildNodeCount (connectionPlacesNode, "connectionPlace"); for (int i=0; i<nbConnectionPlaces; ++i) { XMLNode connectionPlaceNode = GetChildNode (connectionPlacesNode, "connectionPlace", i); _temporaryEnvironment.getEditableRegistry<StopArea>().add (synthese::pt::XmlBuilder::CreateConnectionPlace (connectionPlaceNode, _temporaryEnvironment.getEditableRegistry<City>())); } XMLNode physicalStopsNode = GetChildNode (dataNode, "physicalStops", 0); int nbPhysicalStops = GetChildNodeCount (physicalStopsNode, "physicalStop"); for (int i=0; i<nbPhysicalStops; ++i) { XMLNode physicalStopNode = GetChildNode (physicalStopsNode, "physicalStop", i); _temporaryEnvironment.getEditableRegistry<StopPoint>().add (synthese::pt::XmlBuilder::CreatePhysicalStop (physicalStopNode, _temporaryEnvironment.getEditableRegistry<StopArea>())); } XMLNode commercialLinesNode = GetChildNode (dataNode, "commercialLines", 0); int nbCommercialLines = GetChildNodeCount (commercialLinesNode, "commercialLine"); for (int i=0; i<nbCommercialLines; ++i) { XMLNode commercialLineNode = GetChildNode (commercialLinesNode, "commercialLine", i); _temporaryEnvironment.getEditableRegistry<CommercialLine>().add (synthese::pt::XmlBuilder::CreateCommercialLine (commercialLineNode)); } XMLNode linesNode = GetChildNode (dataNode, "lines", 0); int nbLines = GetChildNodeCount (linesNode, "line"); for (int i=0; i<nbLines; ++i) { XMLNode lineNode = GetChildNode (linesNode, "line", i); _temporaryEnvironment.getEditableRegistry<JourneyPattern>().add( pt::XmlBuilder::CreateLine( lineNode, _temporaryEnvironment.getEditableRegistry<CommercialLine>() ) ); } XMLNode lineStopsNode = GetChildNode (dataNode, "lineStops", 0); int nbLineStops = GetChildNodeCount (lineStopsNode, "lineStop"); for (int i=0; i<nbLineStops; ++i) { XMLNode lineStopNode = GetChildNode (lineStopsNode, "lineStop", i); _temporaryEnvironment.getEditableRegistry<LineStop>().add (synthese::pt::XmlBuilder::CreateLineStop (lineStopNode, _temporaryEnvironment.getEditableRegistry<JourneyPattern>(), _temporaryEnvironment.getEditableRegistry<StopPoint>())); } }