 | OO-Snippets: Iterate over a SequenceCommons| Keywords | Sequence, Sequences, iterate, iteration |
|---|
| Language | Cpp |
|---|
| Application | Office |
|---|
| Authors | Pierre-André Galmes (initial)
|
|---|
| Supported Versions | 2.0.x |
|---|
| Supported OS | All |
|---|
| Question | Howto iterate over a Sequence ?
|
|---|
| Answer | Use the following routine : |
|---|
#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()
{
[...]
Sequence< ::rtl::OUString > sq =
rxOfficeServiceManager->getAvailableServiceNames();
rtl::OString aOString;
const ::rtl::OUString* sIterator = sq.getConstArray();
const ::rtl::OUString* sEnd = sIterator + sq.getLength();
for ( ; sIterator != sEnd ; ++sIterator)
{
aOString = ::rtl::OUStringToOString ( *sIterator, RTL_TEXTENCODING_UTF8 );
cout << "sq : " << aOString << endl;
}
}
|
Changelog| Date | User | Modification |
|---|
| 2005-09-13 | pagalmes | Initial version |
|