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";
106 str <<
" <description>" <<
_description <<
"</description>\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(); }
189 {
return _pimpl->writeXml( str ); }
226 {
return _pimpl->_edition; }
242 Impl( std::istream & input_r );
256 static shared_ptr<Impl> _nullimpl(
new Impl );
261 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
264 {
return new Impl( *
this ); }
275 struct SycontentNode :
public ParseDef
277 SycontentNode( Mode 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 = 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;
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 ) )
415 const std::string & Reader::name()
const
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()
RWCOW_pointer< Impl > _pimpl
std::set< ResObject::constPtr > StorageT
StorageT::iterator iterator
Define a xml node structure to parse.
Reader(const InputStream &stream_r, const Validate &validate_r=Validate::none())
Ctor.
StorageT::size_type size_type
std::ostream & writeXml(std::ostream &str) const
Write collected data as XML.
std::string release() const
Release.
void addIf(const PoolItem &obj_r)
Collect PoolItem if it stays on the system.
StorageT::size_type size_type
static shared_ptr< Impl > nullimpl()
Offer default Impl.
const std::string & name() const
Get name.
Edition represents [epoch:]version[-release]
TraitsType::constPtrType constPtr
RWCOW_pointer< Impl > _pimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
bool empty() const
Whether no data collected so far.
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
Store and operate on date (time_t).
const_iterator begin() const
Iterator to the begin of collected data.
const Edition & edition() const
Get edition.
const Edition & edition() const
epoch_t epoch() const
Epoch.
std::string version() const
Version.
ResStatus & status() const
Returns the current status.
StorageT::const_iterator const_iterator
const Arch & arch() const
std::string numstring(char n, int w=0)
StorageT::const_iterator const_iterator
void addInstalled(const PoolItem &obj_r)
Collect currently installed PoolItem.
std::list< Entry > _content
size_type size() const
Number of items collected.
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
static Date now()
Return the current time.
const_iterator end() const
Iterator to the end of collected data.
std::string asSeconds() const
Convert to string representation of calendar time in numeric form (like "1029255142").
Impl * clone() const
clone for RWCOW_pointer
const std::string & kind() const
std::ostream & writeXml(std::ostream &str) const
Reference to a PoolItem connecting ResObject and ResStatus.
void add(const ResObject::constPtr &obj_r)
Unconditionally add this ResObject (or PoolItem).
const std::string & description() const
Get description.
const std::string & name() const
Impl * clone() const
clone for RWCOW_pointer
xmlTextReader based interface to iterate xml streams.
Collect and serialize a set of ResObject.