本文整理汇总了C++中xapian::WritableDatabase::set_metadata方法的典型用法代码示例。如果您正苦于以下问题:C++ WritableDatabase::set_metadata方法的具体用法?C++ WritableDatabase::set_metadata怎么用?C++ WritableDatabase::set_metadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xapian::WritableDatabase
的用法示例。
在下文中一共展示了WritableDatabase::set_metadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: db
//.........这里部分代码省略.........
if (project_group != NULL)
doc.add_value (XapianValues::PROJECT_GROUP, project_group);
// Add developer name
const gchar *developer_name = as_component_get_developer_name (cpt);
if (developer_name != NULL)
doc.add_value (XapianValues::DEVELOPER_NAME, developer_name);
// Add releases information
Releases pb_rels;
GPtrArray *releases = as_component_get_releases (cpt);
for (uint i = 0; i < releases->len; i++) {
AsRelease *rel = (AsRelease*) g_ptr_array_index (releases, i);
Releases_Release *pb_rel = pb_rels.add_release ();
// version
pb_rel->set_version (as_release_get_version (rel));
// UNIX timestamp
pb_rel->set_unix_timestamp (as_release_get_timestamp (rel));
// release urgency (if set)
if (as_release_get_urgency (rel) != AS_URGENCY_KIND_UNKNOWN)
pb_rel->set_urgency ((Releases_UrgencyType) as_release_get_urgency (rel));
// add location urls
GPtrArray *locations = as_release_get_locations (rel);
for (uint j = 0; j < locations->len; j++) {
pb_rel->add_location ((gchar*) g_ptr_array_index (locations, j));
}
// add checksum info
for (uint j = 0; j < AS_CHECKSUM_KIND_LAST; j++) {
if (as_release_get_checksum (rel, (AsChecksumKind) j) != NULL) {
Releases_Checksum *pb_cs = pb_rel->add_checksum ();
pb_cs->set_type ((Releases_ChecksumType) j);
pb_cs->set_value (as_release_get_checksum (rel, (AsChecksumKind) j));
}
}
// add size info
for (uint j = 0; j < AS_SIZE_KIND_LAST; j++) {
if (as_release_get_size (rel, (AsSizeKind) j) > 0) {
Releases_Size *pb_s = pb_rel->add_size ();
pb_s->set_type ((Releases_SizeType) j);
pb_s->set_value (as_release_get_size (rel, (AsSizeKind) j));
}
}
// add description
if (as_release_get_description (rel) != NULL)
pb_rel->set_description (as_release_get_description (rel));
}
string rel_ostr;
if (pb_rels.SerializeToString (&rel_ostr))
doc.add_value (XapianValues::RELEASES, rel_ostr);
// Languages
GHashTable *langs_table;
langs_table = as_component_get_languages_map (cpt);
if (g_hash_table_size (langs_table) > 0) {
Languages pb_langs;
string ostr;
g_hash_table_foreach (langs_table,
(GHFunc) langs_hashtable_to_langentry,
&pb_langs);
if (pb_rels.SerializeToString (&ostr))
doc.add_value (XapianValues::LANGUAGES, ostr);
}
// Postprocess
string docData = doc.get_data ();
doc.add_term ("AA" + docData);
term_generator.index_text_without_positions (docData, WEIGHT_DESKTOP_NAME);
//! g_debug ("Adding component: %s", as_component_to_string (cpt));
db.add_document (doc);
// infer database locale from single component
// TODO: Do that in a smarter way, if we support multiple databases later.
if (db_locale.empty ())
db_locale = as_component_get_active_locale (cpt);
}
db.set_metadata ("db-schema-version", to_string (AS_DB_SCHEMA_VERSION));
db.set_metadata ("db-locale", db_locale);
db.commit ();
if (g_rename (m_dbPath.c_str (), old_path.c_str ()) < 0) {
g_critical ("Error while moving old database out of the way.");
return false;
}
if (g_rename (rebuild_path.c_str (), m_dbPath.c_str ()) < 0) {
g_critical ("Error while moving rebuilt database.");
return false;
}
as_utils_delete_dir_recursive (old_path.c_str ());
return true;
}