Author: dmacvicar
Date: Mon May 14 17:59:51 2007
New Revision: 5545
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5545&view=rev
Log:
adapt the resolvable query to retrieve text
attributes on demand
Modified:
trunk/libzypp/zypp2/cache/CacheStore.cpp
trunk/libzypp/zypp2/cache/CacheStore.h
trunk/libzypp/zypp2/cache/ResolvableQuery.cc
trunk/libzypp/zypp2/cache/ResolvableQuery.h
Modified: trunk/libzypp/zypp2/cache/CacheStore.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.cpp?rev=5545&r1=5544&r2=5545&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.cpp (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.cpp Mon May 14 17:59:51 2007
@@ -527,23 +527,28 @@
return static_cast<RecordId>(id);
}
-void CacheStore::appendStringAttribute( const data::RecordId &resolvable_id,
- const TranslatedText &text )
+void CacheStore::appendTranslatedStringAttribute( const data::RecordId &resolvable_id,
+ const std::string &klass,
+ const std::string &name,
+ const TranslatedText &text )
{
set<Locale> locales = text.locales();
for ( set<Locale>::const_iterator it = locales.begin(); it != locales.end(); ++it )
{
- appendStringAttribute( resolvable_id, *it, text.text(*it) );
+ appendStringAttributeTranslation( resolvable_id, *it, klass, name, text.text(*it) );
}
}
-void CacheStore::appendStringAttribute( const data::RecordId &resolvable_id,
- const Locale &locale,
- const std::string &text )
+void CacheStore::appendStringAttributeTranslation( const data::RecordId &resolvable_id,
+ const Locale &locale,
+ const std::string &klass,
+ const std::string &name,
+ const std::string &text )
{
RecordId lang_id = lookupOrAppendType("lang", locale.code() );
- appendStringAttribute( resolvable_id, lang_id, text );
+ RecordId type_id = lookupOrAppendType( klass, name );
+ appendStringAttribute( resolvable_id, lang_id, type_id, text );
}
void CacheStore::appendStringAttribute( const data::RecordId &resolvable_id,
Modified: trunk/libzypp/zypp2/cache/CacheStore.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.h?rev=5545&r1=5544&r2=5545&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.h (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.h Mon May 14 17:59:51 2007
@@ -257,20 +257,28 @@
/**
* Append a translated string value to a resolvable
* \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 text Translated text
*/
- void appendStringAttribute( const data::RecordId &resolvable_id,
- const TranslatedText &text );
+ void appendTranslatedStringAttribute( const data::RecordId &resolvable_id,
+ const std::string &klass,
+ const std::string &name,
+ const TranslatedText &text );
/**
* Append a string value to a resolvable
* \param resolvable_id Resovable Id, owner of the attribute
* \param locale locale of the text language
+ * \param klass Type class i.e "Package" "lang" "kind"
+ * \param name Type name i.e : "summary" "none" "Script"
* \param text text
*/
- void appendStringAttribute( const data::RecordId &resolvable_id,
- const Locale &locale,
- const std::string &text );
+ void appendStringAttributeTranslation( const data::RecordId &resolvable_id,
+ const Locale &locale,
+ const std::string &klass,
+ const std::string &name,
+ const std::string &text );
/**
* Append a string value to a resolvable
Modified: trunk/libzypp/zypp2/cache/ResolvableQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQuery.cc?rev=5545&r1=5544&r2=5545&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.cc (original)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.cc Mon May 14 17:59:51 2007
@@ -11,8 +11,8 @@
struct ResolvableQuery::Impl
{
- Impl( const Pathname &dbdir, ProcessResolvable fnc )
- : _dbdir(dbdir), _fnc(fnc)
+ Impl( const Pathname &dbdir)
+ : _dbdir(dbdir)
{
_fields = "id, name, version, release, epoch, arch, kind, insnotify, delnotify, license_to_confirm, vendor, installed_size, archive_size, install_only, build_time, install_time, catalog_id";
}
@@ -32,7 +32,8 @@
return ptr;
}
- void query( const data::RecordId &id )
+ void query( const data::RecordId &id,
+ ProcessResolvable fnc )
{
sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
//con.executenonquery("PRAGMA cache_size=8000;");
@@ -42,12 +43,13 @@
sqlite3_reader reader = cmd.executereader();
while(reader.read())
{
- _fnc( id, fromRow(reader) );
+ fnc( id, fromRow(reader) );
}
con.executenonquery("COMMIT;");
}
- void query( const std::string &s )
+ void query( const std::string &s,
+ ProcessResolvable fnc )
{
sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
//con.executenonquery("PRAGMA cache_size=8000;");
@@ -57,29 +59,28 @@
sqlite3_reader reader = cmd.executereader();
while(reader.read())
{
- _fnc( reader.getint64(0), fromRow(reader) );
+ fnc( reader.getint64(0), fromRow(reader) );
}
con.executenonquery("COMMIT;");
}
Pathname _dbdir;
- ProcessResolvable _fnc;
string _fields;
};
-ResolvableQuery::ResolvableQuery( const Pathname &dbdir, ProcessResolvable fnc )
- : _pimpl(new Impl(dbdir, fnc))
+ResolvableQuery::ResolvableQuery( const Pathname &dbdir)
+ : _pimpl(new Impl(dbdir))
{
}
-void ResolvableQuery::query( const data::RecordId &id )
+void ResolvableQuery::query( const data::RecordId &id, ProcessResolvable fnc )
{
- _pimpl->query(id);
+ _pimpl->query(id, fnc);
}
-void ResolvableQuery::query( const std::string &s )
+void ResolvableQuery::query( const std::string &s, ProcessResolvable fnc )
{
- _pimpl->query(s);
+ _pimpl->query(s, fnc);
}
Modified: trunk/libzypp/zypp2/cache/ResolvableQuery.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQuery.h?rev=5545&r1=5544&r2=5545&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.h (original)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.h Mon May 14 17:59:51 2007
@@ -15,20 +15,7 @@
{ /////////////////////////////////////////////////////////////////
/**
- * Allows to iterate around the capabilities in
- * the cache.
- * Use \ref CacheQuery to create this query.
- *
- * \code
- * CacheQuery query(dbdir);
- * CapabilityQuery capquery = query.createCapabilityQuery( zypp::Dep::REQUIRES, 1 );
- * cout << capquery.value() << endl;
- * while ( capquery.read() )
- * {
- * // value is a CapablityImpl::Ptr
- * cout << capquery.value() << endl;
- * }
- * \endcode
+ *
*/
struct ResolvableQuery
{
@@ -41,18 +28,29 @@
typedef function