repo/cached/PackageImpl.cc
repo/cached/PatchImpl.cc
repo/cached/PatternImpl.cc
+ repo/cached/ProductImpl.cc
)
SET( zypp_repository_cached_HEADERS
repo/cached/PackageImpl.h
repo/cached/PatchImpl.h
repo/cached/PatternImpl.h
+ repo/cached/ProductImpl.h
)
SET( zypp_repository_data_SRCS
///////////////////////////////////////////////////////////////////
namespace str
{ /////////////////////////////////////////////////////////////////
-
+ template<>
+ std::string asString( const std::string &t )
+ {
+ return t;
+ }
+
/******************************************************************
**
** FUNCTION NAME : form
{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
+ /**
+ * Global asString() that works with std::string too
+ */
+ template<class _T>
+ std::string asString( const _T &t )
+ {
+ return t.asString();
+ }
+
+ template<>
+ std::string asString( const std::string &t );
+
+ ///////////////////////////////////////////////////////////////////
/** Printf style construction of std::string. */
std::string form( const char * format, ... )
__attribute__ ((format (printf, 1, 2)));
{
if ( iter != begin )
res += sep_r;
- res += *iter;
+ res += asString(*iter);
}
return res;
}
#include "zypp/base/Measure.h"
#include "zypp/ZYppFactory.h"
#include "zypp/ZYpp.h"
-#include "zypp/ZConfig.h"
#include "zypp/Package.h"
#include "zypp/cache/CacheInitializer.h"
#include "zypp/cache/CacheStore.h"
appendStringAttribute( pkgid, "Package", "postin", package->postin );
appendStringAttribute( pkgid, "Package", "preun", package->preun );
appendStringAttribute( pkgid, "Package", "postun", package->postun );
- appendStringContainerAttribute( pkgid, "Package", "keywords", package->keywords );
- appendStringContainerAttribute( pkgid, "Package", "authors", package->authors );
+ appendStringContainerAttribute( pkgid, "Package", "keywords", package->keywords.begin(), package->keywords.end() );
+ appendStringContainerAttribute( pkgid, "Package", "authors", package->authors.begin(), package->authors.end() );
appendStringAttribute( pkgid, "Package", "location", package->repositoryLocation.filePath.asString() );
}
appendTranslatedStringAttribute( id, "Product", "shortName", product->shortName );
appendTranslatedStringAttribute( id, "Product", "longName", product->longName );
- appendStringContainerAttribute( id, "Product", "flags", product->flags );
+ appendStringContainerAttribute( id, "Product", "flags", product->flags.begin(), product->flags.end() );
appendStringAttribute( id, "Pattern", "releasenotesUrl", product->releasenotesUrl.asString() );
//! \todo figure out how to store list of Urls. A separate method appendUrlContainerAttribute? Or change it to plain string in ResolvableData.h?
// appendStringContainerAttribute( id, "Product", "updateUrls", product->updateUrls );
_pimpl->append_text_attribute_cmd->executenonquery();
}
-template <class _Container>
-void CacheStore::appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const _Container &cont )
-{
- // don't bother with writing if the container is empty
- if (cont.empty()) return;
-
- string value = str::join(cont, ZConfig().cacheDBSplitJoinSeparator());
-
- appendStringAttribute( resolvable_id, klass, name, value );
-}
-
-template
-void CacheStore::appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const std::set<std::string> &cont );
-template
-void CacheStore::appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const std::list<std::string> &cont );
-template
- void CacheStore::appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const Package::Keywords &cont );
-
-
-
}
}
#include "zypp/base/PtrTypes.h"
#include "zypp/Pathname.h"
#include "zypp/NVRA.h"
+#include "zypp/ZConfig.h"
#include "zypp/capability/CapabilityImpl.h"
#include "zypp/capability/Capabilities.h"
/**
- * Append strings from _Container to a resolvable.
- * Uses \ref zypp::str::split(_Container, std::string) with
+ * Append strings from _Iterator to a resolvable.
+ *
+ * Uses \ref zypp::str::split(_Iterator,_Iterator, std::string) with
* \ref ZConfig::cacheDBSplitJoinSeparator() as the second argument
* (a separator string) of split().
- *
+ *
+ * Any container of any class providing asString() can be used.
+ *
* \param resolvable_id Resovable Id, owner of the attribute
* \param klass Type class i.e "Package" "lang" "kind"
* \param name Type name i.e : "summary" "none" "Script"
- * \param cont The string container.
+ * \param begin begin Iterator to the container
+ * \param end end Iterator to the container
*/
- template <class _Container>
+ template <class _Iterator>
void appendStringContainerAttribute( const data::RecordId &resolvable_id,
const std::string &klass,
const std::string &name,
- const _Container &cont );
+ _Iterator begin,
+ _Iterator end )
+ {
+ std::string value = str::join(begin, end, ZConfig().cacheDBSplitJoinSeparator());
+ appendStringAttribute( resolvable_id, klass, name, value );
+ }
/**
* Update a known repository checksum and timestamp
return ( queryNumericAttributeInternal( con, record_id, klass, name) != 0 );
}
- template <class _Container> _Container
- queryStringContainerAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
- {
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- string all = queryStringAttributeInternal( con, record_id, klass, name);
- _Container words;
-
- //
- str::split( all, std::inserter(words, words.begin()) );
- return words;
- }
-
-
int queryNumericAttribute( const data::RecordId &record_id,
const std::string &klass,
const std::string &name )
return _pimpl->queryTranslatedStringAttribute(record_id, klass, name);
}
-template<class _Container>
-_Container ResolvableQuery::queryStringContainerAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
-{
- return _pimpl->queryStringContainerAttribute<_Container>(record_id, klass, name);
-}
-
-template
-std::set<std::string> ResolvableQuery::queryStringContainerAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name );
-
-template
-std::list<std::string> ResolvableQuery::queryStringContainerAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name );
-
-template
-Package::Keywords ResolvableQuery::queryStringContainerAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name );
-
//////////////////////////////////////////////////////////////////////////////
} } // namespace zypp::cache
* \return the attribute or a empty
* \ref _Container if no record is found.
*/
- template<class _Container>
- _Container queryStringContainerAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name );
+ template<class _OutputIterator>
+ void queryStringContainerAttribute( const data::RecordId &record_id,
+ const std::string &klass,
+ const std::string &name,
+ _OutputIterator result )
+ {
+
+ std::string all = queryStringAttribute( record_id, klass, name);
+ //FIXME use zypp separator
+ str::split( all, result );
+ }
std::string ProductImplIf::category() const
{ return std::string(); }
- /** Get the vendor of the product */
- Label ProductImplIf::vendor() const
- { return Label(); }
-
Url ProductImplIf::releaseNotesUrl() const
{ return Url(); }
/** Get the category of the product - addon or base*/
virtual std::string category() const PURE_VIRTUAL;
- /** Get the vendor of the product */
- virtual Label vendor() const PURE_VIRTUAL;
-
virtual Url releaseNotesUrl() const PURE_VIRTUAL;
virtual std::list<Url> updateUrls() const PURE_VIRTUAL;
PackageImpl::Keywords PackageImpl::keywords() const
{
- return _repository->resolvableQuery().queryStringContainerAttribute< PackageImpl::Keywords >( _id, "Package", "keywords" );
+ PackageImpl::Keywords keywords;
+ _repository->resolvableQuery().queryStringContainerAttribute( _id, "Package", "keywords", std::inserter(keywords, keywords.begin()) );
+ return keywords;
}
Changelog PackageImpl::changelog() const
list<string> PackageImpl::authors() const
{
- return _repository->resolvableQuery().queryStringContainerAttribute< list<string> >( _id, "Package", "authors" );
+ list<string> authors;
+ _repository->resolvableQuery().queryStringContainerAttribute( _id, "Package", "authors", back_inserter(authors) );
+ return authors;
}
std::list<std::string> PackageImpl::filenames() const
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#include "zypp/TranslatedText.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Logger.h"
+#include "zypp/repo/RepositoryImpl.h"
+#include "ProductImpl.h"
+
+
+using namespace std;
+using namespace zypp::detail;
+using namespace::zypp::repo;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp { namespace repo { namespace cached {
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : ProductImpl
+//
+///////////////////////////////////////////////////////////////////
+
+/** Default ctor
+*/
+ProductImpl::ProductImpl (const data::RecordId &id, cached::RepoImpl::Ptr repository_r)
+ : _repository (repository_r),
+ _id(id)
+{}
+
+Repository
+ProductImpl::repository() const
+{
+ return _repository->selfRepository();
+}
+
+///////////////////////////////////////////////////
+// ResObject Attributes
+///////////////////////////////////////////////////
+
+TranslatedText ProductImpl::summary() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "summary" );
+}
+
+TranslatedText ProductImpl::description() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "description" );
+}
+
+TranslatedText ProductImpl::insnotify() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "insnotify" );
+}
+
+TranslatedText ProductImpl::delnotify() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "delnotify" );
+}
+
+TranslatedText ProductImpl::licenseToConfirm() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "licenseToConfirm" );
+}
+
+Vendor ProductImpl::vendor() const
+{
+ return _repository->resolvableQuery().queryStringAttribute( _id, "ResObject", "vendor" );
+}
+
+
+ByteCount ProductImpl::size() const
+{
+ return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "size" );
+}
+
+ByteCount ProductImpl::archivesize() const
+{
+ return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "archivesize" );
+}
+
+bool ProductImpl::installOnly() const
+{
+ return _repository->resolvableQuery().queryBooleanAttribute( _id, "ResObject", "installOnly" );
+}
+
+Date ProductImpl::buildtime() const
+{
+ return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "buildtime" );
+}
+
+Date ProductImpl::installtime() const
+{
+ return Date();
+}
+
+//////////////////////////////////////////
+// DEPRECATED
+//////////////////////////////////////////
+
+Source_Ref ProductImpl::source() const
+{
+ return Source_Ref::noSource;
+}
+
+unsigned ProductImpl::sourceMediaNr() const
+{
+ return 1;
+}
+
+//////////////////////////////////////////
+// PRODUCT
+/////////////////////////////////////////
+
+std::string ProductImpl::category() const
+{
+ return _repository->resolvableQuery().queryStringAttribute( _id, "Product", "category" );
+}
+
+Url ProductImpl::releaseNotesUrl() const
+{
+ return _repository->resolvableQuery().queryStringAttribute( _id, "Product", "releaseNotesUrl" );
+}
+
+std::list<Url> ProductImpl::updateUrls() const
+{
+ std::list<Url> urls;
+ _repository->resolvableQuery().queryStringContainerAttribute( _id, "Product", "updateUrls", back_inserter(urls) );
+ return urls;
+}
+
+std::list<Url> ProductImpl::extraUrls() const
+{
+ std::list<Url> urls;
+ _repository->resolvableQuery().queryStringContainerAttribute( _id, "Product", "extraUrls", back_inserter(urls) );
+ return urls;
+}
+
+std::list<Url> ProductImpl::optionalUrls() const
+{
+ std::list<Url> urls;
+ _repository->resolvableQuery().queryStringContainerAttribute( _id, "Product", "optionalUrls", back_inserter(urls) );
+ return urls;
+}
+
+list<string> ProductImpl::flags() const
+{
+ list<string> flags;
+ _repository->resolvableQuery().queryStringContainerAttribute( _id, "Product", "flags", back_inserter(flags) );
+ return flags;
+}
+
+TranslatedText ProductImpl::shortName() const
+{
+ return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "Product", "shortName" );
+}
+
+std::string ProductImpl::distributionName() const
+{
+ return _repository->resolvableQuery().queryStringAttribute( _id, "Product", "distributionName" );
+}
+
+Edition ProductImpl::distributionEdition() const
+{
+ return _repository->resolvableQuery().queryStringAttribute( _id, "Product", "distributionEdition" );
+}
+
+/////////////////////////////////////////////////////////////////
+} } } // namespace zypp::repo::cached
+///////////////////////////////////////////////////////////////////
+
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef zypp_repo_cached_ProductImpl_H
+#define zypp_repo_cached_ProductImpl_H
+
+#include "zypp/detail/ProductImpl.h"
+#include "zypp/repo/cached/RepoImpl.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+namespace repo
+{ /////////////////////////////////////////////////////////////////
+namespace cached
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ProductImpl
+ //
+ class ProductImpl : public detail::ProductImplIf
+ {
+ public:
+
+ ProductImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r );
+
+ virtual TranslatedText summary() const;
+ virtual TranslatedText description() const;
+ virtual TranslatedText insnotify() const;
+ virtual TranslatedText delnotify() const;
+ virtual TranslatedText licenseToConfirm() const;
+ virtual Vendor vendor() const;
+ virtual ByteCount size() const;
+ virtual ByteCount archivesize() const;
+ virtual bool installOnly() const;
+ virtual Date buildtime() const;
+ virtual Date installtime() const;
+
+ virtual Source_Ref source() const;
+ virtual unsigned sourceMediaNr() const;
+
+ // PRODUCT
+ virtual std::string category() const;
+ virtual Url releaseNotesUrl() const;
+ virtual std::list<Url> updateUrls() const;
+ virtual std::list<Url> extraUrls() const ;
+ virtual std::list<Url> optionalUrls() const ;
+ virtual std::list<std::string> flags() const;
+ virtual TranslatedText shortName() const;
+ virtual std::string distributionName() const;
+ virtual Edition distributionEdition() const;
+ virtual Repository repository() const;
+
+ protected:
+ repo::cached::RepoImpl::Ptr _repository;
+ data::RecordId _id;
+ };
+ /////////////////////////////////////////////////////////////////
+} // namespace cached
+} // namespace repository
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZMD_BACKEND_DBSOURCE_DBPACKAGEIMPL_H
+