Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
2ebda60b
Kaydet (Commit)
2ebda60b
authored
Mar 28, 2012
tarafından
Luboš Luňák
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
more SFINAE to distinguish between const char* and const char[]
üst
86ebc847
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
14 deletions
+56
-14
string.hxx
sal/inc/rtl/string.hxx
+28
-14
test_ostring_stringliterals.cxx
sal/qa/rtl/strings/test_ostring_stringliterals.cxx
+28
-0
No files found.
sal/inc/rtl/string.hxx
Dosyayı görüntüle @
2ebda60b
...
@@ -799,18 +799,8 @@ public:
...
@@ -799,18 +799,8 @@ public:
friend
sal_Bool
operator
==
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
friend
sal_Bool
operator
==
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
{
return
rStr1
.
getLength
()
==
rStr2
.
getLength
()
&&
rStr1
.
compareTo
(
rStr2
)
==
0
;
}
{
return
rStr1
.
getLength
()
==
rStr2
.
getLength
()
&&
rStr1
.
compareTo
(
rStr2
)
==
0
;
}
friend
sal_Bool
operator
==
(
const
OString
&
rStr1
,
const
sal_Char
*
pStr2
)
SAL_THROW
(())
{
return
rStr1
.
compareTo
(
pStr2
)
==
0
;
}
friend
sal_Bool
operator
==
(
const
sal_Char
*
pStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
{
return
OString
(
pStr1
).
compareTo
(
rStr2
)
==
0
;
}
friend
sal_Bool
operator
!=
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
friend
sal_Bool
operator
!=
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
{
return
!
(
operator
==
(
rStr1
,
rStr2
));
}
{
return
!
(
operator
==
(
rStr1
,
rStr2
));
}
friend
sal_Bool
operator
!=
(
const
OString
&
rStr1
,
const
sal_Char
*
pStr2
)
SAL_THROW
(())
{
return
!
(
operator
==
(
rStr1
,
pStr2
));
}
friend
sal_Bool
operator
!=
(
const
sal_Char
*
pStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
{
return
!
(
operator
==
(
pStr1
,
rStr2
));
}
friend
sal_Bool
operator
<
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
friend
sal_Bool
operator
<
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
{
return
rStr1
.
compareTo
(
rStr2
)
<
0
;
}
{
return
rStr1
.
compareTo
(
rStr2
)
<
0
;
}
friend
sal_Bool
operator
>
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
friend
sal_Bool
operator
>
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
...
@@ -820,6 +810,18 @@ public:
...
@@ -820,6 +810,18 @@ public:
friend
sal_Bool
operator
>=
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
friend
sal_Bool
operator
>=
(
const
OString
&
rStr1
,
const
OString
&
rStr2
)
SAL_THROW
(())
{
return
rStr1
.
compareTo
(
rStr2
)
>=
0
;
}
{
return
rStr1
.
compareTo
(
rStr2
)
>=
0
;
}
template
<
typename
T
>
friend
typename
internal
::
CharPtrDetector
<
T
,
bool
>::
Type
operator
==
(
const
OString
&
rStr1
,
const
T
&
value
)
SAL_THROW
(())
{
return
rStr1
.
compareTo
(
value
)
==
0
;
}
template
<
typename
T
>
friend
typename
internal
::
CharPtrDetector
<
T
,
bool
>::
Type
operator
==
(
const
T
&
value
,
const
OString
&
rStr2
)
SAL_THROW
(())
{
return
rStr2
.
compareTo
(
value
)
==
0
;
}
/**
/**
@overload
@overload
This function accepts an ASCII string literal as its argument.
This function accepts an ASCII string literal as its argument.
...
@@ -829,8 +831,8 @@ public:
...
@@ -829,8 +831,8 @@ public:
friend
bool
operator
==
(
const
OString
&
rStr
,
const
char
(
&
literal
)[
N
]
)
SAL_THROW
(())
friend
bool
operator
==
(
const
OString
&
rStr
,
const
char
(
&
literal
)[
N
]
)
SAL_THROW
(())
{
{
RTL_STRING_CONST_FUNCTION
RTL_STRING_CONST_FUNCTION
return
rStr
.
getLength
()
==
N
-
1
&&
rtl_str_compare_WithLength
(
rStr
.
pData
->
buffer
,
rStr
.
pData
->
length
,
return
rStr
.
getLength
()
==
N
-
1
literal
,
N
-
1
)
;
&&
rtl_str_compare_WithLength
(
rStr
.
pData
->
buffer
,
rStr
.
pData
->
length
,
literal
,
N
-
1
)
==
0
;
}
}
/**
/**
...
@@ -856,8 +858,8 @@ public:
...
@@ -856,8 +858,8 @@ public:
friend
bool
operator
==
(
const
char
(
&
literal
)[
N
],
const
OString
&
rStr
)
SAL_THROW
(())
friend
bool
operator
==
(
const
char
(
&
literal
)[
N
],
const
OString
&
rStr
)
SAL_THROW
(())
{
{
RTL_STRING_CONST_FUNCTION
RTL_STRING_CONST_FUNCTION
return
rStr
.
getLength
()
==
N
-
1
&&
rtl_str_compare_WithLength
(
rStr
.
pData
->
buffer
,
rStr
.
pData
->
length
,
return
rStr
.
getLength
()
==
N
-
1
literal
,
N
-
1
)
;
&&
rtl_str_compare_WithLength
(
rStr
.
pData
->
buffer
,
rStr
.
pData
->
length
,
literal
,
N
-
1
)
==
0
;
}
}
/**
/**
...
@@ -874,6 +876,18 @@ public:
...
@@ -874,6 +876,18 @@ public:
return
rStr
.
compareTo
(
value
)
==
0
;
return
rStr
.
compareTo
(
value
)
==
0
;
}
}
template
<
typename
T
>
friend
typename
internal
::
CharPtrDetector
<
T
,
bool
>::
Type
operator
!=
(
const
OString
&
rStr1
,
const
T
&
value
)
SAL_THROW
(())
{
return
!
(
operator
==
(
rStr1
,
value
));
}
template
<
typename
T
>
friend
typename
internal
::
CharPtrDetector
<
T
,
bool
>::
Type
operator
!=
(
const
T
&
value
,
const
OString
&
rStr2
)
SAL_THROW
(())
{
return
!
(
operator
==
(
value
,
rStr2
));
}
/**
/**
@overload
@overload
This function accepts an ASCII string literal as its argument.
This function accepts an ASCII string literal as its argument.
...
...
sal/qa/rtl/strings/test_ostring_stringliterals.cxx
Dosyayı görüntüle @
2ebda60b
...
@@ -149,20 +149,48 @@ void test::ostring::StringLiterals::checkUsage()
...
@@ -149,20 +149,48 @@ void test::ostring::StringLiterals::checkUsage()
rtl_string_unittest_const_literal
=
false
;
// start checking for OString conversions
rtl_string_unittest_const_literal
=
false
;
// start checking for OString conversions
rtl_string_unittest_non_const_literal_function
=
false
;
// and check for non-const variants
rtl_string_unittest_non_const_literal_function
=
false
;
// and check for non-const variants
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT_EQUAL
(
foo
,
rtl
::
OString
()
=
"foo"
);
CPPUNIT_ASSERT_EQUAL
(
foo
,
rtl
::
OString
()
=
"foo"
);
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
FoO
.
equalsIgnoreAsciiCase
(
"fOo"
));
CPPUNIT_ASSERT
(
FoO
.
equalsIgnoreAsciiCase
(
"fOo"
));
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
foobarfoo
.
match
(
"bar"
,
3
));
CPPUNIT_ASSERT
(
foobarfoo
.
match
(
"bar"
,
3
));
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
foobar
.
match
(
"foo"
));
CPPUNIT_ASSERT
(
foobar
.
match
(
"foo"
));
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
FooBaRfoo
.
matchIgnoreAsciiCase
(
"bAr"
,
3
));
CPPUNIT_ASSERT
(
FooBaRfoo
.
matchIgnoreAsciiCase
(
"bAr"
,
3
));
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
FooBaR
.
matchIgnoreAsciiCase
(
"fOo"
));
CPPUNIT_ASSERT
(
FooBaR
.
matchIgnoreAsciiCase
(
"fOo"
));
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
foobar
.
endsWith
(
"bar"
));
CPPUNIT_ASSERT
(
foobar
.
endsWith
(
"bar"
));
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
// rtl_string_unittest_const_literal_function = false;
// CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( "bar" ));
// CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( "bar" ));
// CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
foo
==
"foo"
);
CPPUNIT_ASSERT
(
foo
==
"foo"
);
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
"foo"
==
foo
);
CPPUNIT_ASSERT
(
"foo"
==
foo
);
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
foo
!=
"bar"
);
CPPUNIT_ASSERT
(
foo
!=
"bar"
);
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
"foo"
!=
bar
);
CPPUNIT_ASSERT
(
"foo"
!=
bar
);
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
rtl_string_unittest_const_literal_function
=
false
;
CPPUNIT_ASSERT
(
foobarfoo
.
indexOf
(
"foo"
,
1
)
==
6
);
CPPUNIT_ASSERT
(
foobarfoo
.
indexOf
(
"foo"
,
1
)
==
6
);
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal_function
==
true
);
// rtl_string_unittest_const_literal_function = false;
// CPPUNIT_ASSERT( foobarfoo.lastIndexOf( "foo" ) == 6 );
// CPPUNIT_ASSERT( foobarfoo.lastIndexOf( "foo" ) == 6 );
// CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == true );
// if this is not true, some of the calls above converted to OString
// if this is not true, some of the calls above converted to OString
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal
==
false
);
CPPUNIT_ASSERT
(
rtl_string_unittest_const_literal
==
false
);
// if this is not true, some of the calls above used non-const variants
// if this is not true, some of the calls above used non-const variants
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment