Quick Links: |
#include <bdlb_stringrefutil.h>
This struct
provides a namespace for a suite of functions on bslstl::StringRef
references to strings.
See Component bdlb_stringrefutil
static bool bdlb::StringRefUtil::areEqualCaseless | ( | const bslstl::StringRef & | lhs, | |
const bslstl::StringRef & | rhs | |||
) | [static] |
Compare (the referent data of) the specified lhs
and rhs
. Return true
if lhs
and rhs
are equal up to a case conversion, and false
otherwise. See Caseless Comparisons.
static int bdlb::StringRefUtil::lowerCaseCmp | ( | const bslstl::StringRef & | lhs, | |
const bslstl::StringRef & | rhs | |||
) | [static] |
Compare (the referent data of) the specified lhs
and rhs
. Return 1 if, after a conversion to lower case, lhs
is greater than rhs
, 0 if lhs
and rhs
are equal up to a case conversion, and -1 otherwise. See Caseless Comparisons.
static int bdlb::StringRefUtil::upperCaseCmp | ( | const bslstl::StringRef & | lhs, | |
const bslstl::StringRef & | rhs | |||
) | [static] |
Compare (the referent data of) the specified lhs
and rhs
. Return 1 if, after a conversion to upper case, lhs
is greater than rhs
, 0 if lhs
and rhs
are equal up to a case conversion, and -1 otherwise. See Caseless Comparisons.
static bslstl::StringRef bdlb::StringRefUtil::ltrim | ( | const bslstl::StringRef & | string | ) | [static] |
Return a bslstl::StringRef
object referring to the substring of (the referent data of) the specified string
that excludes all leading whitespace. See Whitespace Character Specification. If string
consists entirely of whitespace, return a zero-length reference to the end of string
(i.e., bslstl::StringRef(string.end(), 0)
).
static bslstl::StringRef bdlb::StringRefUtil::rtrim | ( | const bslstl::StringRef & | string | ) | [static] |
Return a bslstl::StringRef
object referring to the substring of (the referent data of) the specified string
that excludes all trailing whitespace. See Whitespace Character Specification. If string
consists entirely of whitespace, return a zero-length reference to the beginning of (the referent data of) string
(i.e., bslstl::StringRef(string.data(), 0)
).
static bslstl::StringRef bdlb::StringRefUtil::trim | ( | const bslstl::StringRef & | string | ) | [static] |
Return a bslstl::StringRef
object referring to the substring of (the referent data of) the specified string
that excludes all leading and trailing whitespace. See Whitespace Character Specification. If string
consists entirely of whitespace, return a zero-length reference to the beginning of (the referent data of) string
(i.e., bslstl::StringRef(string.data(), 0)
).
static bslstl::StringRef bdlb::StringRefUtil::substr | ( | const bslstl::StringRef & | string, | |
size_type | position = 0 , |
|||
size_type | numChars = k_NPOS | |||
) | [static] |
Return a string whose value is the substring starting at the optionally specified position
in the specified string
, of length the optionally specified numChars
or length() - position
, whichever is smaller. If position
is not specified, 0 is used (i.e., the substring is from the beginning of this string). If numChars
is not specified, k_NPOS
is used (i.e., the entire suffix from position
to the end of the string is returned). The behavior is undefined unless position
is within the string boundaries (0 <= position <= string.length()
).
static bslstl::StringRef bdlb::StringRefUtil::strstr | ( | const bslstl::StringRef & | string, | |
const bslstl::StringRef & | subString | |||
) | [static] |
Return a bslstl::StringRef
object referring to the first occurrence in (the referent data of) the specified string
at which (the referent data of) the specified subString
is found, or bslstl::StringRef()
if there is no such occurrence. If subString
has zero length then a zero-length reference to the beginning of string
is returned (i.e., bslstl::StringRef(string.data(), 0)
);
static bslstl::StringRef bdlb::StringRefUtil::strstrCaseless | ( | const bslstl::StringRef & | string, | |
const bslstl::StringRef & | subString | |||
) | [static] |
Return a bslstl::StringRef
object referring to the first occurrence in (the referent data of) the specified string
at which (the referent data of) the specified subString
is found using case-insensitive comparisons, or bslstl::StringRef()
if there is no such occurrence. See Caseless Comparisons. If subString
has zero length then a zero-length reference to the beginning of string
is returned (i.e., bslstl::StringRef(string.data(), 0)
);
static bslstl::StringRef bdlb::StringRefUtil::strrstr | ( | const bslstl::StringRef & | string, | |
const bslstl::StringRef & | subString | |||
) | [static] |
Return a bslstl::StringRef
object referring to the last occurrence in (the referent data of) the specified string
at which (the referent data of) the specified subString
is found, or bslstl::StringRef()
if there is no such occurrence. If subString
has zero length then a zero-length reference to the end of string
is returned (i.e., bslstl::StringRef(string.end(), 0)
);
static bslstl::StringRef bdlb::StringRefUtil::strrstrCaseless | ( | const bslstl::StringRef & | string, | |
const bslstl::StringRef & | subString | |||
) | [static] |
Return a bslstl::StringRef
object referring to the last occurrence in (the referent data of) the specified string
at which (the referent data of) the specified subString
is found using case-insensitive comparisons, or bslstl::StringRef()
if there is no such occurrence. See Caseless Comparisons. If subString
has zero length then a zero-length reference to the end of string
is returned (i.e., bslstl::StringRef(string.end(), 0)
);
static size_type bdlb::StringRefUtil::findFirstOf | ( | const bslstl::StringRef & | string, | |
const bslstl::StringRef & | characters, | |||
size_type | position = 0u | |||
) | [static] |
Return the position of the first occurrence of a character belonging to the specified characters
, if such an occurrence can can be found in the specified string
(on or after the optionally specified position
if such a position
is specified), and return k_NPOS
otherwise.
static size_type bdlb::StringRefUtil::findLastOf | ( | const bslstl::StringRef & | string, | |
const bslstl::StringRef & | characters, | |||
size_type | position = k_NPOS | |||
) | [static] |
Return the position of the last occurrence of a character belonging to the specified characters
, if such an occurrence can can be found in the specified string
(on or before the optionally specified position
if such a position
is specified), and return k_NPOS
otherwise.
static size_type bdlb::StringRefUtil::findFirstNotOf | ( | const bslstl::StringRef & | string, | |
const bslstl::StringRef & | characters, | |||
size_type | position = 0u | |||
) | [static] |
Return the position of the first occurrence of a character not belonging to the specified characters
, if such an occurrence can be found in the specified string
(on or after the optionally specified position
if such a position
is specified), and return k_NPOS
otherwise.
static size_type bdlb::StringRefUtil::findLastNotOf | ( | const bslstl::StringRef & | string, | |
const bslstl::StringRef & | characters, | |||
size_type | position = k_NPOS | |||
) | [static] |
Return the position of the last occurrence of a character not belonging to the specified characters
, if such an occurrence can be found in the specified string
(on or before the optionally specified position
if such a position
is specified), and return k_NPOS
otherwise.
const size_type bdlb::StringRefUtil::k_NPOS = ~size_type(0) [static] |
Value used to denote "not-a-position", guaranteed to be outside the range[0 .. INT_MAX]
.