9 #ifndef ZYPP_NG_CORE_STRING_H_INCLUDED 10 #define ZYPP_NG_CORE_STRING_H_INCLUDED 14 #include <boost/utility/string_view.hpp> 27 const int entryVal = zypp::str::strtonum<T>( val.data() );
28 if ( errno == ERANGE )
34 template<
typename StrType,
typename T = std::remove_reference_t<StrType> >
37 T ret( std::forward<StrType>(s) );
44 typename T::size_type p = ret.find_first_not_of(
" \t\r\n" );
47 if constexpr ( std::is_same_v<std::string_view, StrType> )
54 ret.remove_prefix( p );
59 typename T::size_type p = ret.find_last_not_of(
" \t\r\n" );
62 if constexpr ( std::is_same_v<std::string_view, StrType> )
69 ret.remove_suffix( ret.size() - ( p+1 ) );
75 template<
class TOutputIterator>
76 void split(
const boost::string_view & line_r, TOutputIterator result_r,
const boost::string_view & sepchars_r =
" \t",
const Trim trim_r =
Trim::NO_TRIM )
82 if ( tokenBegin == std::string_view::npos )
85 while ( ( tokenEnd = line_r.find_first_of( sepchars_r, tokenBegin ) ) != std::string_view::npos ) {
86 auto line = line_r.substr( tokenBegin, tokenEnd-tokenBegin );
87 *result_r =
trim( line, trim_r );
90 tokenBegin = line_r.find_first_not_of( sepchars_r, tokenEnd );
91 if( tokenBegin == std::string_view::npos )
96 if ( tokenBegin != std::string_view::npos && tokenBegin < line_r.size() )
97 *result_r =
trim( line_r.substr( tokenBegin ), trim_r );
T trim(StrType &&s, const Trim trim_r)
void split(const boost::string_view &line_r, TOutputIterator result_r, const boost::string_view &sepchars_r=" \, const Trim trim_r=Trim::NO_TRIM)
String related utilities and Regular expression matching.
Trim
To define how to trim.
std::optional< T > safe_strtonum(const std::string_view &val)
std::string strerror(int errno_r)
Return string describing the error_r code.