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

#include <bdlb_string.h>

Static Public Member Functions

static bool areEqualCaseless (const char *lhsString, const char *rhsString)
 
static bool areEqualCaseless (const char *lhsString, const char *rhsString, int rhsLength)
 
static bool areEqualCaseless (const char *lhsString, const bsl::string &rhsString)
 
static bool areEqualCaseless (const char *lhsString, int lhsLength, const char *rhsString)
 
static bool areEqualCaseless (const char *lhsString, int lhsLength, const char *rhsString, int rhsLength)
 
static bool areEqualCaseless (const char *lhsString, int lhsLength, const bsl::string &rhsString)
 
static bool areEqualCaseless (const bsl::string &lhsString, const char *rhsString)
 
static bool areEqualCaseless (const bsl::string &lhsString, const char *rhsString, int rhsLength)
 
static bool areEqualCaseless (const bsl::string &lhsString, const bsl::string &rhsString)
 
static char * copy (const char *string, bslma::Allocator *basicAllocator)
 
static char * copy (const char *string, int length, bslma::Allocator *basicAllocator)
 
static char * copy (const bsl::string &string, bslma::Allocator *basicAllocator)
 
static int lowerCaseCmp (const char *lhsString, const char *rhsString)
 
static int lowerCaseCmp (const char *lhsString, const char *rhsString, int rhsLength)
 
static int lowerCaseCmp (const char *lhsString, const bsl::string &rhsString)
 
static int lowerCaseCmp (const char *lhsString, int lhsLength, const char *rhsString)
 
static int lowerCaseCmp (const char *lhsString, int lhsLength, const char *rhsString, int rhsLength)
 
static int lowerCaseCmp (const char *lhsString, int lhsLength, const bsl::string &rhsString)
 
static int lowerCaseCmp (const bsl::string &lhsString, const char *rhsString)
 
static int lowerCaseCmp (const bsl::string &lhsString, const char *rhsString, int rhsLength)
 
static int lowerCaseCmp (const bsl::string &lhsString, const bsl::string &rhsString)
 
static void ltrim (char *string)
 
static void ltrim (bsl::string *string)
 
static void ltrim (std::string *string)
 
static void ltrim (char *string, int *length)
 
static void pad (bsl::string *string, int length, char padChar=' ')
 
static void pad (std::string *string, int length, char padChar=' ')
 
static void rtrim (char *string)
 
static void rtrim (bsl::string *string)
 
static void rtrim (std::string *string)
 
static void rtrim (const char *string, int *length)
 
static const char * strstr (const char *string, int stringLen, const char *subString, int subStringLen)
 
static const char * strstrCaseless (const char *string, int stringLen, const char *subString, int subStringLen)
 
static const char * strrstr (const char *string, int stringLen, const char *subString, int subStringLen)
 
static const char * strrstrCaseless (const char *string, int stringLen, const char *subString, int subStringLen)
 
static int strnlen (const char *string, int maximumLength)
 
static void toFixedLength (char *dstString, int dstLength, const char *srcString, int srcLength, char padChar=' ')
 
static void toLower (char *string)
 
static void toLower (char *string, int length)
 
static void toLower (bsl::string *string)
 
static void toLower (std::string *string)
 
static void toUpper (char *string)
 
static void toUpper (char *string, int length)
 
static void toUpper (bsl::string *string)
 
static void toUpper (std::string *string)
 
static void trim (char *string)
 
static void trim (bsl::string *string)
 
static void trim (std::string *string)
 
static void trim (char *string, int *length)
 
static void skipLeadingTrailing (const char **begin, const char **end)
 
static int upperCaseCmp (const char *lhsString, const char *rhsString)
 
static int upperCaseCmp (const char *lhsString, const char *rhsString, int rhsLength)
 
static int upperCaseCmp (const char *lhsString, const bsl::string &rhsString)
 
static int upperCaseCmp (const char *lhsString, int lhsLength, const char *rhsString)
 
static int upperCaseCmp (const char *lhsString, int lhsLength, const char *rhsString, int rhsLength)
 
static int upperCaseCmp (const char *lhsString, int lhsLength, const bsl::string &rhsString)
 
static int upperCaseCmp (const bsl::string &lhsString, const char *rhsString)
 
static int upperCaseCmp (const bsl::string &lhsString, const char *rhsString, int rhsLength)
 
static int upperCaseCmp (const bsl::string &lhsString, const bsl::string &rhsString)
 

Detailed Description

This struct provides a namespace for a suite of functions on STL-style strings (bsl::string, std::string, std::pmr::string), C-style strings, and strings specified by a (const char *, int) or (char *, int) pair.

Member Function Documentation

◆ areEqualCaseless() [1/9]

bool bdlb::String::areEqualCaseless ( const bsl::string lhsString,
const bsl::string rhsString 
)
inlinestatic

Compare for equality the specified lhsString and rhsString having the optionally specified lhsLength and rhsLength, respectively, as if the strings were converted to lower case before the equality comparison. Return true if lhsString is equal to rhsString, and false otherwise. The behavior is undefined unless 0 <= lhsLength and 0 <= rhsLength (if specified), and lhsString.size() <= INT_MAX and rhsString.size() <= INT_MAX (if applicable). See bdlb_stringviewutil for an identically named method having the same semantics taking bsl::string_view.

◆ areEqualCaseless() [2/9]

bool bdlb::String::areEqualCaseless ( const bsl::string lhsString,
const char *  rhsString 
)
inlinestatic

◆ areEqualCaseless() [3/9]

bool bdlb::String::areEqualCaseless ( const bsl::string lhsString,
const char *  rhsString,
int  rhsLength 
)
inlinestatic

◆ areEqualCaseless() [4/9]

bool bdlb::String::areEqualCaseless ( const char *  lhsString,
const bsl::string rhsString 
)
inlinestatic

◆ areEqualCaseless() [5/9]

static bool bdlb::String::areEqualCaseless ( const char *  lhsString,
const char *  rhsString 
)
static

◆ areEqualCaseless() [6/9]

static bool bdlb::String::areEqualCaseless ( const char *  lhsString,
const char *  rhsString,
int  rhsLength 
)
static

◆ areEqualCaseless() [7/9]

bool bdlb::String::areEqualCaseless ( const char *  lhsString,
int  lhsLength,
const bsl::string rhsString 
)
inlinestatic

◆ areEqualCaseless() [8/9]

bool bdlb::String::areEqualCaseless ( const char *  lhsString,
int  lhsLength,
const char *  rhsString 
)
inlinestatic

◆ areEqualCaseless() [9/9]

static bool bdlb::String::areEqualCaseless ( const char *  lhsString,
int  lhsLength,
const char *  rhsString,
int  rhsLength 
)
static

◆ copy() [1/3]

char * bdlb::String::copy ( const bsl::string string,
bslma::Allocator basicAllocator 
)
inlinestatic

Create a null-terminated copy of the specified string, using the specified basicAllocator to supply memory, and return the address of the newly-created modifiable string. The string that is returned is owned by the caller. The behavior is undefined unless string.size() <= INT_MAX and basicAllocator is non-null. Note that if string contains any embedded null ('\0') characters they will be propagated to the copy.

◆ copy() [2/3]

char * bdlb::String::copy ( const char *  string,
bslma::Allocator basicAllocator 
)
inlinestatic

Create a null-terminated copy of the specified string, using the specified basicAllocator to supply memory, and return the address of the newly-created modifiable string. The string that is returned is owned by the caller. The behavior is undefined unless bsl::strlen(string) <= INT_MAX and basicAllocator is non-null.

◆ copy() [3/3]

static char * bdlb::String::copy ( const char *  string,
int  length,
bslma::Allocator basicAllocator 
)
static

Create a null-terminated copy of the specified string having the specified length (in bytes), using the specified basicAllocator to supply memory, and return the address of the newly-created modifiable string. The string that is returned is owned by the caller. The behavior is undefined unless 0 <= length and basicAllocator is non-null. Note that if string contains any embedded null ('\0') characters they will be propagated to the copy.

◆ lowerCaseCmp() [1/9]

int bdlb::String::lowerCaseCmp ( const bsl::string lhsString,
const bsl::string rhsString 
)
inlinestatic

Compare the specified lhsString and rhsString having the optionally specified lhsLength and rhsLength, respectively. Return 1 if, after conversion to lower case, lhsString is lexically greater than rhsString, 0 if they are equal up to a case conversion, and -1 otherwise. The behavior is undefined unless 0 <= lhsLength and 0 <= rhsLength (if specified), and lhsString.size() <= INT_MAX and rhsString.size() <= INT_MAX (if applicable). See bdlb_stringviewutil for an identically named method having the same semantics taking bsl::string_view.

◆ lowerCaseCmp() [2/9]

int bdlb::String::lowerCaseCmp ( const bsl::string lhsString,
const char *  rhsString 
)
inlinestatic

◆ lowerCaseCmp() [3/9]

int bdlb::String::lowerCaseCmp ( const bsl::string lhsString,
const char *  rhsString,
int  rhsLength 
)
inlinestatic

◆ lowerCaseCmp() [4/9]

int bdlb::String::lowerCaseCmp ( const char *  lhsString,
const bsl::string rhsString 
)
inlinestatic

◆ lowerCaseCmp() [5/9]

static int bdlb::String::lowerCaseCmp ( const char *  lhsString,
const char *  rhsString 
)
static

◆ lowerCaseCmp() [6/9]

static int bdlb::String::lowerCaseCmp ( const char *  lhsString,
const char *  rhsString,
int  rhsLength 
)
static

◆ lowerCaseCmp() [7/9]

int bdlb::String::lowerCaseCmp ( const char *  lhsString,
int  lhsLength,
const bsl::string rhsString 
)
inlinestatic

◆ lowerCaseCmp() [8/9]

int bdlb::String::lowerCaseCmp ( const char *  lhsString,
int  lhsLength,
const char *  rhsString 
)
inlinestatic

◆ lowerCaseCmp() [9/9]

static int bdlb::String::lowerCaseCmp ( const char *  lhsString,
int  lhsLength,
const char *  rhsString,
int  rhsLength 
)
static

◆ ltrim() [1/4]

void bdlb::String::ltrim ( bsl::string string)
inlinestatic

◆ ltrim() [2/4]

static void bdlb::String::ltrim ( char *  string)
static

◆ ltrim() [3/4]

static void bdlb::String::ltrim ( char *  string,
int *  length 
)
static

Remove all leading whitespace characters from the specified string having the specified length, and load into length the number of characters in the resulting (trimmed) string. If string consists of only whitespace then it will be empty (i.e., have 0 length) after this operation. The behavior is undefined unless 0 <= *length. Note that length is both an input and output parameter. See bdlb_stringviewutil for an identically named method having similar semantics taking (and returning) bsl::string_view.

◆ ltrim() [4/4]

void bdlb::String::ltrim ( std::string *  string)
inlinestatic

Remove all leading whitespace characters from the specified string. If string consists of only whitespace then it will be empty (i.e., have 0 length) after this operation. The behavior is undefined unless string->size() <= INT_MAX (if applicable). See bdlb_stringviewutil for an identically named method having similar semantics taking (and returning) bsl::string_view.

◆ pad() [1/2]

void bdlb::String::pad ( bsl::string string,
int  length,
char  padChar = ' ' 
)
inlinestatic

◆ pad() [2/2]

void bdlb::String::pad ( std::string *  string,
int  length,
char  padChar = ' ' 
)
inlinestatic

Append repeatedly to the specified string the optionally specified padChar until string has the specified length. If padChar is not specified the space () character is appended. This operation has no effect if string.size() >= length. The behavior is undefined unless 0 <= length.

◆ rtrim() [1/4]

void bdlb::String::rtrim ( bsl::string string)
inlinestatic

◆ rtrim() [2/4]

static void bdlb::String::rtrim ( char *  string)
static

◆ rtrim() [3/4]

static void bdlb::String::rtrim ( const char *  string,
int *  length 
)
static

Determine the number of characters that the specified string having the specified length would have if all trailing whitespace characters were removed and load the result into *length. string is not modified. The behavior is undefined unless 0 <= *length. Note that length is both an input and output parameter.

◆ rtrim() [4/4]

void bdlb::String::rtrim ( std::string *  string)
inlinestatic

Remove all trailing whitespace characters from the specified string. If string consists of only whitespace then it will be empty (i.e., have 0 length) after this operation. The behavior is undefined unless string->size() <= INT_MAX (if applicable). See bdlb_stringviewutil for an identically named method having similar semantics taking (and returning) bsl::string_view.

◆ skipLeadingTrailing()

static void bdlb::String::skipLeadingTrailing ( const char **  begin,
const char **  end 
)
static

Skip leading and trailing whitespace characters in the string indicated by the specified *begin and *end iterators by appropriately advancing *begin and regressing *end. If the indicated string is empty, or consists solely of whitespace characters, *begin is unchanged and *end is regressed to *begin. Otherwise, advance *begin to the first non-whitespace character whose position is greater than or equal to *begin and regress *end to one past the position of the last non-whitespace character whose position is less than *end. The indicated string need not be null-terminated and may contain embedded null ('\0') characters. The behavior is undefined unless *begin <= *end. Note that since *begin and *end are iterators, *end refers to the character one past the end of the subject string.

◆ strnlen()

static int bdlb::String::strnlen ( const char *  string,
int  maximumLength 
)
static

Return the minimum of the length of the specified string and the specified maximumLength. If maximumLength is 0, string may be null and 0 is returned. The behavior is undefined unless 0 <= maximumLength.

◆ strrstr()

static const char * bdlb::String::strrstr ( const char *  string,
int  stringLen,
const char *  subString,
int  subStringLen 
)
static

Return the address providing non-modifiable access to the last position in the specified string having stringLen characters at which the specified subString having subStringLen characters is found, or 0 if there is no such position. If subStringLen is 0, subString may be null and string + stringLen is returned. The behavior is undefined unless 0 <= stringLen and 0 <= subStringLen. See bdlb_stringviewutil for an identically named method having similar semantics taking (and returning) bsl::string_view.

◆ strrstrCaseless()

static const char * bdlb::String::strrstrCaseless ( const char *  string,
int  stringLen,
const char *  subString,
int  subStringLen 
)
static

Return the address providing non-modifiable access to the last position in the specified string having stringLen characters at which the specified subString having subStringLen characters is found using case-insensitive comparison, or 0 if there is no such position. If subStringLen is 0, subString may be null and string + stringLen is returned. The behavior is undefined unless 0 <= stringLen and 0 <= subStringLen. See bdlb_stringviewutil for an identically named method having similar semantics taking (and returning) bsl::string_view.

◆ strstr()

static const char * bdlb::String::strstr ( const char *  string,
int  stringLen,
const char *  subString,
int  subStringLen 
)
static

Return the address providing non-modifiable access to the first position in the specified string having stringLen characters at which the specified subString having subStringLen characters is found, or 0 if there is no such position. If subStringLen is 0, subString may be null and string is returned. The behavior is undefined unless 0 <= stringLen and 0 <= subStringLen. See bdlb_stringviewutil for an identically named method having similar semantics taking (and returning) bsl::string_view.

◆ strstrCaseless()

static const char * bdlb::String::strstrCaseless ( const char *  string,
int  stringLen,
const char *  subString,
int  subStringLen 
)
static

Return the address providing non-modifiable access to the first position in the specified string having stringLen characters at which the specified subString having subStringLen characters is found using case-insensitive comparison, or 0 if there is no such position. If subStringLen is 0, subString may be null and string is returned. The behavior is undefined unless 0 <= stringLen and 0 <= subStringLen. See bdlb_stringviewutil for an identically named method having similar semantics taking (and returning) bsl::string_view.

◆ toFixedLength()

static void bdlb::String::toFixedLength ( char *  dstString,
int  dstLength,
const char *  srcString,
int  srcLength,
char  padChar = ' ' 
)
static

Copy into the specified dstString at most the specified leading dstLength characters from the specified srcString having the specified srcLength. If srcLength < dstLength, after srcString is copied to dstString repeatedly append to dstString the optionally specified padChar until the total number of characters written to dstString is dstLength. If padChar is not specified the space () character is appended. The behavior is undefined unless 0 <= dstLength and 0 <= srcLength.

◆ toLower() [1/4]

void bdlb::String::toLower ( bsl::string string)
inlinestatic

◆ toLower() [2/4]

static void bdlb::String::toLower ( char *  string)
static

◆ toLower() [3/4]

static void bdlb::String::toLower ( char *  string,
int  length 
)
static

◆ toLower() [4/4]

void bdlb::String::toLower ( std::string *  string)
inlinestatic

Replace all upper case characters in the specified string having the optionally specified length with their lower-case equivalent. The behavior is undefined unless 0 <= length (if specified) and string->size() <= INT_MAX (if applicable).

◆ toUpper() [1/4]

void bdlb::String::toUpper ( bsl::string string)
inlinestatic

◆ toUpper() [2/4]

static void bdlb::String::toUpper ( char *  string)
static

◆ toUpper() [3/4]

static void bdlb::String::toUpper ( char *  string,
int  length 
)
static

◆ toUpper() [4/4]

void bdlb::String::toUpper ( std::string *  string)
inlinestatic

Replace all lower case characters in the specified string having the optionally specified length with their upper-case equivalent. The behavior is undefined unless 0 <= length (if specified) and string->size() <= INT_MAX (if applicable).

◆ trim() [1/4]

void bdlb::String::trim ( bsl::string string)
inlinestatic

◆ trim() [2/4]

static void bdlb::String::trim ( char *  string)
static

◆ trim() [3/4]

void bdlb::String::trim ( char *  string,
int *  length 
)
inlinestatic

Remove all leading and trailing whitespace characters from the specified string having the specified length, and load into length the number of characters in the resulting (trimmed) string. If string consists of only whitespace then it will be empty (i.e., have 0 length) after this operation. The behavior is undefined unless 0 <= *length. Note that length is both an input and output parameter. See bdlb_stringviewutil for an identically named method having similar semantics taking (and returning) bsl::string_view.

◆ trim() [4/4]

void bdlb::String::trim ( std::string *  string)
inlinestatic

Remove all leading and trailing whitespace characters from the specified string. If string consists of only whitespace then it will be empty (i.e., have 0 length) after this operation. The behavior is undefined unless string->size() <= INT_MAX (if applicable). See bdlb_stringviewutil for an identically named method having similar semantics taking (and returning) bsl::string_view.

◆ upperCaseCmp() [1/9]

int bdlb::String::upperCaseCmp ( const bsl::string lhsString,
const bsl::string rhsString 
)
inlinestatic

Compare the specified lhsString and rhsString having the optionally specified lhsLength and rhsLength, respectively, as if the strings were converted to upper case before the comparison. Return 1 if lhsString is lexically greater than rhsString, 0 if they are equal, and -1 otherwise. The behavior is undefined unless 0 <= lhsLength and 0 <= rhsLength (if specified), and lhsString.size() <= INT_MAX and rhsString.size() <= INT_MAX (if applicable). See bdlb_stringviewutil for an identically named method having the same semantics taking bsl::string_view.

◆ upperCaseCmp() [2/9]

int bdlb::String::upperCaseCmp ( const bsl::string lhsString,
const char *  rhsString 
)
inlinestatic

◆ upperCaseCmp() [3/9]

int bdlb::String::upperCaseCmp ( const bsl::string lhsString,
const char *  rhsString,
int  rhsLength 
)
inlinestatic

◆ upperCaseCmp() [4/9]

int bdlb::String::upperCaseCmp ( const char *  lhsString,
const bsl::string rhsString 
)
inlinestatic

◆ upperCaseCmp() [5/9]

static int bdlb::String::upperCaseCmp ( const char *  lhsString,
const char *  rhsString 
)
static

◆ upperCaseCmp() [6/9]

static int bdlb::String::upperCaseCmp ( const char *  lhsString,
const char *  rhsString,
int  rhsLength 
)
static

◆ upperCaseCmp() [7/9]

int bdlb::String::upperCaseCmp ( const char *  lhsString,
int  lhsLength,
const bsl::string rhsString 
)
inlinestatic

◆ upperCaseCmp() [8/9]

int bdlb::String::upperCaseCmp ( const char *  lhsString,
int  lhsLength,
const char *  rhsString 
)
inlinestatic

◆ upperCaseCmp() [9/9]

static int bdlb::String::upperCaseCmp ( const char *  lhsString,
int  lhsLength,
const char *  rhsString,
int  rhsLength 
)
static

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