PUMA Library Reference Manual
Puma::StrCol Class Reference

#include <Puma/StrCol.h>

Description

Collection of string helper functions.

Static Public Member Functions

static bool isSpace (const char c)
 Check if the given character is one of: More...
 
static bool onlySpaces (const char *str)
 Check if the given string only contains space characters as recognized by isSpace(). More...
 
static bool effectivelyDifferent (const char *str1, const char *str2)
 Check if the two strings differ not only in spaces. More...
 
static char * dup (const char *str)
 Copy a string. More...
 
static char * dup (const char *str, int n)
 Copy the first n characters of a string. More...
 
static unsigned int hash (const char *str)
 Calculate a hash value for a string using the Hsieh algorithm. More...
 
static unsigned int hash (const char *str, int n)
 Calculate a hash value for the first n characters of a string using the Hsieh algorithm. More...
 
static std::string & replaceEnvironmentVariables (std::string &str)
 Replace environment variables of the form ${ENVVAR} in the given string. More...
 

Member Function Documentation

◆ dup() [1/2]

static char* Puma::StrCol::dup ( const char *  str)
static

Copy a string.

Parameters
strThe string to copy.
Returns
A newly allocated copy of the input string.

◆ dup() [2/2]

static char* Puma::StrCol::dup ( const char *  str,
int  n 
)
static

Copy the first n characters of a string.

Parameters
strThe string to copy.
nThe number of characters to copy.
Returns
A newly allocated string containing the first n characters of the input string.

◆ effectivelyDifferent()

static bool Puma::StrCol::effectivelyDifferent ( const char *  str1,
const char *  str2 
)
static

Check if the two strings differ not only in spaces.

Parameters
str1The first string.
str2The second string.
Returns
True if there are differences other than spaces.

◆ hash() [1/2]

static unsigned int Puma::StrCol::hash ( const char *  str)
static

Calculate a hash value for a string using the Hsieh algorithm.

Parameters
strThe input string.
Returns
The hash value.

◆ hash() [2/2]

static unsigned int Puma::StrCol::hash ( const char *  str,
int  n 
)
static

Calculate a hash value for the first n characters of a string using the Hsieh algorithm.

Parameters
strThe input string.
nThe number of characters to consider for the hash value.
Returns
The hash value.

◆ isSpace()

static bool Puma::StrCol::isSpace ( const char  c)
static

Check if the given character is one of:

  • white space
  • horizontal tab
  • vertical tab
  • form feed
  • line feed
  • carriage return
  • backspace
Parameters
cThe character to check.
Returns
True if it is a space character.

◆ onlySpaces()

static bool Puma::StrCol::onlySpaces ( const char *  str)
static

Check if the given string only contains space characters as recognized by isSpace().

Parameters
strThe string to check.
Returns
True if there are only space characters in that string.

◆ replaceEnvironmentVariables()

static std::string& Puma::StrCol::replaceEnvironmentVariables ( std::string &  str)
static

Replace environment variables of the form ${ENVVAR} in the given string.

Parameters
strA reference to the string containing the environment variables.
Returns
A reference to the input string with environment variables replaced by their values.