1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 #include <rtl/string.hxx>
19 const char* matchArray(const char* pSource
, sal_Int32 nSourceSize
, const char* pSearch
,
20 sal_Int32 nSearchSize
)
22 for (sal_Int32 increment
= 0; increment
<= (nSourceSize
- nSearchSize
); ++increment
)
25 // search both arrays if they match
26 for (sal_Int32 index
= 0; index
< nSearchSize
&& bMatch
; ++index
)
28 if (pSource
[index
] != pSearch
[index
])
31 // match has been found
39 const char* matchArrayWithString(const char* pSource
, sal_Int32 nSourceSize
, OString
const& rString
)
41 return matchArray(pSource
, nSourceSize
, rString
.getStr(), rString
.getLength());
44 bool checkArrayForMatchingStrings(const char* pSource
, sal_Int32 nSourceSize
,
45 std::vector
<OString
> const& rStrings
)
49 if (rStrings
.size() < 2)
50 return matchArrayWithString(pSource
, nSourceSize
, rStrings
[0]) != nullptr;
52 const char* pBegin
= pSource
;
53 const char* pCurrent
= pSource
;
54 for (OString
const& rString
: rStrings
)
56 sal_Int32 nCurrentSize
= nSourceSize
- sal_Int32(pCurrent
- pBegin
);
57 pCurrent
= matchArray(pCurrent
, nCurrentSize
, rString
.getStr(), rString
.getLength());
58 if (pCurrent
== nullptr)
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */