KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
Functions
Kratos::StringUtilities Namespace Reference

Functions

std::string ConvertCamelCaseToSnakeCase (const std::string &rString)
 This method converts CamelCase to snake_case. More...
 
std::string ConvertSnakeCaseToCamelCase (const std::string &rString)
 Convert snake_case to CamelCase. More...
 
std::string ErasePartialString (const std::string &rMainString, const std::string &rToErase)
 Erase first occurrence of given substring from main string. More...
 
bool ContainsPartialString (const std::string &rMainString, const std::string &rToCheck)
 Checks the existence of a substring from main string. More...
 
std::string RemoveWhiteSpaces (const std::string &rString)
 This method removes whitespaces. More...
 
std::vector< std::string > SplitStringByDelimiter (const std::string &rString, const char Delimiter)
 This method splits a string by a delimiter. More...
 
std::string ReplaceAllSubstrings (const std::string &rInputString, const std::string &rStringToBeReplaced, const std::string &rStringToReplace)
 This function replaces from a string all times a certain substring is repeated. More...
 
template<class TClass >
static void PrintDataWithIdentation (std::ostream &rOStream, const TClass &rThisClass, const std::string Identation="\t")
 Prints the data of an object of type TClass to the given output stream with indentation. More...
 

Function Documentation

◆ ContainsPartialString()

bool Kratos::StringUtilities::ContainsPartialString ( const std::string &  rMainString,
const std::string &  rToCheck 
)

Checks the existence of a substring from main string.

Parameters
rMainStringThe string to be transformed
rToCheckThe string to search
Returns
True if the substring is found and false otherwise

◆ ConvertCamelCaseToSnakeCase()

std::string Kratos::StringUtilities::ConvertCamelCaseToSnakeCase ( const std::string &  rString)

This method converts CamelCase to snake_case.

Parameters
rStringThe string to be transformed into snake_case
Returns
The string in snake_case

◆ ConvertSnakeCaseToCamelCase()

std::string Kratos::StringUtilities::ConvertSnakeCaseToCamelCase ( const std::string &  rString)

Convert snake_case to CamelCase.

Parameters
rStringString to convert.
Exceptions
Ifthe input string
  • contains capital letters [A-Z]
  • contains special characters other than underscores (?![a-z0-9_])
  • contains repeated underscores __+

◆ ErasePartialString()

std::string Kratos::StringUtilities::ErasePartialString ( const std::string &  rMainString,
const std::string &  rToErase 
)

Erase first occurrence of given substring from main string.

Parameters
rMainStringThe string to be transformed
rToEraseThe string to remove
Returns
The string without the part to remove

◆ PrintDataWithIdentation()

template<class TClass >
static void Kratos::StringUtilities::PrintDataWithIdentation ( std::ostream &  rOStream,
const TClass &  rThisClass,
const std::string  Identation = "\t" 
)
static

Prints the data of an object of type TClass to the given output stream with indentation.

Parameters
rOStreamThe output stream where the data will be printed.
rThisClassThe object of type TClass whose data will be printed.
Identation(optional) The string used for the indentation. Default is four spaces.

◆ RemoveWhiteSpaces()

std::string Kratos::StringUtilities::RemoveWhiteSpaces ( const std::string &  rString)

This method removes whitespaces.

Parameters
rStringThe string to be transformed
Returns
The string without white spaces

◆ ReplaceAllSubstrings()

std::string Kratos::StringUtilities::ReplaceAllSubstrings ( const std::string &  rInputString,
const std::string &  rStringToBeReplaced,
const std::string &  rStringToReplace 
)

This function replaces from a string all times a certain substring is repeated.

Parameters
rInputStringThe input string to replace the substring
rStringToBeReplacedThe original string to be replaced
rStringToReplaceThe string which replaces the substring
Returns
The string updated with the new substring

◆ SplitStringByDelimiter()

std::vector< std::string > Kratos::StringUtilities::SplitStringByDelimiter ( const std::string &  rString,
const char  Delimiter 
)

This method splits a string by a delimiter.

Parameters
rStringThe string to be splitted
DelimiterThe delimiter by which the string is to be splitted
Returns
a vector containing the splitted string