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... | |
static sal_uInt32 | decimalStringToNumber (OUString const &str, sal_Int32 nStart, sal_Int32 nLength) |
sal_uInt32 | decimalStringToNumber (OUString const &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. More... | |
OString | reverseString (std::string_view rStr) |
Reverse an OString. 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... | |
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... | |
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 418 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 400 of file string.cxx.
References comphelper::containerToSequence(), and split().
OUString comphelper::string::convertCommaSeparated | ( | uno::Sequence< OUString > const & | i_rSeq | ) |
Definition at line 371 of file string.cxx.
References comphelper::intersperse().
COMPHELPER_DLLPUBLIC sal_uInt32 comphelper::string::decimalStringToNumber | ( | OUString const & | 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 361 of file string.cxx.
References decimalStringToNumber().
|
static |
Definition at line 264 of file string.cxx.
References i, nLength, result, and value.
Referenced by compareNatural(), and decimalStringToNumber().
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 254 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 259 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 546 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 507 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 514 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 406 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 220 of file string.hxx.
References nLength, and comphelper::string::detail::padToLength().
|
inline |
Definition at line 227 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 563 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 634 of file string.cxx.
References o3tl::make_unsigned(), nCount, and nIndex.
COMPHELPER_DLLPUBLIC OString comphelper::string::reverseString | ( | std::string_view | rStr | ) |
Reverse an OString.
rIn | the input OString |
Definition at line 541 of file string.cxx.
COMPHELPER_DLLPUBLIC OUString comphelper::string::reverseString | ( | std::u16string_view | rStr | ) |
Reverse an OUString.
rIn | the input OUString |
Definition at line 536 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 599 of file string.cxx.
COMPHELPER_DLLPUBLIC std::vector< OUString > comphelper::string::split | ( | std::u16string_view | rStr, |
sal_Unicode | cSeparator | ||
) |
Definition at line 381 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 215 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 225 of file string.cxx.
COMPHELPER_DLLPUBLIC std::string_view comphelper::string::strip | ( | std::string_view | rIn, |
char | c | ||
) |
Definition at line 220 of file string.cxx.
COMPHELPER_DLLPUBLIC std::u16string_view comphelper::string::strip | ( | std::u16string_view | rIn, |
sal_Unicode | c | ||
) |
Definition at line 230 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 144 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 154 of file string.cxx.
COMPHELPER_DLLPUBLIC std::string_view comphelper::string::stripEnd | ( | std::string_view | rIn, |
char | c | ||
) |
Definition at line 149 of file string.cxx.
COMPHELPER_DLLPUBLIC std::u16string_view comphelper::string::stripEnd | ( | std::u16string_view | rIn, |
sal_Unicode | c | ||
) |
Definition at line 159 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 86 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 96 of file string.cxx.
COMPHELPER_DLLPUBLIC std::string_view comphelper::string::stripStart | ( | std::string_view | rIn, |
char | c | ||
) |
Definition at line 91 of file string.cxx.
COMPHELPER_DLLPUBLIC std::u16string_view comphelper::string::stripStart | ( | std::u16string_view | rIn, |
sal_Unicode | c | ||
) |
Definition at line 101 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 190 of file string.hxx.
References nLength, and comphelper::string::detail::truncateToLength().