Goodbye O[U]StringView, welcome O[U]String::Concat
O[U]StringView had an odd mixture of uses. For one, it was used like std::[u16]string_view, for which directly using the latter std types is clearly the better alternative. For another, it was used in concatenation sequences, when neither of the two leading terms were of our rtl string-related types. For that second use case introduce O[U]String::Concat (as std::[u16]string_view can obviously not be used, those not being one of our rtl string-related types). Also, O[U]StringLiteral is occasionally used for this, but the planned changes outlined in the 33ecd0d5c4fff9511a8436513936a3f7044a775a "Change OUStringLiteral from char[] to char16_t[]" commit message will make that no longer work, so O[U]String::Concat will be the preferred solution in such use cases going forward, too. O[U]StringView was also occasionally used to include O[U]StringBuffer values in concatenation sequences, for which a more obvious alternative is to make O[U]StringBuffer participate directly in the ToStringHelper/O[U]StringConcat machinery. Change-Id: I1f0e8d836796c9ae01c45f32c518be5f52976622 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101586 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
6379f79970
commit
2e21240f23
@ -379,7 +379,7 @@ void MethodDescriptor::addTypeParameter(OUString const & name) {
|
||||
}
|
||||
|
||||
OString MethodDescriptor::getDescriptor() const {
|
||||
return rtl::OStringView(m_descriptorStart) + m_descriptorEnd;
|
||||
return m_descriptorStart + m_descriptorEnd;
|
||||
}
|
||||
|
||||
|
||||
|
@ -489,7 +489,7 @@ void PreparedStatement::setBytes(
|
||||
*this, OUString(), 1, Any() );
|
||||
}
|
||||
m_vars[parameterIndex-1]
|
||||
= "'" + rtl::OStringView(reinterpret_cast<char *>(escapedString.get()), len -1) + "'";
|
||||
= OString::Concat("'") + std::string_view(reinterpret_cast<char *>(escapedString.get()), len -1) + "'";
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,7 +199,7 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
OString aUDName = rtl::OStringView(rule) + "_" + aLanguage;
|
||||
OString aUDName = OString::Concat(rule) + "_" + aLanguage;
|
||||
UDataMemory* pUData = udata_open("OpenOffice", "brk", aUDName.getStr(), &status);
|
||||
if( U_SUCCESS(status) )
|
||||
rbi = std::make_shared<OOoRuleBasedBreakIterator>( pUData, status);
|
||||
|
@ -166,11 +166,11 @@ void xdictionary::initDictionaryData(const char *pLang)
|
||||
|
||||
#ifdef SAL_DLLPREFIX
|
||||
OString sModuleName = // mostly "lib*.so" (with * == dict_zh)
|
||||
SAL_DLLPREFIX
|
||||
OString::Concat(SAL_DLLPREFIX "dict_") + pLang + SAL_DLLEXTENSION;
|
||||
#else
|
||||
OString sModuleName = // mostly "*.dll" (with * == dict_zh)
|
||||
OString::Concat("dict_") + pLang + SAL_DLLEXTENSION;
|
||||
#endif
|
||||
"dict_" + rtl::OStringView(pLang) + SAL_DLLEXTENSION;
|
||||
aEntry.mhModule = osl_loadModuleRelativeAscii( &thisModule, sModuleName.getStr(), SAL_LOADMODULE_DEFAULT );
|
||||
if( aEntry.mhModule ) {
|
||||
oslGenericFunction func;
|
||||
|
@ -550,7 +550,7 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
|
||||
{
|
||||
(*pOutCachedItem).reset(new LocaleDataLookupTableItem( rCurrent ));
|
||||
(*pOutCachedItem)->localeName = i.pLocale;
|
||||
OString sSymbolName = rtl::OStringView(pFunction) + "_" +
|
||||
OString sSymbolName = OString::Concat(pFunction) + "_" +
|
||||
(*pOutCachedItem)->localeName;
|
||||
return (*pOutCachedItem)->module->getFunctionSymbol(
|
||||
sSymbolName.getStr());
|
||||
@ -563,10 +563,10 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
|
||||
// Library not loaded, load it and add it to the list.
|
||||
#ifdef SAL_DLLPREFIX
|
||||
OString sModuleName = // mostly "lib*.so"
|
||||
SAL_DLLPREFIX + rtl::OStringView(i.pLib) + SAL_DLLEXTENSION;
|
||||
OString::Concat(SAL_DLLPREFIX) + i.pLib + SAL_DLLEXTENSION;
|
||||
#else
|
||||
OString sModuleName = // mostly "*.dll"
|
||||
rtl::OStringView(i.pLib) + SAL_DLLEXTENSION;
|
||||
OString::Concat(i.pLib) + SAL_DLLEXTENSION;
|
||||
#endif
|
||||
std::unique_ptr<osl::Module> module(new osl::Module());
|
||||
if ( module->loadRelative(&thisModule, sModuleName.getStr()) )
|
||||
@ -578,7 +578,7 @@ oslGenericFunction lcl_LookupTableHelper::getFunctionSymbolByName(
|
||||
if( pOutCachedItem )
|
||||
{
|
||||
pOutCachedItem->reset(new LocaleDataLookupTableItem( maLookupTable.back() ));
|
||||
OString sSymbolName = rtl::OStringView(pFunction) + "_" + (*pOutCachedItem)->localeName;
|
||||
OString sSymbolName = OString::Concat(pFunction) + "_" + (*pOutCachedItem)->localeName;
|
||||
return pTmpModule->getFunctionSymbol(sSymbolName.getStr());
|
||||
}
|
||||
else
|
||||
@ -1436,7 +1436,7 @@ oslGenericFunction LocaleDataImpl::getFunctionSymbol( const Locale& rLocale, con
|
||||
|
||||
if (cachedItem && cachedItem->equals(rLocale))
|
||||
{
|
||||
OString sSymbolName = rtl::OStringView(pFunction) + "_" +
|
||||
OString sSymbolName = OString::Concat(pFunction) + "_" +
|
||||
cachedItem->localeName;
|
||||
return cachedItem->module->getFunctionSymbol(sSymbolName.getStr());
|
||||
}
|
||||
|
@ -17,6 +17,9 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include <options.hxx>
|
||||
|
||||
@ -285,7 +288,7 @@ bool Options::initOptions(std::vector< std::string > & rArgs)
|
||||
{
|
||||
return badOption("invalid", option);
|
||||
}
|
||||
OString param = "-D" + rtl::OStringView((*first).c_str(), (*first).size());
|
||||
OString param = OString::Concat("-D") + std::string_view((*first).c_str(), (*first).size());
|
||||
if (m_options.count("-D") > 0)
|
||||
{
|
||||
param = m_options["-D"] + " " + param;
|
||||
|
@ -1035,13 +1035,6 @@ public:
|
||||
*pInternalCapacity = &nCapacity;
|
||||
}
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
explicit operator OStringView() const
|
||||
{
|
||||
return OStringView(getStr(), getLength());
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
/**
|
||||
A pointer to the data structure which contains the data.
|
||||
@ -1054,6 +1047,18 @@ private:
|
||||
sal_Int32 nCapacity;
|
||||
};
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
template<> struct ToStringHelper<OStringBuffer> {
|
||||
static std::size_t length(OStringBuffer const & s) { return s.getLength(); }
|
||||
|
||||
static char * addData(char * buffer, OStringBuffer const & s) SAL_RETURNS_NONNULL
|
||||
{ return addDataHelper(buffer, s.getStr(), s.getLength()); }
|
||||
|
||||
static constexpr bool allowOStringConcat = true;
|
||||
static constexpr bool allowOUStringConcat = false;
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef RTL_STRING_UNITTEST
|
||||
|
@ -1900,6 +1900,31 @@ public:
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
|
||||
#endif
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
// A wrapper for the first expression in an
|
||||
//
|
||||
// OString::Concat(e1) + e2 + ...
|
||||
//
|
||||
// concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
|
||||
// classes (so something like
|
||||
//
|
||||
// OString s = "a" + (b ? std::string_view("c" : "dd");
|
||||
//
|
||||
// would not compile):
|
||||
template<typename T> [[nodiscard]] static
|
||||
typename std::enable_if_t<
|
||||
ToStringHelper<T>::allowOStringConcat, OStringConcat<OStringConcatMarker, T>>
|
||||
Concat(T const & value) { return OStringConcat<OStringConcatMarker, T>({}, value); }
|
||||
|
||||
// This overload is needed so that an argument of type 'char const[N]' ends up as
|
||||
// 'OStringConcat<rtl::OStringConcatMarker, char const[N]>' rather than as
|
||||
// 'OStringConcat<rtl::OStringConcatMarker, char[N]>':
|
||||
template<typename T, std::size_t N> [[nodiscard]] static
|
||||
typename std::enable_if_t<
|
||||
ToStringHelper<T[N]>::allowOStringConcat, OStringConcat<OStringConcatMarker, T[N]>>
|
||||
Concat(T (& value)[N]) { return OStringConcat<OStringConcatMarker, T[N]>({}, value); }
|
||||
#endif
|
||||
};
|
||||
|
||||
/* ======================================================================= */
|
||||
|
@ -490,63 +490,52 @@ struct ToStringHelper< OUStringNumber< T > >
|
||||
static const bool allowOUStringConcat = true;
|
||||
};
|
||||
|
||||
// Abstractions over null-terminated char and sal_Unicode strings that sometimes are needed in
|
||||
// concatenations of multiple such raw strings, as in
|
||||
//
|
||||
// char const * s1, s2;
|
||||
// OString s = OStringView(s1) + s2;
|
||||
//
|
||||
// (Providing specializations of ToStringHelper<std::string_view> and
|
||||
// ToStringHelper<std::u16string_view> would look dubious, as it would give meaning to expressions
|
||||
// like
|
||||
//
|
||||
// std::string_view(s1) + s2
|
||||
//
|
||||
// that do not involve any user-defined types.)
|
||||
template<> struct ToStringHelper<std::string_view> {
|
||||
static constexpr std::size_t length(std::string_view s) { return s.size(); }
|
||||
|
||||
class OStringView {
|
||||
public:
|
||||
explicit OStringView(char const * s): view_(s) {}
|
||||
explicit OStringView(char const * s, size_t len): view_(s, len) {}
|
||||
static char * addData(char * buffer, std::string_view s) SAL_RETURNS_NONNULL
|
||||
{ return addDataHelper(buffer, s.data(), s.size()); }
|
||||
|
||||
std::size_t length() const { return view_.length(); }
|
||||
|
||||
char const * data() const { return view_.data(); }
|
||||
|
||||
private:
|
||||
std::string_view view_;
|
||||
static constexpr bool allowOStringConcat = true;
|
||||
static constexpr bool allowOUStringConcat = false;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ToStringHelper< OStringView >
|
||||
{
|
||||
static std::size_t length( const OStringView& v ) { return v.length(); }
|
||||
static char* addData( char* buffer, const OStringView& v ) SAL_RETURNS_NONNULL { return addDataHelper( buffer, v.data(), v.length() ); }
|
||||
static const bool allowOStringConcat = true;
|
||||
static const bool allowOUStringConcat = false;
|
||||
};
|
||||
template<> struct ToStringHelper<std::u16string_view> {
|
||||
static constexpr std::size_t length(std::u16string_view s) { return s.size(); }
|
||||
|
||||
class OUStringView {
|
||||
public:
|
||||
explicit OUStringView(sal_Unicode const * s): view_(s) {}
|
||||
explicit OUStringView(sal_Unicode const * s, size_t len): view_(s, len) {}
|
||||
static sal_Unicode * addData(sal_Unicode * buffer, std::u16string_view s) SAL_RETURNS_NONNULL
|
||||
{ return addDataHelper(buffer, s.data(), s.size()); }
|
||||
|
||||
std::size_t length() const { return view_.length(); }
|
||||
|
||||
sal_Unicode const * data() const { return view_.data(); }
|
||||
|
||||
private:
|
||||
std::u16string_view view_;
|
||||
static constexpr bool allowOStringConcat = false;
|
||||
static constexpr bool allowOUStringConcat = true;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ToStringHelper< OUStringView >
|
||||
{
|
||||
static std::size_t length( const OUStringView& v ) { return v.length(); }
|
||||
static sal_Unicode* addData( sal_Unicode* buffer, const OUStringView& v ) SAL_RETURNS_NONNULL { return addDataHelper( buffer, v.data(), v.length() ); }
|
||||
static const bool allowOStringConcat = false;
|
||||
static const bool allowOUStringConcat = true;
|
||||
};
|
||||
// An internal marker class used by OString::Concat:
|
||||
struct OStringConcatMarker {};
|
||||
|
||||
template<> struct ToStringHelper<OStringConcatMarker> {
|
||||
static constexpr std::size_t length(OStringConcatMarker) { return 0; }
|
||||
|
||||
static constexpr char * addData(char * buffer, OStringConcatMarker) SAL_RETURNS_NONNULL
|
||||
{ return buffer; }
|
||||
|
||||
static constexpr bool allowOStringConcat = true;
|
||||
static constexpr bool allowOUStringConcat = false;
|
||||
};
|
||||
|
||||
// An internal marker class used by OUString::Concat:
|
||||
struct OUStringConcatMarker {};
|
||||
|
||||
template<> struct ToStringHelper<OUStringConcatMarker> {
|
||||
static constexpr std::size_t length(OUStringConcatMarker) { return 0; }
|
||||
|
||||
static constexpr sal_Unicode * addData(sal_Unicode * buffer, OUStringConcatMarker)
|
||||
SAL_RETURNS_NONNULL
|
||||
{ return buffer; }
|
||||
|
||||
static constexpr bool allowOStringConcat = false;
|
||||
static constexpr bool allowOUStringConcat = true;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -1643,13 +1643,6 @@ public:
|
||||
return OUStringBuffer( pNew, count + 16 );
|
||||
}
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
explicit operator OUStringView() const
|
||||
{
|
||||
return OUStringView(getStr(), getLength());
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
|
||||
{
|
||||
@ -1668,6 +1661,18 @@ private:
|
||||
sal_Int32 nCapacity;
|
||||
};
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
template<> struct ToStringHelper<OUStringBuffer> {
|
||||
static std::size_t length(OUStringBuffer const & s) { return s.getLength(); }
|
||||
|
||||
static sal_Unicode * addData(sal_Unicode * buffer, OUStringBuffer const & s) SAL_RETURNS_NONNULL
|
||||
{ return addDataHelper(buffer, s.getStr(), s.getLength()); }
|
||||
|
||||
static constexpr bool allowOStringConcat = false;
|
||||
static constexpr bool allowOUStringConcat = true;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
// Define this here to avoid circular includes
|
||||
inline OUString & OUString::operator+=( const OUStringBuffer & str ) &
|
||||
|
@ -3693,6 +3693,31 @@ public:
|
||||
operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
|
||||
#endif
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
// A wrapper for the first expression in an
|
||||
//
|
||||
// OUString::Concat(e1) + e2 + ...
|
||||
//
|
||||
// concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
|
||||
// classes (so something like
|
||||
//
|
||||
// OUString s = "a" + (b ? std::u16string_view(u"c" : u"dd");
|
||||
//
|
||||
// would not compile):
|
||||
template<typename T> [[nodiscard]] static
|
||||
typename std::enable_if_t<
|
||||
ToStringHelper<T>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T>>
|
||||
Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>({}, value); }
|
||||
|
||||
// This overload is needed so that an argument of type 'char const[N]' ends up as
|
||||
// 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
|
||||
// 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
|
||||
template<typename T, std::size_t N> [[nodiscard]] static
|
||||
typename std::enable_if_t<
|
||||
ToStringHelper<T[N]>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T[N]>>
|
||||
Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
OUString & internalAppend( rtl_uString* pOtherData )
|
||||
{
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include <oox/core/relationshandler.hxx>
|
||||
|
||||
#include <sal/log.hxx>
|
||||
@ -41,9 +43,9 @@ namespace {
|
||||
OUString lclGetRelationsPath( const OUString& rFragmentPath )
|
||||
{
|
||||
sal_Int32 nPathLen = ::std::max< sal_Int32 >( rFragmentPath.lastIndexOf( '/' ) + 1, 0 );
|
||||
return rtl::OUStringView(rFragmentPath.getStr(), nPathLen ) + // file path including slash
|
||||
return OUString::Concat(std::u16string_view(rFragmentPath.getStr(), nPathLen )) + // file path including slash
|
||||
"_rels/" + // additional '_rels/' path
|
||||
rtl::OUStringView(rFragmentPath.getStr() + nPathLen) + // file name after path
|
||||
std::u16string_view(rFragmentPath.getStr() + nPathLen) + // file name after path
|
||||
".rels"; // '.rels' suffix
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ OString createFileName(cl_device_id deviceId, const char* clFileName)
|
||||
platformVersion, nullptr);
|
||||
|
||||
// create hash for deviceName + driver version + platform version
|
||||
OString aString = rtl::OStringView(deviceName) + driverVersion + platformVersion;
|
||||
OString aString = OString::Concat(deviceName) + driverVersion + platformVersion;
|
||||
OString aHash = generateMD5(aString.getStr(), aString.getLength());
|
||||
|
||||
return getCacheFolder() + fileName + "-" + aHash + ".bin";
|
||||
|
@ -65,6 +65,8 @@ void test::ostring::StringConcat::checkConcat()
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, const char[ 4 ] > )), typeid( OString( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), OString( OString( "foo" ) + "bar" + "baz" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringConcat< OString, const char[ 4 ] >, const char[ 4 ] > )), typeid( OString( "foo" ) + "bar" + "baz" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringBuffer( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringBuffer, const char[ 4 ] > )), typeid( OStringBuffer( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringLiteral( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringLiteral, const char[ 4 ] > )), typeid( OStringLiteral( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringLiteral( "foo" ) + static_cast<const char*>("bar") ));
|
||||
@ -83,8 +85,16 @@ void test::ostring::StringConcat::checkConcat()
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, char* > )), typeid( OString( "foo" ) + d4 ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "fooabc" ), OString( OString( "foo" ) + d4 ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, char* > )), typeid( OString( "foo" ) + d4 ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "fooabc" ), OString( rtl::OStringView( "foo" ) + d4 ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< rtl::OStringView, char* > )), typeid( rtl::OStringView( "foo" ) + d4 ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OString::Concat( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringConcat< OStringConcatMarker, const char[ 4 ] >, const char[ 4 ] > )), typeid( OString::Concat( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "xyzbar" ), OString( OString::Concat( d1 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringConcat< OStringConcatMarker, const char[ 4 ] >, const char[ 4 ] > )), typeid( OString::Concat( d1 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "abcbar" ), OString( OString::Concat( d2 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringConcat< OStringConcatMarker, char[ 4 ] >, const char[ 4 ] > )), typeid( OString::Concat( d2 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "xyzbar" ), OString( OString::Concat( d3 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringConcat< OStringConcatMarker, const char* >, const char[ 4 ] > )), typeid( OString::Concat( d3 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "abcbar" ), OString( OString::Concat( d4 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OStringConcat< OStringConcatMarker, char* >, const char[ 4 ] > )), typeid( OString::Concat( d4 ) + "bar" ));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( OString( "num10" ), OString( OString( "num" ) + OString::number( 10 )));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OStringConcat< OString, OStringNumber< int > > )), typeid( OString( "num" ) + OString::number( 10 )));
|
||||
@ -155,11 +165,10 @@ void test::ostring::StringConcat::checkAppend()
|
||||
void test::ostring::StringConcat::checkInvalid()
|
||||
{
|
||||
CPPUNIT_ASSERT( !INVALID_CONCAT( OString() + OString()));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OStringBuffer( "b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUString( "b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUStringBuffer( "b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUStringLiteral( u"b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + rtl::OUStringView( u"b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUString::Concat( u"b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + 1 ));
|
||||
rtl_String* rs = nullptr;
|
||||
rtl_uString* rus = nullptr;
|
||||
|
@ -66,6 +66,8 @@ void test::oustring::StringConcat::checkConcat()
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), OUString( OUString( "foo" ) + "bar" + "baz" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< OUString, const char[ 4 ] >, const char[ 4 ] > )), typeid( OUString( "foo" ) + "bar" + "baz" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringBuffer( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringBuffer, const char[ 4 ] > )), typeid( OUStringBuffer( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringLiteral( u"foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringLiteral, const char[ 4 ] > )), typeid( OUStringLiteral( u"foo" ) + "bar" ));
|
||||
const char d1[] = "xyz";
|
||||
@ -74,8 +76,17 @@ void test::oustring::StringConcat::checkConcat()
|
||||
const sal_Unicode* d2 = u"xyz";
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( OUString( "foo" ) + d2 ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const sal_Unicode* > )), typeid( OUString( "foo" ) + d2 ));
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( rtl::OUStringView( u"foo" ) + d2 ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< rtl::OUStringView, const sal_Unicode* > )), typeid( rtl::OUStringView( u"foo" ) + d2 ));
|
||||
const sal_Unicode d3[] = u"xyz";
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString::Concat( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const char[ 4 ] >, const char[ 4 ] > )), typeid( OUString::Concat( "foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "xyzbar" ), OUString( OUString::Concat( d1 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const char[ 4 ] >, const char[ 4 ] > )), typeid( OUString::Concat( d1 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString::Concat( u"foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const sal_Unicode[ 4 ] >, const char[ 4 ] > )), typeid( OUString::Concat( u"foo" ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "xyzbar" ), OUString( OUString::Concat( d2 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const sal_Unicode* >, const char[ 4 ] > )), typeid( OUString::Concat( d2 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "xyzbar" ), OUString( OUString::Concat( d3 ) + "bar" ));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringConcat< rtl::OUStringConcatMarker, const sal_Unicode[ 4 ] >, const char[ 4 ] > )), typeid( OUString::Concat( d3 ) + "bar" ));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( OUString( "num10" ), OUString( OUString( "num" ) + OUString::number( 10 )));
|
||||
CPPUNIT_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUStringNumber< int > > )), typeid( OUString( "num" ) + OUString::number( 10 )));
|
||||
@ -164,7 +175,6 @@ void test::oustring::StringConcat::checkAppend()
|
||||
void test::oustring::StringConcat::checkInvalid()
|
||||
{
|
||||
CPPUNIT_ASSERT( !INVALID_CONCAT( OUString() + OUString()));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OUStringBuffer( "b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OString( "b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OStringBuffer( "b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + static_cast<const char*>("b") ));
|
||||
@ -172,7 +182,7 @@ void test::oustring::StringConcat::checkInvalid()
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + d ));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + static_cast<char*>(d) ));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OStringLiteral( "b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + rtl::OStringView( "b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OString::Concat( "b" )));
|
||||
CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + 1 ));
|
||||
rtl_String* rs = nullptr;
|
||||
rtl_uString* rus = nullptr;
|
||||
|
@ -163,7 +163,7 @@ void SaxEmitter::endTag( const char* pTag )
|
||||
for( int i = 0; i < nIndent; i++ )
|
||||
pStream->write( " ", 4, nWritten );
|
||||
|
||||
OString aBuf = "</" + rtl::OStringView(pTag) + ">\n";
|
||||
OString aBuf = OString::Concat("</") + pTag + ">\n";
|
||||
pStream->write( aBuf.getStr(), aBuf.getLength(), nWritten );
|
||||
nIndent--;
|
||||
#endif
|
||||
|
@ -242,7 +242,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert
|
||||
for ( nSub=0; nSub<nSubCount; nSub++ )
|
||||
{
|
||||
// search sub item by name
|
||||
OString aStr = rtl::OStringView(pSlot->pUnoName) + "." + pType->aAttrib[nSub].pName;
|
||||
OString aStr = OString::Concat(pSlot->pUnoName) + "." + pType->aAttrib[nSub].pName;
|
||||
if ( rPropValue.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
|
||||
{
|
||||
sal_uInt8 nSubId = static_cast<sal_uInt8>(static_cast<sal_Int8>(pType->aAttrib[nSub].nAID));
|
||||
@ -345,7 +345,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert
|
||||
for ( sal_uInt16 nSub=0; nSub<nSubCount; nSub++ )
|
||||
{
|
||||
// search sub item by name
|
||||
OString aStr = rtl::OStringView(rArg.pName) + "." + pType->aAttrib[nSub].pName;
|
||||
OString aStr = OString::Concat(rArg.pName) + "." + pType->aAttrib[nSub].pName;
|
||||
if ( rProp.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
|
||||
{
|
||||
// at least one member found ...
|
||||
|
@ -284,7 +284,7 @@ void SAL_CALL UrlReference::setName(OUString const & name)
|
||||
|
||||
auto tmp = std::u16string_view(m_base.m_path).substr(i);
|
||||
m_base.m_path = encodeNameOrParamFragment(name) +
|
||||
rtl::OUStringView(tmp.data(), tmp.length());
|
||||
std::u16string_view(tmp.data(), tmp.length());
|
||||
}
|
||||
|
||||
sal_Bool UrlReference::hasParameter(OUString const & key)
|
||||
|
@ -923,7 +923,7 @@ SvStream& HTMLOutFuncs::Out_Events( SvStream& rStrm,
|
||||
|
||||
if( pStr )
|
||||
{
|
||||
OString sOut = " " + rtl::OStringView(pStr) + "=\"";
|
||||
OString sOut = OString::Concat(" ") + pStr + "=\"";
|
||||
rStrm.WriteOString( sOut );
|
||||
|
||||
Out_String( rStrm, pMacro->GetMacName(), eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
|
||||
|
@ -505,7 +505,7 @@ static void lcl_html_outFootEndNoteInfo( Writer& rWrt, OUString const *pParts,
|
||||
rHTMLWrt.OutNewLine();
|
||||
OString sOut =
|
||||
"<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_meta " "
|
||||
OOO_STRING_SVTOOLS_HTML_O_name "=\"" + rtl::OStringView(pName) +
|
||||
OOO_STRING_SVTOOLS_HTML_O_name "=\"" + pName +
|
||||
"\" " OOO_STRING_SVTOOLS_HTML_O_content "=\"";
|
||||
rWrt.Strm().WriteOString( sOut );
|
||||
HTMLOutFuncs::Out_String( rWrt.Strm(), aContent.makeStringAndClear(), rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -4198,8 +4199,8 @@ bool INetURLObject::removeExtension(sal_Int32 nIndex, bool bIgnoreFinalSlash)
|
||||
return true;
|
||||
|
||||
OUString aNewPath =
|
||||
rtl::OUStringView(pPathBegin, pExtension - pPathBegin) +
|
||||
rtl::OUStringView(p, pPathEnd - p);
|
||||
OUString::Concat(std::u16string_view(pPathBegin, pExtension - pPathBegin)) +
|
||||
std::u16string_view(p, pPathEnd - p);
|
||||
|
||||
return setPath(aNewPath, EncodeMechanism::NotCanonical, RTL_TEXTENCODING_UTF8);
|
||||
}
|
||||
@ -4226,7 +4227,8 @@ bool INetURLObject::setFinalSlash()
|
||||
if (pPathEnd > pPathBegin && pPathEnd[-1] == '/')
|
||||
return true;
|
||||
|
||||
OUString aNewPath = rtl::OUStringView(pPathBegin, pPathEnd - pPathBegin) + "/";
|
||||
OUString aNewPath
|
||||
= OUString::Concat(std::u16string_view(pPathBegin, pPathEnd - pPathBegin)) + "/";
|
||||
|
||||
return setPath(aNewPath, EncodeMechanism::NotCanonical, RTL_TEXTENCODING_UTF8);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * in
|
||||
setRequestHeaders( hdrs_bkt );
|
||||
|
||||
// 'If' header with token, so that we can save document locked by us
|
||||
const OString sIfHeader( "<" + rtl::OStringView(getPathStr()) + "> (<" + OUStringToOString(
|
||||
const OString sIfHeader( OString::Concat("<") + getPathStr() + "> (<" + OUStringToOString(
|
||||
msToken, RTL_TEXTENCODING_UTF8) + ">)" );
|
||||
serf_bucket_headers_set( hdrs_bkt, "If", sIfHeader.getStr() );
|
||||
|
||||
|
@ -1571,7 +1571,7 @@ void PDFWriterImpl::appendLiteralStringEncrypt( const OUString& rInString, const
|
||||
|
||||
void PDFWriterImpl::emitComment( const char* pComment )
|
||||
{
|
||||
OString aLine = "% " + rtl::OStringView(pComment) + "\n";
|
||||
OString aLine = OString::Concat("% ") + pComment + "\n";
|
||||
writeBuffer( aLine.getStr(), aLine.getLength() );
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ namespace
|
||||
OUStringToOString(aInfo.GetDriverVersion(), RTL_TEXTENCODING_UTF8) +
|
||||
OString::number(DriverBlocklist::GetWindowsVersion());
|
||||
#else
|
||||
return rtl::OStringView(reinterpret_cast<const char*>(glGetString(GL_VENDOR))) +
|
||||
return OString::Concat(reinterpret_cast<const char*>(glGetString(GL_VENDOR))) +
|
||||
reinterpret_cast<const char*>(glGetString(GL_RENDERER)) +
|
||||
reinterpret_cast<const char*>(glGetString(GL_VERSION));
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user