NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
websocketpp::utility Namespace Reference

Generic non-websocket specific utility functions and data structures. More...

Classes

struct  ci_less
 Helper less than functor for case insensitive find. More...
 
struct  my_equal
 Helper functor for case insensitive find. More...
 

Functions

std::string to_lower (std::string const &in)
 Convert a string to lowercase. More...
 
std::string to_hex (std::string const &input)
 Convert std::string to ascii printed string of hex digits. More...
 
std::string to_hex (uint8_t const *input, size_t length)
 Convert byte array (uint8_t) to ascii printed string of hex digits. More...
 
std::string to_hex (char const *input, size_t length)
 Convert char array to ascii printed string of hex digits. More...
 
std::string string_replace_all (std::string subject, std::string const &search, std::string const &replace)
 Replace all occurrances of a substring with another. More...
 
template<typename T >
T::const_iterator ci_find_substr (T const &haystack, T const &needle, std::locale const &loc=std::locale())
 Find substring (case insensitive) More...
 
template<typename T >
T::const_iterator ci_find_substr (T const &haystack, typename T::value_type const *needle, typename T::size_type size, std::locale const &loc=std::locale())
 Find substring (case insensitive) More...
 

Detailed Description

Generic non-websocket specific utility functions and data structures.

Function Documentation

◆ to_lower()

std::string websocketpp::utility::to_lower ( std::string const &  in)
inline

Convert a string to lowercase.

Parameters
[in]inThe string to convert
Returns
The converted string

Definition at line 37 of file utilities_impl.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), and ci_find_substr().

◆ to_hex() [1/3]

std::string websocketpp::utility::to_hex ( std::string const &  input)
inline

Convert std::string to ascii printed string of hex digits.

Parameters
[in]inputThe string to print
Returns
A copy of input converted to the printable representation of the hex values of its data.

Definition at line 43 of file utilities_impl.hpp.

Referenced by ci_find_substr(), websocketpp::connection< stub_config >::handle_read_frame(), websocketpp::connection< stub_config >::handle_read_handshake(), main(), on_message(), connection_metadata::on_message(), websocketpp::connection< stub_config >::process_handshake_request(), to_hex(), and websocketpp::connection< stub_config >::write_frame().

◆ to_hex() [2/3]

std::string websocketpp::utility::to_hex ( uint8_t const *  input,
size_t  length 
)
inline

Convert byte array (uint8_t) to ascii printed string of hex digits.

Parameters
[in]inputThe byte array to print
[in]lengthThe length of input
Returns
A copy of input converted to the printable representation of the hex values of its data.

Definition at line 56 of file utilities_impl.hpp.

◆ to_hex() [3/3]

std::string websocketpp::utility::to_hex ( char const *  input,
size_t  length 
)
inline

Convert char array to ascii printed string of hex digits.

Parameters
[in]inputThe char array to print
[in]lengthThe length of input
Returns
A copy of input converted to the printable representation of the hex values of its data.

Definition at line 69 of file utilities_impl.hpp.

References to_hex().

◆ string_replace_all()

std::string websocketpp::utility::string_replace_all ( std::string  subject,
std::string const &  search,
std::string const &  replace 
)
inline

Replace all occurrances of a substring with another.

Parameters
[in]subjectThe string to search in
[in]searchThe string to search for
[in]replaceThe string to replace with
Returns
A copy of subject with all occurances of search replaced with replace

Definition at line 73 of file utilities_impl.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), ci_find_substr(), and websocketpp::connection< stub_config >::get_supported_versions().

◆ ci_find_substr() [1/2]

template<typename T >
T::const_iterator websocketpp::utility::ci_find_substr ( T const &  haystack,
T const &  needle,
std::locale const &  loc = std::locale() 
)

Find substring (case insensitive)

Parameters
[in]haystackThe string to search in
[in]needleThe string to search for
[in]locThe locale to use for determining the case of values. Defaults to the current locale.
Returns
An iterator to the first element of the first occurrance of needle in haystack. If the sequence is not found, the function returns haystack.end()

Definition at line 101 of file utilities.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), websocketpp::processor::is_websocket_handshake(), and websocketpp::processor::hybi13< stub_config >::validate_server_handshake_response().

◆ ci_find_substr() [2/2]

template<typename T >
T::const_iterator websocketpp::utility::ci_find_substr ( T const &  haystack,
typename T::value_type const *  needle,
typename T::size_type  size,
std::locale const &  loc = std::locale() 
)

Find substring (case insensitive)

Todo:
Is this still used? This method may not make sense.

. should use iterators or be less generic. As is it is too tightly coupled to std::string

Parameters
[in]haystackThe string to search in
[in]needleThe string to search for as a char array of values
[in]sizeLength of needle
[in]locThe locale to use for determining the case of values. Defaults to the current locale.
Returns
An iterator to the first element of the first occurrance of needle in haystack. If the sequence is not found, the function returns haystack.end()

Definition at line 123 of file utilities.hpp.

References nonstd::span_lite::size(), string_replace_all(), to_hex(), and to_lower().