20 #undef ZYPP_BASE_LOGGER_LOGGROUP
21 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::plugin"
38 Impl(
const std::string & command_r )
41 Impl(
const std::string & command_r,
const std::string & body_r )
52 Impl( std::istream & stream_r );
63 if ( command_r.find(
'\n' ) != std::string::npos )
68 const std::string &
body()
const
74 void setBody(
const std::string & body_r )
79 typedef std::pair<HeaderList::iterator,HeaderList::iterator>
KeyRange;
87 const std::string &
getHeader(
const std::string & key_r )
const
90 if ( r.first == r.second )
92 const std::string & ret( r.first->second );
93 if ( ++r.first != r.second )
98 const std::string &
getHeader(
const std::string & key_r,
const std::string & default_r )
const
101 if ( r.first == r.second )
103 const std::string & ret( r.first->second );
104 if ( ++r.first != r.second )
109 const std::string &
getHeaderNT(
const std::string & key_r,
const std::string & default_r )
const
112 return iter !=
_header.end() ? iter->second : default_r;
115 HeaderList::value_type
mkHeaderPair(
const std::string & key_r,
const std::string & value_r )
117 if ( key_r.find_first_of(
":\n" ) != std::string::npos )
119 if ( value_r.find_first_of(
"\n" ) != std::string::npos )
121 return HeaderList::value_type( key_r, value_r );
124 void setHeader(
const std::string & key_r,
const std::string & value_r )
130 void addHeader(
const std::string & key_r,
const std::string & value_r )
137 for (
const auto & el : contents_r )
147 std::ostream &
writeTo( std::ostream & stream_r )
const;
158 static shared_ptr<Impl> _nullimpl(
new Impl );
162 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
165 {
return new Impl( *
this ); }
172 return str <<
"PluginFrame[" << obj.
command() <<
"](" << obj.
headerList().size() <<
"){" << obj.
body().size() <<
"}";
190 if ( ! stream_r.good() )
196 if ( ! stream_r.good() )
203 if ( sep == std::string::npos )
206 _header.insert( HeaderList::value_type( data.substr(0,sep), data.substr(sep+1) ) );
211 if ( ! stream_r.good() )
222 stream_r << _command << endl;
224 for_( it, _header.begin(), _header.end() )
225 stream_r << it->first <<
':' << it->second << endl;
243 static std::string _val(
"ACK" );
249 static std::string _val(
"ERROR" );
255 static std::string _val(
"_ENOMETHOD" );
264 : _pimpl( new
Impl( command_r ) )
268 : _pimpl( new
Impl( command_r, body_r ) )
272 : _pimpl( new
Impl( command_r, contents_r ) )
276 : _pimpl( new
Impl( command_r, body_r, contents_r ) )
280 : _pimpl( new
Impl( stream_r ) )
334 {
return str << *obj.
_pimpl; }