本文整理汇总了C++中Package::files方法的典型用法代码示例。如果您正苦于以下问题:C++ Package::files方法的具体用法?C++ Package::files怎么用?C++ Package::files使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::files方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: storePackage
void TdbDatabase::storePackage(const Package& p) {
TdbKeyValue kv;
// check if this package is already indexed
kv.setKey(p.name() + "-version");
kv.setValue(tdb_fetch(m_tdbFile, kv.key()));
if (kv.value_str() == p.version()) {
kv.setKey(p.name() + "-release");
kv.setValue(tdb_fetch(m_tdbFile, kv.key()));
if (kv.value_str() == p.release()) {
return;
}
}
// OK, we have something new
int res = 0;
kv.setKey(p.name() + "-version");
kv.setValue(p.version());
res = tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_MODIFY);
if (res != 0 ) tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_INSERT);
kv.setKey(p.name() + "-release");
kv.setValue(p.release());
res = tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_MODIFY);
if (res != 0 ) tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_INSERT);
kv.setKey(p.name() + "-architecture");
kv.setValue(p.architecture());
res = tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_MODIFY);
if (res != 0 ) tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_INSERT);
kv.setKey(p.name() + "-compression");
kv.setValue(p.compression());
res = tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_MODIFY);
if (res != 0 ) tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_INSERT);
string filesString;
bool first = true;
for (const auto& elem : p.files()) {
TdbKeyValue fkv(elem, p.name());
const int ret = tdb_store(m_tdbFile, fkv.key(), fkv.value(),
TDB_INSERT);
if (ret != 0) {
fkv.setValue(tdb_fetch(m_tdbFile, fkv.key()));
vector<string> others;
istringstream iss(fkv.value_str());
copy(istream_iterator<string>(iss), istream_iterator<string>(),
back_inserter<vector<string> >(others));
others.push_back(p.name());
auto uIter = unique(others.begin(), others.end());
others.resize(uIter - others.begin());
string newValue;
bool isthefirst = true;
for (auto& other : others) {
if (isthefirst) {
isthefirst = false;
} else {
newValue += " ";
}
newValue += other;
}
fkv.setValue(newValue);
tdb_store(m_tdbFile, fkv.key(), fkv.value(), TDB_MODIFY);
}
if (first) {
filesString.append(elem);
first = false;
} else {
filesString.append(" " + elem);
}
}
kv.setKey(p.name() + "-files");
kv.setValue(filesString);
res = tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_MODIFY);
if (res != 0 ) tdb_store(m_tdbFile, kv.key(), kv.value(), TDB_INSERT);
}