{
std::string _name;
std::string _summary;
+ std::string _repository;
std::string _product;
DefaultIntegral<bool,false> _notify;
std::string _status;
: _pimpl( allocated_r ? allocated_r : new Impl )
{}
- std::string ProductFileData::Upgrade::name() const { return _pimpl->_name; }
- std::string ProductFileData::Upgrade::summary() const { return _pimpl->_summary; }
- std::string ProductFileData::Upgrade::product() const { return _pimpl->_product; }
- bool ProductFileData::Upgrade::notify() const { return _pimpl->_notify; }
- std::string ProductFileData::Upgrade::status() const { return _pimpl->_status; }
+ std::string ProductFileData::Upgrade::name() const { return _pimpl->_name; }
+ std::string ProductFileData::Upgrade::summary() const { return _pimpl->_summary; }
+ std::string ProductFileData::Upgrade::repository() const { return _pimpl->_repository; }
+ std::string ProductFileData::Upgrade::product() const { return _pimpl->_product; }
+ bool ProductFileData::Upgrade::notify() const { return _pimpl->_notify; }
+ std::string ProductFileData::Upgrade::status() const { return _pimpl->_status; }
/////////////////////////////////////////////////////////////////
//
Edition _edition;
Arch _arch;
+ std::string _shortName;
+ std::string _summary;
+
std::string _productline;
std::string _registerTarget;
std::string _registerRelease;
Edition ProductFileData::edition() const { return _pimpl->_edition; }
Arch ProductFileData::arch() const { return _pimpl->_arch; }
+ std::string ProductFileData::shortName() const { return _pimpl->_shortName; }
+ std::string ProductFileData::summary() const { return _pimpl->_summary; }
+
std::string ProductFileData::productline() const { return _pimpl->_productline; }
std::string ProductFileData::registerTarget() const { return _pimpl->_registerTarget; }
std::string ProductFileData::registerRelease() const { return _pimpl->_registerRelease; }
std::ostream & operator<<( std::ostream & str, const ProductFileData::Upgrade & obj )
{
- str << str::form( "|upgrade|%s|",
- obj.name().c_str() );
+ str << str::form( "|upgrade|%s|%s|%s|%s|%s|",
+ obj.name().c_str(),
+ obj.repository().c_str(),
+ obj.product().c_str(),
+ obj.status().c_str(),
+ (obj.notify() ? "notify" : "noNotify") );
return str;
}
/////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////
- /** Assign types constructible from \c char* */
- template <class _Val>
- struct ConsumeVal : public xml::ParseDefConsume
- {
- ConsumeVal( _Val & value_r )
- : _value( &value_r )
- {}
-
- virtual void text( const xml::Node & node_r )
- {
- *_value = _Val( node_r.value().c_str() );
- }
-
- private:
- _Val * _value;
- };
-
- template <class _Val>
- shared_ptr<xml::ParseDefConsume> consumeVal( _Val & value_r )
- { return shared_ptr<xml::ParseDefConsume>( new ConsumeVal<_Val>( value_r ) ); }
-
- /////////////////////////////////////////////////////////////////
-
- struct ProductNode : public xml::ParseDef, public xml::ParseDefConsume
+ struct ProductNode : public xml::ParseDef
{
ProductNode( ProductFileData::Impl & pdata_r )
: ParseDef( "product", MANDTAORY )
, _pdata( pdata_r )
{
(*this)
- ("vendor", OPTIONAL, consumeVal( _pdata._vendor ) )
- ("name", MANDTAORY, consumeVal( _pdata._name ) )
- ("version", OPTIONAL, consumeVal( _version ) )
- ("release", OPTIONAL, consumeVal( _release ) )
- ("arch", OPTIONAL, consumeVal( _pdata._arch ) )
- ("productline", OPTIONAL, consumeVal( _pdata._productline ) )
+ ("vendor", OPTIONAL, xml::parseDefAssign( _pdata._vendor ) )
+ ("name", MANDTAORY, xml::parseDefAssign( _pdata._name ) )
+ ("version", MANDTAORY, xml::parseDefAssign( _version ) )
+ ("release", MANDTAORY, xml::parseDefAssign( _release ) )
+ ("arch", MANDTAORY, xml::parseDefAssign( _pdata._arch ) )
+ ("shortsummary", OPTIONAL, xml::parseDefAssign( _pdata._shortName ) )
+ ("summary", MULTIPLE_OPTIONAL, xml::parseDefAssign( _ttext )( "lang", _tlocale )
+ >>bind( &ProductNode::doneLocalizedDefault, this, _1, boost::ref(_pdata._summary) ))
+ ("productline", OPTIONAL, xml::parseDefAssign( _pdata._productline ) )
("register", OPTIONAL)
- ("updaterepokey", OPTIONAL, consumeVal( _pdata._updaterepokey ) )
+ ("updaterepokey", OPTIONAL, xml::parseDefAssign( _pdata._updaterepokey ) )
("upgrades", OPTIONAL)
;
(*this)["register"]
- ("target", OPTIONAL, consumeVal( _pdata._registerTarget ) )
- ("release", OPTIONAL, consumeVal( _pdata._registerRelease ) )
+ ("target", OPTIONAL, xml::parseDefAssign( _pdata._registerTarget ) )
+ ("release", OPTIONAL, xml::parseDefAssign( _pdata._registerRelease ) )
;
(*this)["upgrades"]
- ("upgrade", MULTIPLE_OPTIONAL)
+ ("upgrade", MULTIPLE_OPTIONAL, xml::parseDefAssign()
+ >> bind( &ProductNode::doneUpgrade, this, _1 ))
;
(*this)["upgrades"]["upgrade"]
- ("name", OPTIONAL, consumeVal( _upgrade._name ) )
- ("summary", OPTIONAL, consumeVal( _upgrade._summary ) )
- ("repository", OPTIONAL, consumeVal( _upgrade._product ) )
- ("notify", OPTIONAL) // need consume to bool!
- ("status", OPTIONAL, consumeVal( _upgrade._status ) )
+ ("name", OPTIONAL, xml::parseDefAssign( _upgrade._name ) )
+ ("summary", OPTIONAL, xml::parseDefAssign( _upgrade._summary ) )
+ ("repository", OPTIONAL, xml::parseDefAssign( _upgrade._repository ) )
+ ("product", OPTIONAL, xml::parseDefAssign( _upgrade._product ) )
+ ("notify", OPTIONAL, xml::parseDefAssign( _upgrade._notify ) )
+ ("status", OPTIONAL, xml::parseDefAssign( _upgrade._status ) )
;
- // not a clean way to collect the END_ELEMENT calls, but
- // works for this case. NEEDS CLEANUP!
- setConsumer( *this );
- (*this)["upgrades"].setConsumer( *this );
- }
-
- virtual void done ( const xml::Node & _node )
- {
- //SEC << "DONE.... " << _node.localName() << endl;
- if ( _node.localName() == name() )
- {
- // this END node
- _pdata._edition = Edition( _version, _release );
- }
- else if ( _node.localName() == "upgrade" )
- {
- // collect upgrade
- ProductFileData::Upgrade cdata( new ProductFileData::Upgrade::Impl( _upgrade ) );
- _pdata._upgrades.push_back( cdata );
- }
- }
-
- ProductFileData::Impl & _pdata;
-
- std::string _version;
- std::string _release;
-
- ProductFileData::Upgrade::Impl _upgrade;
+ // </product> callback to build edition.
+ setConsumer( xml::parseDefAssign() >> bind( &ProductNode::done, this, _1 ) );
+ // xml::ParseDef::_debug = true;
+ }
+
+ /** collect _upgrade */
+ void doneUpgrade( const xml::Node & _node )
+ {
+ ProductFileData::Upgrade cdata( new ProductFileData::Upgrade::Impl( _upgrade ) );
+ _pdata._upgrades.push_back( cdata );
+ _upgrade = ProductFileData::Upgrade::Impl();
+ }
+ /** collect localized data */
+ void doneLocalizedDefault( const xml::Node & _node, std::string & store_r )
+ {
+ // take 1st or default
+ if ( store_r.empty() || _tlocale.empty() )
+ store_r = _ttext;
+ }
+
+ /** finaly */
+ void done( const xml::Node & _node )
+ {
+ _pdata._edition = Edition( _version, _release );
+ }
+
+ private:
+ ProductFileData::Impl & _pdata;
+
+ std::string _version;
+ std::string _release;
+
+ std::string _ttext;
+ std::string _tlocale;
+
+ ProductFileData::Upgrade::Impl _upgrade;
};
bool ProductFileReader::parse( const InputStream & input_r ) const
try
{
- //xml::ParseDef::_debug = true;
xml::Reader reader( input_r );
ProductNode rootNode( *pdataImpl );
rootNode.take( reader );
{
if ( ! PathInfo( file_r ).isFile() )
{
- WAR << "scanFile " << PathInfo( file_r ) << " is no t a file." << endl;
+ WAR << "scanFile " << PathInfo( file_r ) << " is not a file." << endl;
return ProductFileData();
}