Sequence Sequences iterate iteration Pierre-André Galmes Howto iterate over a Sequence ?

Use the following routine :

/* Copyright (C) 2005 - StarXpert - http://www.starxpert.fr */ #include <iostream> #include <exception> #include <rtl/ustring.hxx> #include <cppuhelper/bootstrap.hxx> #include <com/sun/star/bridge/XUnoUrlResolver.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> using namespace std; using namespace ::rtl; main() { [...] // Get a sequence. Sequence< ::rtl::OUString > sq = rxOfficeServiceManager->getAvailableServiceNames(); // Set some variables on the beginning and the end of the sequence. rtl::OString aOString; const ::rtl::OUString* sIterator = sq.getConstArray(); const ::rtl::OUString* sEnd = sIterator + sq.getLength(); // Iterate and display the result. for ( ; sIterator != sEnd ; ++sIterator) { aOString = ::rtl::OUStringToOString ( *sIterator, RTL_TEXTENCODING_UTF8 ); cout << "sq : " << aOString << endl; } }
Initial version