FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
ns_string Namespace Reference

String manipulation and conversion utilities. More...

Classes

struct  static_string
 Compile-time string container with fixed size. More...
 

Functions

template<typename T>
std::string to_string (T &&t) noexcept
 Converts a type to a string.
 
template<typename T>
std::string from_container (T &&t, std::optional< char > sep=std::nullopt) noexcept
 Converts a container into a string if it has string convertible elements.
 
template<std::input_iterator It>
std::string from_container (It &&begin, It &&end, std::optional< char > sep=std::nullopt) noexcept
 Converts a container into a string if it has string convertible elements.
 
template<typename... Args>
std::string placeholders_replace (std::string str, Args &&... args)
 Replace all occurrences of "{}" placeholders in a string with provided values.
 

Detailed Description

String manipulation and conversion utilities.

This namespace provides enhanced string utilities including compile-time static strings, type-to-string conversion using concepts, container-to-string serialization, and placeholder replacement.

Function Documentation

◆ from_container() [1/2]

template<std::input_iterator It>
std::string ns_string::from_container ( It && begin,
It && end,
std::optional< char > sep = std::nullopt )
nodiscardnoexcept

Converts a container into a string if it has string convertible elements.

Template Parameters
TA container type
Parameters
beginThe begin iterator of the container to convert
endThe end iterator of the container to convert
sepThe separator to use between elements of the container
Returns
std::string The result of the conversion operation

Definition at line 161 of file string.hpp.

Here is the call graph for this function:

◆ from_container() [2/2]

template<typename T>
std::string ns_string::from_container ( T && t,
std::optional< char > sep = std::nullopt )
nodiscardnoexcept

Converts a container into a string if it has string convertible elements.

Template Parameters
TA container type
Parameters
tThe container to convert to a string
sepThe separator to use between elements of the container
Returns
std::string The result of the conversion operation

Definition at line 140 of file string.hpp.

Here is the caller graph for this function:

◆ placeholders_replace()

template<typename... Args>
std::string ns_string::placeholders_replace ( std::string str,
Args &&... args )
inlinenodiscard

Replace all occurrences of "{}" placeholders in a string with provided values.

This function iterates through the string and replaces "{}" placeholders with the provided arguments in order.

Template Parameters
ArgsThe types of the arguments to replace
Parameters
strThe string containing "{}" placeholders
argsThe values to replace placeholders with
Returns
The string with placeholders replaced

Definition at line 178 of file string.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string()

template<typename T>
std::string ns_string::to_string ( T && t)
inlinenodiscardnoexcept

Converts a type to a string.

Template Parameters
TA string representable type
Parameters
tThe value to convert to a string
Returns
std::string The type string representation

Definition at line 97 of file string.hpp.

Here is the caller graph for this function: