summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-08-21 13:58:45 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2019-08-21 16:38:20 +0200
commit8c01d962ee98138acc1a61512f3775610be529be (patch)
tree897353d624d5b95fbd77a4af0b3796dcac1b034b
parent193180164a66927999616fdc976dbaa6710d0344 (diff)
Make comphelper::findValue inline template and drop sequence.cxx
Change-Id: Ibee3424b9a957d5d62e66c3257a4050a2ebc207b Reviewed-on: https://gerrit.libreoffice.org/77881 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--comphelper/Library_comphelper.mk1
-rw-r--r--comphelper/source/misc/sequence.cxx42
-rw-r--r--include/comphelper/sequence.hxx16
3 files changed, 13 insertions, 46 deletions
diff --git a/comphelper/Library_comphelper.mk b/comphelper/Library_comphelper.mk
index 62b59e0f72de..727766a1ec0c 100644
--- a/comphelper/Library_comphelper.mk
+++ b/comphelper/Library_comphelper.mk
@@ -126,7 +126,6 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\
comphelper/source/misc/random \
comphelper/source/misc/SelectionMultiplex \
comphelper/source/misc/sequenceashashmap \
- comphelper/source/misc/sequence \
comphelper/source/misc/servicedecl \
comphelper/source/misc/serviceinfohelper \
comphelper/source/misc/sharedmutex \
diff --git a/comphelper/source/misc/sequence.cxx b/comphelper/source/misc/sequence.cxx
deleted file mode 100644
index 81079de2223c..000000000000
--- a/comphelper/source/misc/sequence.cxx
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <comphelper/sequence.hxx>
-
-namespace comphelper
-{
-sal_Int32 findValue(const css::uno::Sequence< OUString >& _rList, const OUString& _rValue)
-{
- sal_Int32 nLength = _rList.getLength();
-
- // at which position do I find the value?
- const OUString* pTArray = _rList.getConstArray();
- for (sal_Int32 i = 0; i < nLength; ++i, ++pTArray)
- {
- if( *pTArray == _rValue )
- {
- return i;
- }
- }
-
- return -1;
-}
-} // namespace comphelper
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx
index 3c448cd6573a..6eadc5e917cb 100644
--- a/include/comphelper/sequence.hxx
+++ b/include/comphelper/sequence.hxx
@@ -22,17 +22,27 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <osl/diagnose.h>
-#include <comphelper/comphelperdllapi.h>
#include <algorithm>
#include <vector>
namespace comphelper
{
- /** Search the given string within the given sequence, return the position of the first occurrence.
+ /** Search the given value within the given sequence, return the position of the first occurrence.
Returns -1 if nothing found.
*/
- COMPHELPER_DLLPUBLIC sal_Int32 findValue(const css::uno::Sequence< OUString >& _rList, const OUString& _rValue);
+ template <class T1, class T2>
+ inline sal_Int32 findValue(const css::uno::Sequence<T1>& _rList, const T2& _rValue)
+ {
+ // at which position do I find the value?
+ for (sal_Int32 i = 0; i < _rList.getLength(); ++i)
+ {
+ if (_rList[i] == _rValue)
+ return i;
+ }
+
+ return -1;
+ }
/// concat several sequences
template <class T, class... Ss>