DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
CppUtils::Strings Namespace Reference

Namespaces

namespace  details
 

Classes

struct  ci_char_traits
 
class  Tokenizer
 

Typedefs

using ci_string = std::basic_string<char, ci_char_traits>
 Type alias for case-insensitive strings.
 

Functions

template<class OutputTraits, class InputTraits>
constexpr std::basic_string< char, OutputTraits > traits_cast (const std::basic_string< char, InputTraits > &input) noexcept
 
std::ostream & operator<< (std::ostream &os, const std::basic_string< char, ci_char_traits > &str)
 
template<typename T, typename CharTraits = std::char_traits<char>>
auto lexical_cast (const std::basic_string< char, CharTraits > &str)
 
template<typename TO, typename FROM, typename = std::enable_if_t<std::is_pointer_v<std::decay_t<FROM>>>>
auto lexical_cast (FROM &&str)
 
template<typename CharTraits>
constexpr bool foundSubstr (const std::basic_string< char, CharTraits > &stringToFind, const std::basic_string< char, CharTraits > &stringToSearch) noexcept
 
template<typename CharTraits>
constexpr bool foundSubstr (char stringToFind, const std::basic_string< char, CharTraits > &stringToSearch) noexcept
 
template<typename CharTraits>
constexpr bool foundSubstr (const char *stringToFind, const std::basic_string< char, CharTraits > &stringToSearch) noexcept
 
template<typename CharTraits, typename... TArgs>
 Tokenizer (const std::basic_string< char, CharTraits > &, TArgs...) -> Tokenizer< CharTraits >
 

Typedef Documentation

◆ ci_string

using CppUtils::Strings::ci_string = std::basic_string<char, ci_char_traits>

Function Documentation

◆ traits_cast()

template<class OutputTraits, class InputTraits>
std::basic_string< char, OutputTraits > CppUtils::Strings::traits_cast ( const std::basic_string< char, InputTraits > & input)
constexprnoexcept

A simple function for casting one char_trait to another

Parameters
input- An input string with some char_traits
Returns
An output string with another type of char_traits

◆ operator<<()

std::ostream & CppUtils::Strings::operator<< ( std::ostream & os,
const std::basic_string< char, ci_char_traits > & str )
inline

Allow for case-insensitive strings to be inserted into a ouput stream like a normal std::string.

Parameters
os- A character output stream
str- The string to be inserted

◆ lexical_cast() [1/2]

template<typename T, typename CharTraits = std::char_traits<char>>
auto CppUtils::Strings::lexical_cast ( const std::basic_string< char, CharTraits > & str)
inline

A simple function for converting a string to another type.

Template Parameters
T- The type to convert the input string to, must be input streamable
CharTraits- A trait allowing for either case-sensitive or case-insensitive searches
Parameters
str- The input string to convert
Returns
Either the converted value if nothing goes wrong, or the default constructed value and a warning message if something does.

References CppUtils::Errors::printErrorMessage().

Referenced by lexical_cast(), and CppUtils::Strings::Tokenizer< CharTraits >::split().

◆ lexical_cast() [2/2]

template<typename TO, typename FROM, typename = std::enable_if_t<std::is_pointer_v<std::decay_t<FROM>>>>
auto CppUtils::Strings::lexical_cast ( FROM && str)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References lexical_cast().

◆ foundSubstr() [1/3]

template<typename CharTraits>
bool CppUtils::Strings::foundSubstr ( const std::basic_string< char, CharTraits > & stringToFind,
const std::basic_string< char, CharTraits > & stringToSearch )
constexprnoexcept

A predicate wrapper for std::basic_string<char, CharTraits>::find() that returns whether the substring stringToFind was found in stringToSearch.

Template Parameters
CharTraits- A trait allowing for either case-sensitive or case-insensitive searches
Parameters
stringToFind- The string/substring to seach for
stringToSearch- The string to seach through

Referenced by CppUtils::Strings::Tokenizer< CharTraits >::isDelimiter(), and CppUtils::Strings::Tokenizer< CharTraits >::nextToken().

◆ foundSubstr() [2/3]

template<typename CharTraits>
bool CppUtils::Strings::foundSubstr ( char stringToFind,
const std::basic_string< char, CharTraits > & stringToSearch )
constexprnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ foundSubstr() [3/3]

template<typename CharTraits>
bool CppUtils::Strings::foundSubstr ( const char * stringToFind,
const std::basic_string< char, CharTraits > & stringToSearch )
constexprnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Tokenizer()

template<typename CharTraits, typename... TArgs>
CppUtils::Strings::Tokenizer ( const std::basic_string< char, CharTraits > & ,
TArgs...  ) -> Tokenizer< CharTraits >

Declaration guide for the Tokenizer<> class template so we can still deduce the character traits when the other arguments are passed as character arrays.

Template Parameters
CharTraits- The character traits we are trying to deduce
...TArgs- The types of delimiters