13#include <zypp/base/Logger.h>
37 inline std::string attrIf(
const std::string & tag_r,
38 const std::string & value_r )
41 if ( ! value_r.empty() )
64 std::ostream &
writeXml( std::ostream &
str )
const;
76 static shared_ptr<Impl> _nullimpl(
new Impl );
81 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
84 {
return new Impl( *
this ); }
96 str <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
97 str <<
"<syscontent>\n";
100 str <<
" <name>" <<
_name <<
"</name>\n";
108 str <<
" </ident>\n";
114 << attrIf(
"kind", (*it)->kind().asString() )
115 << attrIf(
"name", (*it)->name() )
117 << attrIf(
"ver", (*it)->edition().version() )
118 << attrIf(
"rel", (*it)->edition().release() )
119 << attrIf(
"arch", (*it)->arch().asString() )
122 str <<
" </onsys>\n";
124 str <<
"</syscontent>" << endl;
142 {
_pimpl->_name = val_r;
return *
this; }
145 {
return _pimpl->_edition; }
148 {
_pimpl->_edition = val_r;
return *
this; }
151 {
return _pimpl->_description; }
154 {
_pimpl->_description = val_r;
return *
this; }
174 {
_pimpl->_onsys.insert( obj_r ); }
177 {
return _pimpl->_onsys.empty(); }
180 {
return _pimpl->_onsys.size(); }
183 {
return _pimpl->_onsys.begin(); }
186 {
return _pimpl->_onsys.end(); }
215 Reader::Entry::Entry(
const shared_ptr<Impl> & pimpl_r )
219 const std::string & Reader::Entry::kind()
const
222 const std::string & Reader::Entry::name()
const
225 const Edition & Reader::Entry::edition()
const
226 {
return _pimpl->_edition; }
228 const Arch & Reader::Entry::arch()
const
242 Impl( std::istream & input_r );
261 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
264 {
return new Impl( *
this ); }
275 struct SycontentNode :
public ParseDef
277 SycontentNode( Mode mode_r )
278 : ParseDef(
"syscontent", mode_r )
280 (*this)(
"ident", OPTIONAL)
286 (
"version", OPTIONAL)
287 (
"description", OPTIONAL)
288 (
"created", OPTIONAL)
292 (
"entry", MULTIPLE_OPTIONAL)
298 struct ConsumeEdition :
public ParseDefConsume
300 ConsumeEdition( Edition & value_r )
304 virtual void start(
const Node & node_r )
306 *
_value = Edition( node_r.getAttribute(
"ver").asString(),
307 node_r.getAttribute(
"rel").asString(),
308 node_r.getAttribute(
"epoch").asString() );
315 struct ConsumeString :
public ParseDefConsume
317 ConsumeString( std::string & value_r )
321 virtual void text(
const Node & node_r )
323 *
_value = node_r.value().asString();
330 struct ConsumeDate :
public ParseDefConsume
332 ConsumeDate( Date & value_r )
336 virtual void text(
const Node & node_r )
338 *
_value = Date(node_r.value().asString());
345 struct ConsumeEntries :
public ParseDefConsume
347 ConsumeEntries( std::list<Reader::Entry> & value_r )
351 virtual void start(
const Node & node_r )
355 centry->_kind = node_r.getAttribute(
"kind").asString();
356 centry->_name = node_r.getAttribute(
"name").asString();
357 centry->_edition = Edition( node_r.getAttribute(
"ver").asString(),
358 node_r.getAttribute(
"rel").asString(),
359 node_r.getAttribute(
"epoch").asString() );
360 centry->_arch = Arch( node_r.getAttribute(
"arch").asString() );
362 _value->push_back( Reader::Entry( centry ) );
365 std::list<Reader::Entry> *
_value;
377 Reader::Impl::Impl( std::istream & input_r )
379 xml::Reader reader( input_r );
382 rootNode[
"ident"][
"name"].setConsumer
383 (
new ConsumeString( _name ) );
385 rootNode[
"ident"][
"version"].setConsumer
386 (
new ConsumeEdition( _edition ) );
388 rootNode[
"ident"][
"description"].setConsumer
389 (
new ConsumeString( _description ) );
391 rootNode[
"ident"][
"created"].setConsumer
392 (
new ConsumeDate( _created ) );
394 rootNode[
"onsys"][
"entry"].setConsumer
395 (
new ConsumeEntries( _content ) );
398 rootNode.take( reader );
412 : _pimpl( new
Impl( input_r ) )
416 {
return _pimpl->_name; }
419 {
return _pimpl->_edition; }
421 const std::string & Reader::description()
const
422 {
return _pimpl->_description; }
424 const Date & Reader::ctime()
const
425 {
return _pimpl->_created; }
427 bool Reader::empty()
const
428 {
return _pimpl->_content.empty(); }
431 {
return _pimpl->_content.size(); }
434 {
return _pimpl->_content.begin(); }
437 {
return _pimpl->_content.end(); }
446 return str <<
"syscontent(" << obj.name() <<
"-" << obj.edition()
447 <<
", " << obj.size() <<
" entries"
448 <<
", created " << obj.ctime()
RepoManager implementation.
Store and operate on date (time_t).
std::string asSeconds() const
Convert to string representation of calendar time in numeric form (like "1029255142").
static Date now()
Return the current time.
Edition represents [epoch:]version[-release]
std::string version() const
Version.
std::string release() const
Release.
epoch_t epoch() const
Epoch.
Combining sat::Solvable and ResStatus.
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
ResStatus & status() const
Returns the current status.
TraitsType::constPtrType constPtr
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Impl * clone() const
clone for RWCOW_pointer
std::list< Entry > _content
StorageT::const_iterator const_iterator
StorageT::size_type size_type
RWCOW_pointer< Impl > _pimpl
const std::string & name() const
Get name.
Impl * clone() const
clone for RWCOW_pointer
static shared_ptr< Impl > nullimpl()
Offer default Impl.
std::ostream & writeXml(std::ostream &str) const
Collect and serialize a set of ResObject.
const Edition & edition() const
Get edition.
std::ostream & writeXml(std::ostream &str) const
Write collected data as XML.
std::set< ResObject::constPtr > StorageT
const std::string & description() const
Get description.
void addIf(const PoolItem &obj_r)
Collect PoolItem if it stays on the system.
StorageT::iterator iterator
RWCOW_pointer< Impl > _pimpl
void addInstalled(const PoolItem &obj_r)
Collect currently installed PoolItem.
const_iterator begin() const
Iterator to the begin of collected data.
StorageT::const_iterator const_iterator
bool empty() const
Whether no data collected so far.
size_type size() const
Number of items collected.
void add(const ResObject::constPtr &obj_r)
Unconditionally add this ResObject (or PoolItem).
const std::string & name() const
Get name.
StorageT::size_type size_type
const_iterator end() const
Iterator to the end of collected data.
xmlTextReader based interface to iterate xml streams.
Reader(const InputStream &stream_r, const Validate &validate_r=Validate::none())
Ctor.
String related utilities and Regular expression matching.
std::string numstring(char n, int w=0)
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
Easy-to use interface to the ZYPP dependency resolver.