1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
12 #include "sal/config.h"
14 #include <string_view>
16 #include "rtl/string.hxx"
17 #include "rtl/ustring.hxx"
18 #include "rtl/ustrbuf.hxx"
19 #include "sal/types.h"
21 void f1a(std::string_view
);
22 // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OString &' with 'std::string_view' [loplugin:stringviewparam]}}
23 char f1b(OString
const& s
)
27 if (s
.isEmpty() || s
.startsWith("foo", &rest
) || s
.endsWith("foo"))
29 f1a(std::string_view(s
));
34 void f2a(std::u16string_view
);
35 // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
36 sal_Unicode
f2b(OUString
const& s
)
40 if (s
.isEmpty() || s
.startsWith("foo", &rest
) || s
.endsWith("foo"))
42 f2a(std::u16string_view(s
));
47 void f3a(OUString
const&) {}
48 using F3
= void(OUString
const&);
49 F3
* f3b() { return f3a
; }
51 SAL_DLLPUBLIC_EXPORT
void f4(OUString
const&) {}
53 template <typename T
> void f5(T
const&);
54 template <> void f5
<OUString
>(OUString
const&) {}
56 void f6([[maybe_unused
]] OUString
const&) {}
59 // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
61 // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
66 // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
67 bool f8(const OUString
& p1
, std::u16string_view p2
) { return p1
== p2
; }
71 // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
72 static bool convertBool(bool& rBool
, const OUString
& rString
)
74 rBool
= rString
== "true";
75 return rBool
|| (rString
== "false");
79 void f9(std::u16string_view
);
80 void f9(OUString
const& s
) { return f9(std::u16string_view(s
)); }
84 S10(std::u16string_view
);
85 S10(OUString
const& s
)
86 : S10(std::u16string_view(s
))
91 // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
92 void f11(const OUString
& f11rString
)
95 buf
.append(f11rString
);
98 // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
99 sal_uInt32
decimalStringToNumber(OUString
const& str
, sal_Int32 nStart
, sal_Int32 nLength
)
101 sal_uInt32 result
= 0;
102 for (sal_Int32 i
= nStart
; i
< nStart
+ nLength
;)
104 sal_uInt32 c
= str
.iterateCodePoints(&i
);
105 sal_uInt32 value
= 0;
108 result
= result
* 10 + value
;
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */