17#include <zypp-core/base/String.h>
18#include <zypp-core/base/LogTools.h>
20#include <zypp-core/TriBool.h>
36 std::string
form(
const char * format, ... )
45 return safe.asString();
107 return ( (
'a' <=
ch &&
ch <=
'z' )
108 ||(
'A' <=
ch &&
ch <=
'Z' )
109 ||(
'0' <=
ch &&
ch <=
'9' ) );
112 inline int heDecodeCh(
char ch )
114 if (
'0' <= ch && ch <=
'9' )
116 if (
'A' <= ch && ch <=
'F' )
117 return( ch -
'A' + 10 );
118 if (
'a' <= ch && ch <=
'f' )
119 return( ch -
'a' + 10 );
126 static const char *
const hdig =
"0123456789ABCDEF";
178 {
return toLower( std::string(
s) ); }
182 std::string
ret( std::move(
s) );
187 for ( std::string::size_type
i = 0;
i <
ret.length(); ++
i )
201 {
return toUpper( std::string(
s) ); }
205 std::string
ret( std::move(
s) );
210 for ( std::string::size_type
i = 0;
i <
ret.length(); ++
i )
228 std::string
ret( std::move(
s) );
235 std::string::size_type
p =
ret.find_first_not_of(
" \t\n" );
236 if (
p == std::string::npos )
246 std::string::size_type
p =
ret.find_last_not_of(
" \t\n" );
247 if (
p == std::string::npos )
272 std::string::size_type
p =
line.find_first_of(
" \t" );
274 if (
p == std::string::npos ) {
278 }
else if (
p == 0 ) {
305 std::string::size_type
p =
line.find_last_of(
" \t" );
307 if (
p == std::string::npos ) {
311 }
else if (
p ==
line.size()-1 ) {
334 std::string::size_type
pos = 0;
357 std::string::size_type
pos = 0;
373 std::vector<char>
buf;
381 buf.push_back(
'\\' );
386 buf.push_back(
'\\' );
390 return std::string(
buf.begin(),
buf.end() );
400 && ( ::strchr(
special_r.c_str(),
'\\' ) || !::strchr(
str_r.c_str(),
'\\' ) ) )
406 if ( *
s ==
'\\' || ::strchr(
special_r.c_str(), *
s ) )
413 #define RXSPECIALCHARS "\\.*+?^$[()|{"
434 if ( *(
s+1) ) { ++
s;
buf << *
s; }
436 else if ( *
s ==
'?' )
440 else if ( *
s ==
'*' )
444 else if ( *
s ==
'[' )
446 const char *
e =
s+1;
447 if ( *
e ==
'^' || *
e ==
'!' )
451 while ( *
e && *
e !=
']' )
455 ++
s;
buf <<
'[' << (*
s ==
'!' ?
'^' : *
s );
490 std::ostringstream
datas;
510 str.clear( std::ios::eofbit );
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
String related utilities and Regular expression matching.
std::string stripLastWord(std::string &line, const bool rtrim_first)
std::string hexdecode(const C_Str &str_r)
Decode hexencoded XX sequences.
std::string & replaceAll(std::string &str_r, const std::string &from_r, const std::string &to_r)
Replace all occurrences of from_r with to_r in str_r (inplace).
Trim
To define how to trim.
std::string hexencode(const C_Str &str_r)
Encode all characters other than [a-zA-Z0-9] as XX.
std::string & replaceAllFun(std::string &str_r, const std::string &from_r, function< std::string()> to_r)
std::string gsubFun(const std::string &str_r, const std::string &from_r, function< std::string()> to_r)
bool strToFalse(const C_Str &str)
Return false if str is 0, false, no, off, never.
std::string stripFirstWord(std::string &line, const bool ltrim_first)
std::string getline(std::istream &str, const Trim trim_r)
Return stream content up to (but not returning) the next newline.
TriBool strToTriBool(const C_Str &str)
Parse str into a bool if it's a legal true or false string; else indeterminate.
std::string bEscape(std::string str_r, const C_Str &special_r)
Return str_r with '\'-escaped chars occurring in special_r (and '\').
std::string receiveUpTo(std::istream &str, const char delim_r, bool returnDelim_r)
Return stream content up to the next ocurrence of delim_r or EOF delim_r, if found,...
std::string rtrim(const std::string &s)
std::string strerror(int errno_r)
Return string describing the error_r code.
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
std::string toUpper(const std::string &s)
Return uppercase version of s.
std::string ltrim(const std::string &s)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
std::string rxEscapeStr(std::string str_r)
Escape plain STRING str_r for use in a regex (not anchored by "^" or "$").
std::string rxEscapeGlob(std::string str_r)
Escape GLOB str_r for use in a regex (not anchored by "^" or "$").
std::string toLower(const std::string &s)
Return lowercase version of s.
bool strToTrue(const C_Str &str)
Parsing boolean from string.
std::string gsub(const std::string &str_r, const std::string &from_r, const std::string &to_r)
Return a string with all occurrences of from_r replaced with to_r.
std::string trim(const std::string &s, const Trim trim_r)
Easy-to use interface to the ZYPP dependency resolver.
Assert free called for allocated char *.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
#define for_(IT, BEG, END)
Convenient for-loops using iterator.