BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlb::StringViewUtil Struct Reference

#include <bdlb_stringviewutil.h>

Public Types

typedef bsl::string_view::size_type size_type
 Size type of string_view containers.
 

Static Public Member Functions

static bool areEqualCaseless (const bsl::string_view &lhs, const bsl::string_view &rhs)
 
static int lowerCaseCmp (const bsl::string_view &lhs, const bsl::string_view &rhs)
 
static int upperCaseCmp (const bsl::string_view &lhs, const bsl::string_view &rhs)
 
static bsl::string_view ltrim (const bsl::string_view &string)
 
static bsl::string_view rtrim (const bsl::string_view &string)
 
static bsl::string_view trim (const bsl::string_view &string)
 
static bsl::string_view substr (const bsl::string_view &string, size_type position=0, size_type numChars=k_NPOS)
 
static bsl::string_view strstr (const bsl::string_view &string, const bsl::string_view &subString)
 
static bsl::string_view strstrCaseless (const bsl::string_view &string, const bsl::string_view &subString)
 
static bsl::string_view strrstr (const bsl::string_view &string, const bsl::string_view &subString)
 
static bsl::string_view strrstrCaseless (const bsl::string_view &string, const bsl::string_view &subString)
 
static size_type findFirstOf (const bsl::string_view &string, const bsl::string_view &characters, size_type position=0)
 
static size_type findLastOf (const bsl::string_view &string, const bsl::string_view &characters, size_type position=k_NPOS)
 
static size_type findFirstNotOf (const bsl::string_view &string, const bsl::string_view &characters, size_type position=0)
 
static size_type findLastNotOf (const bsl::string_view &string, const bsl::string_view &characters, size_type position=k_NPOS)
 
static bool startsWith (const bsl::string_view &string, const bsl::string_view &characters)
 
static bool startsWith (const bsl::string_view &string, const char *characters)
 
static bool startsWith (const bsl::string_view &string, char character)
 
static bool endsWith (const bsl::string_view &string, const bsl::string_view &characters)
 
static bool endsWith (const bsl::string_view &string, const char *characters)
 
static bool endsWith (const bsl::string_view &string, char character)
 

Static Public Attributes

static const size_type k_NPOS = bsl::string_view::npos
 

Detailed Description

This struct provides a namespace for a suite of functions on bsl::string_view containers.

Member Typedef Documentation

◆ size_type

Member Function Documentation

◆ areEqualCaseless()

bool bdlb::StringViewUtil::areEqualCaseless ( const bsl::string_view lhs,
const bsl::string_view rhs 
)
inlinestatic

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}.

◆ endsWith() [1/3]

bool bdlb::StringViewUtil::endsWith ( const bsl::string_view string,
char  character 
)
inlinestatic

Return true if the specified string ends with the specified character, and false otherwise.

◆ endsWith() [2/3]

bool bdlb::StringViewUtil::endsWith ( const bsl::string_view string,
const bsl::string_view characters 
)
inlinestatic

◆ endsWith() [3/3]

bool bdlb::StringViewUtil::endsWith ( const bsl::string_view string,
const char *  characters 
)
inlinestatic

Return true if the specified string ends with the specified characters, and false otherwise.

◆ findFirstNotOf()

static size_type bdlb::StringViewUtil::findFirstNotOf ( const bsl::string_view string,
const bsl::string_view characters,
size_type  position = 0 
)
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.

◆ findFirstOf()

static size_type bdlb::StringViewUtil::findFirstOf ( const bsl::string_view string,
const bsl::string_view characters,
size_type  position = 0 
)
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.

◆ findLastNotOf()

static size_type bdlb::StringViewUtil::findLastNotOf ( const bsl::string_view string,
const bsl::string_view 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.

◆ findLastOf()

static size_type bdlb::StringViewUtil::findLastOf ( const bsl::string_view string,
const bsl::string_view 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.

◆ lowerCaseCmp()

static int bdlb::StringViewUtil::lowerCaseCmp ( const bsl::string_view lhs,
const bsl::string_view 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}.

◆ ltrim()

static bsl::string_view bdlb::StringViewUtil::ltrim ( const bsl::string_view string)
static

Return a bsl::string_view 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., bsl::string_view(string.end(), 0)).

◆ rtrim()

static bsl::string_view bdlb::StringViewUtil::rtrim ( const bsl::string_view string)
static

Return a bsl::string_view 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., bsl::string_view(string.data(), 0)).

◆ startsWith() [1/3]

bool bdlb::StringViewUtil::startsWith ( const bsl::string_view string,
char  character 
)
inlinestatic

Return true if the specified string begins with the specified character, and false otherwise.

◆ startsWith() [2/3]

bool bdlb::StringViewUtil::startsWith ( const bsl::string_view string,
const bsl::string_view characters 
)
inlinestatic

◆ startsWith() [3/3]

bool bdlb::StringViewUtil::startsWith ( const bsl::string_view string,
const char *  characters 
)
inlinestatic

Return true if the specified string begins with the specified characters, and false otherwise.

◆ strrstr()

static bsl::string_view bdlb::StringViewUtil::strrstr ( const bsl::string_view string,
const bsl::string_view subString 
)
static

Return a bsl::string_view 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 bsl::string_view() 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., bsl::string_view(string.end(), 0));

◆ strrstrCaseless()

static bsl::string_view bdlb::StringViewUtil::strrstrCaseless ( const bsl::string_view string,
const bsl::string_view subString 
)
static

Return a bsl::string_view 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 bsl::string_view() 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., bsl::string_view(string.end(), 0));

◆ strstr()

static bsl::string_view bdlb::StringViewUtil::strstr ( const bsl::string_view string,
const bsl::string_view subString 
)
static

Return a bsl::string_view 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 bsl::string_view() 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., bsl::string_view(string.data(), 0));

◆ strstrCaseless()

static bsl::string_view bdlb::StringViewUtil::strstrCaseless ( const bsl::string_view string,
const bsl::string_view subString 
)
static

Return a bsl::string_view 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 bsl::string_view() 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., bsl::string_view(string.data(), 0));

◆ substr()

bsl::string_view bdlb::StringViewUtil::substr ( const bsl::string_view string,
size_type  position = 0,
size_type  numChars = k_NPOS 
)
inlinestatic

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()).

◆ trim()

bsl::string_view bdlb::StringViewUtil::trim ( const bsl::string_view string)
inlinestatic

Return a bsl::string_view 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., bsl::string_view(string.data(), 0)).

◆ upperCaseCmp()

static int bdlb::StringViewUtil::upperCaseCmp ( const bsl::string_view lhs,
const bsl::string_view 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}.

Member Data Documentation

◆ k_NPOS

const size_type bdlb::StringViewUtil::k_NPOS = bsl::string_view::npos
static

Value used to denote "not-a-position", guaranteed to be outside the range[0 .. bsl::string_view::max_size()].


The documentation for this struct was generated from the following file: