diff options
Diffstat (limited to 'include/rtl/string.h')
-rw-r--r-- | include/rtl/string.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/include/rtl/string.h b/include/rtl/string.h index bfbb45057fd9..c0f724245d9e 100644 --- a/include/rtl/string.h +++ b/include/rtl/string.h @@ -747,6 +747,31 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_str_toBoolean( SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32( const char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C(); +/** Interpret a string as an integer. + + This function cannot be used for language-specific conversion. The string + must be null-terminated. + + @param str + a null-terminated string. + + @param radix + the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX + (36), inclusive. + + @param len + the length of the character array. + + @return + the integer value represented by the string, or 0 if the string does not + represent an integer. + + @since LibreOffice 7.2 + @internal + */ +SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32_WithLength( + const char * str, sal_Int16 radix, sal_Int32 nStrLength ) SAL_THROW_EXTERN_C(); + /** Interpret a string as an unsigned integer. This function cannot be used for language-specific conversion. The string @@ -1309,6 +1334,59 @@ SAL_DLLPUBLIC void SAL_CALL rtl_string_newTrim( SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getToken( rtl_String ** newStr , rtl_String * str, sal_Int32 token, char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C(); +/** Create a new string by extracting a single token from another string. + + Starting at index, the token's next token is searched for. If there is no + such token, the result is an empty string. Otherwise, all characters from + the start of that token and up to, but not including the next occurrence + of cTok make up the resulting token. The return value is the position of + the next token, or -1 if no more tokens follow. + + Example code could look like + rtl_String * pToken = NULL; + sal_Int32 nIndex = 0; + do + { + ... + nIndex = rtl_string_getToken(&pToken, pStr, 0, ';', nIndex); + ... + } + while (nIndex >= 0); + + The new string does not necessarily have a reference count of 1, so it + must not be modified without checking the reference count. This function + does not handle out-of-memory conditions. + + @param ppViewStr + pointer to the start of the token. The pointed-to data must be null or a valid + string. If either token or index is negative, nullptr is stored in + newStr (and -1 is returned). + + @param pViewLength + length of the token. + + @param str + a valid string. + + @param token + the number of the token to return, starting at index. + + @param cTok + the character that separates the tokens. + + @param idx + the position at which searching for the token starts. Must not be greater + than the length of str. + + @return + the index of the next token, or -1 if no more tokens follow. + + @since LibreOffice 7.2 + @internal + */ +SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getTokenView( + const char ** ppViewStr , sal_Int32* pViewLength, rtl_String * str, sal_Int32 token, char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C(); + /* ======================================================================= */ /** Supply an ASCII string literal together with its length. |