NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Functions
BiometricEvaluation::Text Namespace Reference

Text processing for string objects. More...

Functions

std::string trimWhitespace (const std::string &s, const std::locale &locale=std::locale())
 Remove leading and trailing whitespace from a string. More...
 
std::string ltrimWhitespace (const std::string &s, const std::locale &locale=std::locale())
 Remove leading whitespace from a string. More...
 
std::string rtrimWhitespace (const std::string &s, const std::locale &locale=std::locale())
 Remove trailing whitespace from a string. More...
 
std::string trim (const std::string &s, const char trimChar)
 Remove leading and trailing characters from a string. More...
 
std::string ltrim (const std::string &s, const char trimChar)
 Remove leading characters from a string. More...
 
std::string rtrim (const std::string &s, const char trimChar)
 Remove trailing characters from a string. More...
 
std::string digest (const std::string &s, const std::string &digest="md5")
 Compute the digest of a string. More...
 
std::string digest (const void *buffer, const size_t buffer_size, const std::string &digest="md5")
 Compute the digest of a memory buffer. More...
 
std::vector< std::string > split (const std::string &str, const char delimiter, bool escape=true)
 Return tokens bound by delimiters and the beginning and end of a string. More...
 
std::string basename (const std::string &path)
 Extract the filename component of a pathname. More...
 
std::string dirname (const std::string &path)
 Extract the directory component of a pathname. More...
 
bool caseInsensitiveCompare (const std::string &str1, const std::string &str2)
 Compare two ASCII-encoded strings. More...
 
std::string toUppercase (const std::string &str, const std::locale &locale=std::locale())
 Uppercase a string, respecting locale. More...
 
std::string toLowercase (const std::string &str, const std::locale &locale=std::locale())
 Lowercase a string, respecting locale. More...
 
std::string encodeBase64 (const BiometricEvaluation::Memory::uint8Array &data)
 Perform Base64 encoding. More...
 
BiometricEvaluation::Memory::uint8Array decodeBase64 (const std::string &data)
 Perform Base64 decoding. More...
 

Detailed Description

Text processing for string objects.

The Text package contains a set of functions for the processing of strings: removing leading and trailing whitespace, computing a digest, and other utility functions.

Function Documentation

◆ trimWhitespace()

std::string BiometricEvaluation::Text::trimWhitespace ( const std::string &  s,
const std::locale &  locale = std::locale() 
)

Remove leading and trailing whitespace from a string.

Parameters
sString object whose leading and trailing whitespace should be removed.
localeLocale to be considered when determining whitespace characters.
Returns
Copy of s without leading or trailing whitespace.

◆ ltrimWhitespace()

std::string BiometricEvaluation::Text::ltrimWhitespace ( const std::string &  s,
const std::locale &  locale = std::locale() 
)

Remove leading whitespace from a string.

Parameters
sString object whose leading whitespace should be removed.
localeLocale to be considered when determining whitespace characters.
Returns
Copy of s without leading whitespace.

◆ rtrimWhitespace()

std::string BiometricEvaluation::Text::rtrimWhitespace ( const std::string &  s,
const std::locale &  locale = std::locale() 
)

Remove trailing whitespace from a string.

Parameters
sString object whose trailing whitespace should be removed.
localeLocale to be considered when determining whitespace characters.
Returns
Copy of s without trailing whitespace.

◆ trim()

std::string BiometricEvaluation::Text::trim ( const std::string &  s,
const char  trimChar 
)

Remove leading and trailing characters from a string.

Parameters
sString object whose leading and trailing trimChar should be removed.
trimCharCharacter to remove from the beginning and ending of s.
Returns
Copy of s without leading or trailing trimChar.

◆ ltrim()

std::string BiometricEvaluation::Text::ltrim ( const std::string &  s,
const char  trimChar 
)

Remove leading characters from a string.

Parameters
sString object whose leading trimChar should be removed.
trimCharCharacter to remove from the beginning of s.
Returns
Copy of s without leading trimChar.

◆ rtrim()

std::string BiometricEvaluation::Text::rtrim ( const std::string &  s,
const char  trimChar 
)

Remove trailing characters from a string.

Parameters
sString object whose trailing trimChar should be removed.
trimCharCharacter to remove from the end of s.
Returns
Copy of s without trailing trimChar.

◆ digest() [1/2]

std::string BiometricEvaluation::Text::digest ( const std::string &  s,
const std::string &  digest = "md5" 
)

Compute the digest of a string.

Parameters
[in]sThe string of which a digest should be computed.
[in]digestThe digest to use. Any digest supported by OpenSSL is valid, and the default is MD5.
Exceptions
Error::MemoryErrorCould not allocate memory to store digest.
Error::NotImplementedThe value of digest is not a supported digest.
Error::StrategyErrorAn error occurred while obtaining the digest.
Returns
An ASCII representation of the hex digits composing the digest.

◆ digest() [2/2]

std::string BiometricEvaluation::Text::digest ( const void *  buffer,
const size_t  buffer_size,
const std::string &  digest = "md5" 
)

Compute the digest of a memory buffer.

Parameters
[in]bufferThe buffer of which a digest should be computed.
[in]buffer_sizeThe size of buffer.
[in]digestThe digest to use. Any digest supported by OpenSSL is valid, and the default is MD5.
Exceptions
Error::MemoryErrorCould not allocate memory to store digest.
Error::NotImplementedThe value of digest is not a supported digest.
Error::StrategyErrorAn error occurred while obtaining the digest.
Returns
An ASCII representation of the hex digits composing the digest.

◆ split()

std::vector< std::string > BiometricEvaluation::Text::split ( const std::string &  str,
const char  delimiter,
bool  escape = true 
)

Return tokens bound by delimiters and the beginning and end of a string.

Parameters
[in]strString to tokenize.
[in]delimiterCharacter that defines the end of a token. Any are valid, except '\'.
[in]escapeIf the delimiter is prefixed with '\' in the string, do not split at that point and remove the '\'.
Returns
Vector of string tokens, in order of appearance.
Note
If delimiter does not appear in string, the returned vector vector will still contain one item, str.

◆ basename()

std::string BiometricEvaluation::Text::basename ( const std::string &  path)

Extract the filename component of a pathname.

Returns the component following the final ’/’. Trailing ’/’ characters are not counted as part of the pathname.

Parameters
[in]pathPath from which to extract the filename portion.
Returns
Filename portion of path.

◆ dirname()

std::string BiometricEvaluation::Text::dirname ( const std::string &  path)

Extract the directory component of a pathname.

Returns the string up to, but not including, the final ’/’.

Parameters
[in]pathPath from which to extract the directory portion.
Returns
Directory portion of path.

◆ caseInsensitiveCompare()

bool BiometricEvaluation::Text::caseInsensitiveCompare ( const std::string &  str1,
const std::string &  str2 
)

Compare two ASCII-encoded strings.

Parameters
str1First string to compare.
str2Second string to compare.
Returns
true if str1 and str2 are equal other than case, false otherwise.

◆ toUppercase()

std::string BiometricEvaluation::Text::toUppercase ( const std::string &  str,
const std::locale &  locale = std::locale() 
)

Uppercase a string, respecting locale.

Parameters
strString to uppercase.
localeLocale to use when uppercasing str.
Returns
Uppercase copy of str.

◆ toLowercase()

std::string BiometricEvaluation::Text::toLowercase ( const std::string &  str,
const std::locale &  locale = std::locale() 
)

Lowercase a string, respecting locale.

Parameters
strString to loercase.
localeLocale to use when lowercasing str.
Returns
Lowercase copy of str.

◆ encodeBase64()

std::string BiometricEvaluation::Text::encodeBase64 ( const BiometricEvaluation::Memory::uint8Array data)

Perform Base64 encoding.

Parameters
dataData to encoded.
Returns
Base64 encoding of data.

◆ decodeBase64()

BiometricEvaluation::Memory::uint8Array BiometricEvaluation::Text::decodeBase64 ( const std::string &  data)

Perform Base64 decoding.

Parameters
dataBase64 data to decode.
Returns
Base64 decoding of data.