Repository navigation
TStringFunctions
#include <certpp/string.hpp> --- certpp
Template: template <typename T>
Fills the given data array with default-constructed values of type T.
-
data--- The data array to fill with default-constructed values. -
size--- The number of elements in the data array to fill.
Copies the contents from the source array to the destination array.
-
dest--- The destination array where the contents will be copied. -
src--- The source array from which the contents will be copied. -
size--- The number of elements to copy.
Moves the contents from the source array to the destination array.
-
dest--- The destination array where the contents will be moved. -
src--- The source array from which the contents will be moved. -
size--- The number of elements to move.
Compares two arrays of type T for equality.
-
lhs--- The left-hand side array. -
rhs--- The right-hand side array. -
size--- The number of elements to compare.
Returns: 0 if the arrays are equal, a non-zero value otherwise.
Compares two arrays of type T for equality, ignoring case.
-
lhs--- The left-hand side array. -
rhs--- The right-hand side array. -
size--- The number of elements to compare.
Returns: 0 if the arrays are equal (ignoring case), a non-zero value otherwise.
Finds the first occurrence of the specified character in the given string. Returns a pointer to the character if found, or nullptr if not found.
-
str--- The string to search for the character. -
size--- The size of the string. -
ch--- The character to find.
Returns: A pointer to the character if found, or nullptr if not found.
Finds the last occurrence of the specified character in the given string. Returns a pointer to the character if found, or nullptr if not found.
-
str--- The string to search for the character. -
size--- The size of the string. -
ch--- The character to find.
Returns: A pointer to the character if found, or nullptr if not found.
Finds the first occurrence of the specified character in the given string. Returns the offset of the character if found, or -1 if not found.
-
str--- The string to search for the character. -
size--- The size of the string. -
ch--- The character to find.
Returns: The offset of the character if found, or -1 if not found.
Finds the last occurrence of the specified character in the given string. Returns the offset of the character if found, or -1 if not found.
-
str--- The string to search for the character. -
size--- The size of the string. -
ch--- The character to find.
Returns: The offset of the character if found, or -1 if not found.
Counts the number of characters in the given string up to the specified size.
-
str--- The string to count characters in. -
size--- The maximum number of characters to count.
Returns: The number of characters in the string up to the specified size.
Checks if the given character is a whitespace character.
-
ch--- The character to check.
Returns: True if the character is a whitespace character, false otherwise.
Converts the given character to lowercase.
-
ch--- The character to convert to lowercase.
Returns: The lowercase version of the character.
Converts the given character to uppercase.
-
ch--- The character to convert to uppercase.
Returns: The uppercase version of the character.
The raw-pointer string primitives TString and CName are built on, usable directly when you have a pointer and a length instead of a TString. Everything here takes an explicit size and never looks for a terminator -- countOf() is the one call that does.
// given: const char* header
using Fn = TStringFunctions<char>;
const size_t len = Fn::countOf(header);
if (len == 0) {
return; // also what a null pointer reports, rather than crashing
}
const offset_t colon = Fn::find(header, len, ':');
if (colon < 0) {
return;
}
// caseCmp() compares exactly the count it is given and does not stop at a terminator, so
// the length has to be checked first, not inferred from the result.
const size_t nameLen = static_cast<size_t>(colon);
if (nameLen != 12 || Fn::caseCmp(header, "content-type", nameLen) != 0) {
return;
}Reference generated from certpp/string.hpp at commit 0834b29 (v1.0.1). The header is authoritative --- if this page disagrees with it, the header is right and this page needs regenerating.