25#include <zypp/base/String.h>
53 KVMapPolicy(
const std::string & kvsplit_r,
const std::string & fsplit_r )
59 KVMapPolicy(
const std::string & kvsplit_r,
const std::string & fsplit_r,
60 const std::string & kvjoin_r )
66 KVMapPolicy(
const std::string & kvsplit_r,
const std::string & fsplit_r,
67 const std::string & kvjoin_r,
const std::string & fjoin_r )
81 struct KVMapBase :
public std::map<std::string,std::string> {
86 typedef std::map<std::string,std::string>
map_type;
91 :
std::map<
std::string,
std::string>( kvmap_r )
97 bool has(
const std::string & key_r )
const {
98 return( find( key_r ) != end() );
104 template<
char kv,
char f>
116 std::vector<std::string> fields;
119 for (
unsigned i = 0; i < fields.size(); ++i ) {
120 std::string::size_type pos = fields[i].find( opts_r.
_kvsplit );
121 if ( pos == std::string::npos ) {
124 ret[fields[i].substr( 0, pos )] = fields[i].substr( pos+1 );
139 for ( map_type::const_iterator it = kvmap_r.begin(); it != kvmap_r.end(); ++it ) {
140 if ( ! ret.empty() ) {
144 if ( !it->second.empty() ) {
145 ret += opts_r.
_kvjoin + it->second;
172 template<
typename KVMapOpts>
190 return join( *
this, KVMapOpts() );
197 template<
typename KVMapOpts>
String related utilities and Regular expression matching.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
A map of (key,value) strings.
std::string asString() const
KVMap(const map_type &map_r)
KVMap(const std::string &str_r)
KVMapPolicy for KVMaps using a single char as separator (e.g.
Base class for KVMaps, (key,value) pairs.
bool has(const std::string &key_r) const
Test whether key is set.
KVMapBase(const map_type &kvmap_r)
static map_type split(const std::string &str_r, const KVMapPolicy &opts_r)
Split str_r into (key,value) map, using the separators defined by opts_r.
std::map< std::string, std::string > map_type
(key,value) map type
static std::string join(const map_type &kvmap_r, const KVMapPolicy &opts_r)
Join (key,value) map into string, using the separators defined by opts_r.
KVMapPolicy for conversion of KVMaps to/from string.
KVMapPolicy(const std::string &kvsplit_r, const std::string &fsplit_r, const std::string &kvjoin_r)
KVMapPolicy(const std::string &kvsplit_r, const std::string &fsplit_r, const std::string &kvjoin_r, const std::string &fjoin_r)
KVMapPolicy(const std::string &kvsplit_r, const std::string &fsplit_r)