56 KVMapPolicy(
const std::string & kvsplit_r,
const std::string & fsplit_r )
62 KVMapPolicy(
const std::string & kvsplit_r,
const std::string & fsplit_r,
63 const std::string & kvjoin_r )
69 KVMapPolicy(
const std::string & kvsplit_r,
const std::string & fsplit_r,
70 const std::string & kvjoin_r,
const std::string & fjoin_r )
84 struct KVMapBase :
public std::map<std::string,std::string> {
89 typedef std::map<std::string,std::string>
map_type;
94 : std::map<std::string,std::string>( kvmap_r )
100 bool has(
const std::string & key_r )
const {
101 return( find( key_r ) != end() );
107 template<
char kv,
char f>
119 std::vector<std::string> fields;
122 for (
unsigned i = 0; i < fields.size(); ++i ) {
124 if ( pos == std::string::npos ) {
127 ret[fields[i].substr( 0, pos )] = fields[i].substr( pos+1 );
142 for ( map_type::const_iterator it = kvmap_r.begin(); it != kvmap_r.end(); ++it ) {
143 if ( ! ret.empty() ) {
147 if ( !it->second.empty() ) {
148 ret += opts_r.
_kvjoin + it->second;
175 template<
typename KVMapOpts>
193 return join( *
this, KVMapOpts() );
200 template<
typename KVMapOpts>
201 std::ostream & operator<<( std::ostream & str, const KVMap<KVMapOpts> & obj )
202 {
return str << obj.asString(); }
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.
unsigned split(const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=" \t")
Split line_r into words.
KVMap(const std::string &str_r)
Base class for KVMaps, (key,value) pairs.
KVMapPolicy(const std::string &kvsplit_r, const std::string &fsplit_r, const std::string &kvjoin_r, const std::string &fjoin_r)
std::map< std::string, std::string > map_type
(key,value) map type
KVMapPolicy for KVMaps using a single char as separator (e.g.
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.
KVMapPolicy(const std::string &kvsplit_r, const std::string &fsplit_r, const std::string &kvjoin_r)
KVMapBase(const map_type &kvmap_r)
KVMap(const map_type &map_r)
KVMapPolicy(const std::string &kvsplit_r, const std::string &fsplit_r)
A map of (key,value) strings.
KVMapPolicy for conversion of KVMaps to/from string.
std::string asString() const
bool has(const std::string &key_r) const
Test whether key is set.