BListItem* BOutlineListView::EachItemUnder(BListItem* underItem, bool oneLevelOnly, BListItem* (*eachFunc)(BListItem* item, void* arg), void* arg) { int32 i = IndexOf(underItem); if (i == -1) return NULL; while (i < FullListCountItems()) { BListItem* item = FullListItemAt(i); // If we jump out of the subtree, return NULL if (item->fLevel < underItem->OutlineLevel()) return NULL; // If the level matches, check the index if (!oneLevelOnly || item->fLevel == underItem->OutlineLevel() + 1) { item = eachFunc(item, arg); if (item != NULL) return item; } i++; } return NULL; }
status_t CDDBQuery::GetSites(bool (*eachFunc)(const char *site, int port, const char *latitude, const char *longitude, const char *description, void *state), void *passThru) { if (!_IsConnected()) _Connect(); BString tmp; tmp = "sites\n"; STRACE((">%s", tmp.String())); if (fSocket.Send(tmp.String(), tmp.Length()) == -1) return B_ERROR; _ReadLine(tmp); if (tmp.FindFirst("210") == -1) { _Disconnect(); return B_ERROR; } for (;;) { BString site; int32 sitePort; BString latitude; BString longitude; BString description; _ReadLine(tmp); if (tmp == ".") break; const char *scanner = tmp.String(); scanner = _GetToken(scanner, site); BString portString; scanner = _GetToken(scanner, portString); sitePort = atoi(portString.String()); scanner = _GetToken(scanner, latitude); scanner = _GetToken(scanner, longitude); description = scanner; if (eachFunc(site.String(), sitePort, latitude.String(), longitude.String(), description.String(), passThru)) break; } _Disconnect(); return B_OK; }