jaulib v1.3.6
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
string_util.hpp File Reference
#include <cstdint>
#include <cstring>
#include <cstdarg>
#include <string>
#include <string_view>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <jau/byte_util.hpp>
#include <jau/cpp_lang_util.hpp>
#include <jau/packed_attribute.hpp>
#include <jau/type_traits_queries.hpp>
#include <jau/int_types.hpp>
#include <jau/int_math.hpp>
#include <jau/string_cfmt.hpp>
Include dependency graph for string_util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  jau::string_hash
 C++20: Heterogeneous Lookup in (Un)ordered Containers. More...
 

Namespaces

namespace  jau
 __pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
 

Macros

#define jau_format_string_static(...)
 

Typedefs

template<typename T>
using jau::StringHashMap = std::unordered_map<std::string, T, string_hash, std::equal_to<>>
 
using jau::StringHashSet = std::unordered_set<std::string, string_hash, std::equal_to<>>
 

Functions

std::string & jau::byteHexString (std::string &dest, const uint8_t value, const bool lowerCase) noexcept
 Produce a hexadecimal string representation of the given byte value.
 
template<class uint8_container_type, std::enable_if_t< std::is_integral_v< typename uint8_container_type::value_type > &&std::is_convertible_v< typename uint8_container_type::value_type, uint8_t >, bool > = true>
std::string jau::bytesHexString (const uint8_container_type &bytes, const bool lsbFirst, const bool lowerCase=true, const bool skipLeading0x=false) noexcept
 
std::string jau::bytesHexString (const void *data, const nsize_t length, const bool lsbFirst, const bool lowerCase=true, const bool skipLeading0x=false) noexcept
 Produce a hexadecimal string representation of the given byte values.
 
std::string jau::format_string (const char *format,...)
 Returns a string according to printf() formatting rules and variable number of arguments following the format argument.
 
template<typename... Args>
constexpr std::string jau::format_string_v (const std::size_t maxStrLen, const std::string_view format, const Args &...args)
 Safely returns a string according to printf() formatting rules and variable number of arguments following the format argument.
 
uint64_t jau::from_hexstring (std::string const &s, const bool lsbFirst=!jau::is_little_endian(), const bool checkLeading0x=true) noexcept
 Converts a given hexadecimal string representation into a uint64_t value according to hexStringBytes().
 
std::string jau::get_string (const uint8_t *buffer, nsize_t const buffer_len, nsize_t const max_len) noexcept
 Returns a C++ String taken from buffer with maximum length of min(max_len, max_len).
 
size_t jau::hexStringBytes (std::vector< uint8_t > &out, const std::string &hexstr, const bool lsbFirst, const bool checkLeading0x) noexcept
 Converts a given hexadecimal string representation into a byte vector.
 
size_t jau::hexStringBytes (std::vector< uint8_t > &out, const uint8_t hexstr[], const size_t hexstr_len, const bool lsbFirst, const bool checkLeading0x) noexcept
 See hexStringBytes()
 
bool jau::is_ascii_code (int c) noexcept
 
std::vector< std::string > jau::split_string (const std::string &str, const std::string &separator) noexcept
 Split given string str at separator into the resulting std::vector excluding the separator sequence .
 
template<class value_type, std::enable_if_t< std::is_integral_v< value_type >, bool > = true>
std::string jau::to_decstring (const value_type &v, const char separator=',', const nsize_t width=0) noexcept
 Produce a decimal string representation of an integral integer value.
 
template<class value_type, std::enable_if_t< std::is_pointer_v< value_type >, bool > = true>
std::string jau::to_hexstring (value_type const &v, const bool skipLeading0x=false) noexcept
 Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer.
 
bool jau::to_integer (long long &result, const char *str, size_t str_len, const char limiter='\0', const char *limiter_pos=nullptr)
 
bool jau::to_integer (long long &result, const std::string &str, const char limiter='\0', const char *limiter_pos=nullptr)
 
template<class value_type, std::enable_if_t< std::is_integral_v< value_type >||std::is_floating_point_v< value_type >, bool > = true>
std::string jau::to_string (const value_type &ref)
 
template<typename T>
std::string jau::to_string (std::vector< T > const &list)
 
template<typename T>
std::string jau::to_string (std::vector< T > const &list, const std::string &delim)
 
std::string jau::toLower (const std::string &s) noexcept
 
std::string & jau::toLowerInPlace (std::string &s) noexcept
 
std::string jau::trim (const std::string &s) noexcept
 trim copy
 
void jau::trimInPlace (std::string &s) noexcept
 trim in place
 
std::string jau::vformat_string (const char *format, va_list ap)
 Returns a string according to vprintf() formatting rules using va_list instead of a variable number of arguments.
 

Macro Definition Documentation

◆ jau_format_string_static

#define jau_format_string_static ( ...)
Value:
jau::format_string(__VA_ARGS__); \
static_assert( 0 <= jau::cfmt::checkR(__VA_ARGS__).argCount() );
constexpr PResult checkR(const std::string_view fmt, const Targs &...) noexcept
Strict type validation of arguments against the format string.
std::string format_string(const char *format,...)
Returns a string according to printf() formatting rules and variable number of arguments following th...

Definition at line 466 of file string_util.hpp.