35 std::string
skip(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
36 "abcdefghijklmnopqrstuvwxyz"
39 size_t beg = 0, len = 0;
42 for(
size_t i=0;
i<
safe.size();
i++)
44 if(
more.find(
safe.at(
i)) != std::string::npos)
53 if(pos != std::string::npos)
63 std::isxdigit(
str.at(pos + 1)) &&
64 std::isxdigit(
str.at(pos + 2)))
66 out.append(
str, pos, 3);
89 size_t pos = 0, end = 0, len = 0;
97 if( pos + 2 < len && out.at(pos) ==
'%')
111 _(
"Encoded string contains a NUL byte")
134 static const char tab[] =
"0123456789ABCDEF";
138 out[1] =
tab[0x0f & (
c >> 4)];
139 out[2] =
tab[0x0f &
c];
142 return std::string(out);
150 if(
hex && std::isxdigit(
hex[0]) && std::isxdigit(
hex[1]))
152 char x[3] = {
hex[0],
hex[1],
'\0'};
153 return 0xff & ::strtol(
x,
NULL, 16);
165 const std::string &
pstr,
166 const std::string &
psep)
168 size_t beg = 0, len = 0;
172 _(
"Invalid parameter array split separator character")
182 if(pos != std::string::npos)
199 const std::string &
str,
200 const std::string &
psep,
201 const std::string &
vsep,
205 ParamVec::const_iterator
pitr;
211 _(
"Invalid parameter map split separator character")
220 if(pos != std::string::npos)
230 k =
pitr->substr(0, pos);
231 v =
pitr->substr(pos + 1);
253 const std::string &
psep)
256 ParamVec::const_iterator
i(
pvec.begin());
261 while( ++
i !=
pvec.end())
274 const std::string &
psep,
275 const std::string &
vsep,
276 const std::string &
safe,
282 _(
"Invalid parameter array join separator character")
293 for(std::string::size_type
i=0;
i<
safe.size();
i++)
295 if(
psep.find(
safe[
i]) == std::string::npos ) {
296 if (
vsep.find(
safe[
i]) == std::string::npos ) {
305 ParamMap::const_iterator
i(
pmap.begin());
310 if( !
i->second.empty())
313 while( ++
i !=
pmap.end())
316 if( !
i->second.empty())
323 for (
const auto & [
k,
v] :
pmap ) {
327 if (
not v.empty() ) {
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Thrown if the encoded string contains a NUL byte (%00).
String related utilities and Regular expression matching.
std::string encode(const std::string &str, const std::string &safe, EEncoding eflag)
Encodes a string using URL percent encoding.
int decode_octet(const char *hex)
Decode one character.
std::vector< std::string > ParamVec
A parameter vector container.
std::string encode_octet(const unsigned char c)
Encode one character.
void split(ParamVec &pvec, const std::string &pstr, const std::string &psep)
Split into a parameter vector.
std::string join(const ParamVec &pvec, const std::string &psep)
Join parameter vector to a string.
std::map< std::string, std::string > ParamMap
A parameter map container.
@ E_DECODED
Flag to request decoded string(s).
@ E_ENCODED
Flag to request encoded string(s).
std::string decode(const std::string &str, bool allowNUL)
Decodes a URL percent encoded string.
Easy-to use interface to the ZYPP dependency resolver.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
#define URL_SAFE_CHARS
Characters that are safe for URL without percent-encoding.