LibreOffice Module comphelper (master) 1
|
Namespaces | |
namespace | detail |
Classes | |
class | NaturalStringSorter |
Functions | |
OString | stripStart (const OString &rIn, char c) |
Strips occurrences of a character from the start of the source string. More... | |
std::string_view | stripStart (std::string_view rIn, char c) |
OUString | stripStart (const OUString &rIn, sal_Unicode c) |
Strips occurrences of a character from the start of the source string. More... | |
std::u16string_view | stripStart (std::u16string_view rIn, sal_Unicode c) |
OString | stripEnd (const OString &rIn, char c) |
Strips occurrences of a character from the end of the source string. More... | |
std::string_view | stripEnd (std::string_view rIn, char c) |
OUString | stripEnd (const OUString &rIn, sal_Unicode c) |
Strips occurrences of a character from the end of the source string. More... | |
std::u16string_view | stripEnd (std::u16string_view rIn, sal_Unicode c) |
OString | strip (const OString &rIn, char c) |
Strips occurrences of a character from the start and end of the source string. More... | |
std::string_view | strip (std::string_view rIn, char c) |
OUString | strip (const OUString &rIn, sal_Unicode c) |
Strips occurrences of a character from the start and end of the source string. More... | |
std::u16string_view | strip (std::u16string_view rIn, sal_Unicode c) |
sal_Int32 | getTokenCount (std::string_view rIn, char cTok) |
Returns number of tokens in an OUString. More... | |
sal_Int32 | getTokenCount (std::u16string_view rIn, sal_Unicode cTok) |
Returns number of tokens in an OUString. More... | |
sal_uInt32 | decimalStringToNumber (std::u16string_view str) |
Convert a decimal string to a number. More... | |
OUString | convertCommaSeparated (uno::Sequence< OUString > const &i_rSeq) |
std::vector< OUString > | split (std::u16string_view rStr, sal_Unicode cSeparator) |
uno::Sequence< OUString > | convertCommaSeparated (std::u16string_view i_rString) |
Convert a single comma separated string to a sequence of strings. More... | |
OString | join (std::string_view rSeparator, const std::vector< OString > &rSequence) |
Return a string which is the concatenation of the strings in the sequence. More... | |
sal_Int32 | compareNatural (const OUString &rLHS, const OUString &rRHS, const uno::Reference< i18n::XCollator > &rCollator, const uno::Reference< i18n::XBreakIterator > &rBI, const lang::Locale &rLocale) |
bool | isdigitAsciiString (std::string_view rString) |
Determine if an OString contains solely ASCII numeric digits. More... | |
bool | isdigitAsciiString (std::u16string_view rString) |
Determine if an OUString contains solely ASCII numeric digits. More... | |
OUString | reverseString (std::u16string_view rStr) |
Reverse an OUString's UTF-16 code units. More... | |
OUString | reverseCodePoints (OUString const &str) |
Reverse an OUString's Unicode code points. More... | |
sal_Int32 | indexOfAny (std::u16string_view rIn, sal_Unicode const *const pChars, sal_Int32 const nPos) |
Find any of a list of code units in the string. More... | |
OUString | removeAny (std::u16string_view rIn, sal_Unicode const *const pChars) |
Remove any of a list of code units in the string. More... | |
OUString | setToken (const OUString &rIn, sal_Int32 nToken, sal_Unicode cTok, std::u16string_view rNewToken) |
Replace a token in a string. More... | |
void | replaceAt (OUStringBuffer &rIn, sal_Int32 nIndex, sal_Int32 nCount, std::u16string_view newStr) |
Similar to OUString::replaceAt, but for an OUStringBuffer. More... | |
OUString | sanitizeStringSurrogates (const OUString &rString) |
Sanitize an OUString to not have invalid surrogates. More... | |
OUStringBuffer & | remove (OUStringBuffer &rIn, sal_Unicode c) |
Removes all occurrences of a character from within the source string. More... | |
OUStringBuffer & | truncateToLength (OUStringBuffer &rBuffer, sal_Int32 nLength) |
Truncate a buffer to a given length. More... | |
OStringBuffer & | padToLength (OStringBuffer &rBuffer, sal_Int32 nLength, char cFill='\0') |
Pad a buffer to a given length using a given char. More... | |
OUStringBuffer & | padToLength (OUStringBuffer &rBuffer, sal_Int32 nLength, sal_Unicode cFill='\0') |
COMPHELPER_DLLPUBLIC OUString | convertCommaSeparated (css::uno::Sequence< OUString > const &i_rSeq) |
Convert a sequence of strings to a single comma separated string. More... | |
COMPHELPER_DLLPUBLIC sal_Int32 | compareNatural (const OUString &rLHS, const OUString &rRHS, const css::uno::Reference< css::i18n::XCollator > &rCollator, const css::uno::Reference< css::i18n::XBreakIterator > &rBI, const css::lang::Locale &rLocale) |
Compares two strings using natural order. More... | |
OUString | encodeForXml (std::u16string_view rStr) |
COMPHELPER_DLLPUBLIC sal_Int32 comphelper::string::compareNatural | ( | const OUString & | rLHS, |
const OUString & | rRHS, | ||
const css::uno::Reference< css::i18n::XCollator > & | rCollator, | ||
const css::uno::Reference< css::i18n::XBreakIterator > & | rBI, | ||
const css::lang::Locale & | rLocale | ||
) |
Compares two strings using natural order.
For non digit characters, the comparison use the same algorithm as rtl_str_compare. When a number is encountered during the comparison, natural order is used. Thus, Heading 10 will be considered as greater than Heading 2. Numerical comparison is done using decimal representation.
Beware that "MyString 001" and "MyString 1" will be considered as equal since leading 0 are meaningless.
str | the object to be compared. |
sal_Int32 comphelper::string::compareNatural | ( | const OUString & | rLHS, |
const OUString & | rRHS, | ||
const uno::Reference< i18n::XCollator > & | rCollator, | ||
const uno::Reference< i18n::XBreakIterator > & | rBI, | ||
const lang::Locale & | rLocale | ||
) |
Definition at line 413 of file string.cxx.
References decimalStringToNumber().
Referenced by comphelper::string::NaturalStringSorter::compare().
COMPHELPER_DLLPUBLIC OUString comphelper::string::convertCommaSeparated | ( | css::uno::Sequence< OUString > const & | i_rSeq | ) |
Convert a sequence of strings to a single comma separated string.
Note that no escaping of commas or anything fancy is done.
i_rSeq | A list of strings to be concatenated. |
COMPHELPER_DLLPUBLIC css::uno::Sequence< OUString > comphelper::string::convertCommaSeparated | ( | std::u16string_view | i_rString | ) |
Convert a single comma separated string to a sequence of strings.
Note that no escaping of commas or anything fancy is done.
i_rString | A string containing comma-separated words. |
Definition at line 395 of file string.cxx.
References comphelper::containerToSequence(), and split().
OUString comphelper::string::convertCommaSeparated | ( | uno::Sequence< OUString > const & | i_rSeq | ) |
Definition at line 366 of file string.cxx.
References comphelper::intersperse().
COMPHELPER_DLLPUBLIC sal_uInt32 comphelper::string::decimalStringToNumber | ( | std::u16string_view | str | ) |
Convert a decimal string to a number.
The string must be base-10, no sign but can contain any codepoint listed in the "Number, Decimal Digit" Unicode category.
No verification is made about the validity of the string, passing string not containing decimal digit code points gives unspecified results
If your string is guaranteed to contain only ASCII digit use OUString::toInt32 instead.
str | The string to convert containing only decimal digit codepoints. |
Definition at line 266 of file string.cxx.
References i, o3tl::iterateCodePoints(), result, and value.
Referenced by compareNatural().
|
inline |
Definition at line 26 of file xmlencode.hxx.
References pos.
COMPHELPER_DLLPUBLIC sal_Int32 comphelper::string::getTokenCount | ( | std::string_view | rIn, |
char | cTok | ||
) |
Returns number of tokens in an OUString.
rIn | the input OString |
cTok | the character which separate the tokens. |
Definition at line 256 of file string.cxx.
COMPHELPER_DLLPUBLIC sal_Int32 comphelper::string::getTokenCount | ( | std::u16string_view | rIn, |
sal_Unicode | cTok | ||
) |
Returns number of tokens in an OUString.
rIn | the input OUString |
cTok | the character which separate the tokens. |
Definition at line 261 of file string.cxx.
COMPHELPER_DLLPUBLIC sal_Int32 comphelper::string::indexOfAny | ( | std::u16string_view | rIn, |
sal_Unicode const *const | pChars, | ||
sal_Int32 const | nPos | ||
) |
Find any of a list of code units in the string.
rIn | OUString to search |
pChars | 0-terminated array of sal_Unicode code units to search for |
nPos | start position |
Definition at line 537 of file string.cxx.
COMPHELPER_DLLPUBLIC bool comphelper::string::isdigitAsciiString | ( | std::string_view | rString | ) |
Determine if an OString contains solely ASCII numeric digits.
rString | An OString |
Definition at line 502 of file string.cxx.
COMPHELPER_DLLPUBLIC bool comphelper::string::isdigitAsciiString | ( | std::u16string_view | rString | ) |
Determine if an OUString contains solely ASCII numeric digits.
rString | An OUString |
Definition at line 509 of file string.cxx.
COMPHELPER_DLLPUBLIC OString comphelper::string::join | ( | std::string_view | rSeparator, |
const std::vector< OString > & | rSequence | ||
) |
Return a string which is the concatenation of the strings in the sequence.
Definition at line 401 of file string.cxx.
|
inline |
Pad a buffer to a given length using a given char.
If the StringBuffer has less characters than nLength it will be expanded on the right to nLength characters, with the expansion filled using cFill.
Has no effect if the StringBuffer is >= nLength
rBuf | StringBuffer to operate on |
nLength | Length to pad the buffer to |
cFill | character to fill expansion with |
Definition at line 217 of file string.hxx.
References nLength, and comphelper::string::detail::padToLength().
|
inline |
Definition at line 224 of file string.hxx.
References nLength, and comphelper::string::detail::padToLength().
|
inline |
Removes all occurrences of a character from within the source string.
rIn | The input OUStringBuffer |
c | The character to be removed |
Definition at line 49 of file string.hxx.
References index.
Referenced by comphelper::DirectoryHelper::deleteDirRecursively(), comphelper::DirectoryHelper::moveDirContent(), comphelper::BackupFileHelper::reactOnSafeMode(), comphelper::BackupFileHelper::tryDisableHWAcceleration(), comphelper::BackupFileHelper::tryPop(), comphelper::BackupFileHelper::tryPop_extensionInfo(), comphelper::BackupFileHelper::tryPop_file(), comphelper::BackupFileHelper::tryPop_files(), comphelper::BackupFileHelper::tryPopExtensionInfo(), comphelper::BackupFileHelper::tryPush_extensionInfo(), comphelper::BackupFileHelper::tryPush_Files(), and comphelper::BackupFileHelper::tryResetCustomizations().
COMPHELPER_DLLPUBLIC OUString comphelper::string::removeAny | ( | std::u16string_view | rIn, |
sal_Unicode const *const | pChars | ||
) |
Remove any of a list of code units in the string.
rIn | OUString to search |
pChars | 0-terminated array of sal_Unicode code units to search for |
Definition at line 554 of file string.cxx.
COMPHELPER_DLLPUBLIC void comphelper::string::replaceAt | ( | OUStringBuffer & | rIn, |
sal_Int32 | nIndex, | ||
sal_Int32 | nCount, | ||
std::u16string_view | newStr | ||
) |
Similar to OUString::replaceAt, but for an OUStringBuffer.
Replace n = count characters from position index in this string with newStr.
Definition at line 625 of file string.cxx.
References o3tl::make_unsigned(), nCount, and nIndex.
COMPHELPER_DLLPUBLIC OUString comphelper::string::reverseCodePoints | ( | OUString const & | str | ) |
COMPHELPER_DLLPUBLIC OUString comphelper::string::reverseString | ( | std::u16string_view | rStr | ) |
Reverse an OUString's UTF-16 code units.
rIn | the input OUString |
Definition at line 516 of file string.cxx.
References i.
COMPHELPER_DLLPUBLIC OUString comphelper::string::sanitizeStringSurrogates | ( | const OUString & | rString | ) |
Sanitize an OUString to not have invalid surrogates.
rString | An OUString |
Definition at line 650 of file string.cxx.
COMPHELPER_DLLPUBLIC OUString comphelper::string::setToken | ( | const OUString & | rIn, |
sal_Int32 | nToken, | ||
sal_Unicode | cTok, | ||
std::u16string_view | rNewToken | ||
) |
Replace a token in a string.
rIn | OUString in which the token is to be replaced |
nToken | which nToken to replace |
cTok | token delimiter |
rNewToken | replacement token |
Definition at line 590 of file string.cxx.
COMPHELPER_DLLPUBLIC std::vector< OUString > comphelper::string::split | ( | std::u16string_view | rStr, |
sal_Unicode | cSeparator | ||
) |
Definition at line 376 of file string.cxx.
References o3tl::getToken(), idx, and o3tl::trim().
Referenced by convertCommaSeparated().
COMPHELPER_DLLPUBLIC OString comphelper::string::strip | ( | const OString & | rIn, |
char | c | ||
) |
Strips occurrences of a character from the start and end of the source string.
rIn | The input OString |
c | The character to be stripped from the start and end |
Definition at line 217 of file string.cxx.
COMPHELPER_DLLPUBLIC OUString comphelper::string::strip | ( | const OUString & | rIn, |
sal_Unicode | c | ||
) |
Strips occurrences of a character from the start and end of the source string.
rIn | The input OUString |
c | The character to be stripped from the start and end |
Definition at line 227 of file string.cxx.
COMPHELPER_DLLPUBLIC std::string_view comphelper::string::strip | ( | std::string_view | rIn, |
char | c | ||
) |
Definition at line 222 of file string.cxx.
COMPHELPER_DLLPUBLIC std::u16string_view comphelper::string::strip | ( | std::u16string_view | rIn, |
sal_Unicode | c | ||
) |
Definition at line 232 of file string.cxx.
COMPHELPER_DLLPUBLIC OString comphelper::string::stripEnd | ( | const OString & | rIn, |
char | c | ||
) |
Strips occurrences of a character from the end of the source string.
rIn | The input OString |
c | The character to be stripped from the end |
Definition at line 146 of file string.cxx.
COMPHELPER_DLLPUBLIC OUString comphelper::string::stripEnd | ( | const OUString & | rIn, |
sal_Unicode | c | ||
) |
Strips occurrences of a character from the end of the source string.
rIn | The input OUString |
c | The character to be stripped from the end |
Definition at line 156 of file string.cxx.
COMPHELPER_DLLPUBLIC std::string_view comphelper::string::stripEnd | ( | std::string_view | rIn, |
char | c | ||
) |
Definition at line 151 of file string.cxx.
COMPHELPER_DLLPUBLIC std::u16string_view comphelper::string::stripEnd | ( | std::u16string_view | rIn, |
sal_Unicode | c | ||
) |
Definition at line 161 of file string.cxx.
COMPHELPER_DLLPUBLIC OString comphelper::string::stripStart | ( | const OString & | rIn, |
char | c | ||
) |
Strips occurrences of a character from the start of the source string.
rIn | The input OString |
c | The character to be stripped from the start |
Definition at line 88 of file string.cxx.
COMPHELPER_DLLPUBLIC OUString comphelper::string::stripStart | ( | const OUString & | rIn, |
sal_Unicode | c | ||
) |
Strips occurrences of a character from the start of the source string.
rIn | The input OUString |
c | The character to be stripped from the start |
Definition at line 98 of file string.cxx.
COMPHELPER_DLLPUBLIC std::string_view comphelper::string::stripStart | ( | std::string_view | rIn, |
char | c | ||
) |
Definition at line 93 of file string.cxx.
COMPHELPER_DLLPUBLIC std::u16string_view comphelper::string::stripStart | ( | std::u16string_view | rIn, |
sal_Unicode | c | ||
) |
Definition at line 103 of file string.cxx.
|
inline |
Truncate a buffer to a given length.
If the StringBuffer has more characters than nLength it will be truncated on the right to nLength characters.
Has no effect if the StringBuffer is <= nLength
rBuf | StringBuffer to operate on |
nLength | Length to truncate the buffer to |
Definition at line 187 of file string.hxx.
References nLength, and comphelper::string::detail::truncateToLength().