本文整理汇总了C++中Manifest::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Manifest::size方法的具体用法?C++ Manifest::size怎么用?C++ Manifest::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Manifest
的用法示例。
在下文中一共展示了Manifest::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge
void Manifest::merge(const Manifest& other)
{
if (size() != other.size()) error("Invalid manifest sizes for merging.");
FileStats fileStats;
for (std::size_t i(0); i < size(); ++i)
{
FileInfo& ours(m_fileInfo[i]);
const FileInfo& theirs(other.m_fileInfo[i]);
if (ours.path() != theirs.path()) error("Invalid manifest paths");
if (
ours.status() == FileInfo::Status::Outstanding &&
theirs.status() != FileInfo::Status::Outstanding)
{
ours.status(theirs.status());
switch (theirs.status())
{
case FileInfo::Status::Inserted: fileStats.addInsert(); break;
case FileInfo::Status::Omitted: fileStats.addOmit(); break;
case FileInfo::Status::Error: fileStats.addError(); break;
default: throw std::runtime_error("Invalid file status");
}
}
ours.pointStats().add(theirs.pointStats());
}
m_pointStats.add(other.pointStats());
m_fileStats.add(fileStats);
}
示例2: pushAll
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ResourceBuff::pushAll(Manifest mats) {
double tot_qty = 0;
for (int i = 0; i < mats.size(); i++) {
tot_qty += mats.at(i)->quantity();
}
if (tot_qty - space() > STORE_EPS && unlimited_ != true) {
throw CycOverCapException("Material pushing breaks capacity limit.");
}
std::list<rsrc_ptr>::iterator iter;
for (iter = mats_.begin(); iter != mats_.end(); iter++) {
for (int i = 0; i < mats.size(); i++) {
if ((*iter) == mats.at(i)) {
throw CycDupResException("Duplicate material pushing attempted.");
}
}
}
for (int i = 0; i < mats.size(); i++) {
mats_.push_back(mats.at(i));
}
}
示例3: testManifest
void ManifestTest::testManifest()
{
Manifest<MfTestBase> manifest;
assert (manifest.empty());
assert (manifest.size() == 0);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject1")));
assert (!manifest.empty());
assert (manifest.size() == 1);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject2")));
MetaObject<MfTestObject, MfTestBase>* pMeta = new MetaObject<MfTestObject, MfTestBase>("MfTestObject2");
assert (!manifest.insert(pMeta));
delete pMeta;
assert (!manifest.empty());
assert (manifest.size() == 2);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject3")));
assert (manifest.size() == 3);
assert (manifest.find("MfTestObject1") != manifest.end());
assert (manifest.find("MfTestObject2") != manifest.end());
assert (manifest.find("MfTestObject3") != manifest.end());
assert (manifest.find("MfTestObject4") == manifest.end());
std::set<std::string> classes;
Manifest<MfTestBase>::Iterator it = manifest.begin();
assert (it != manifest.end());
classes.insert(it->name());
++it;
assert (it != manifest.end());
classes.insert(it->name());
++it;
assert (it != manifest.end());
classes.insert(it->name());
it++;
assert (it == manifest.end());
assert (classes.find("MfTestObject1") != classes.end());
assert (classes.find("MfTestObject2") != classes.end());
assert (classes.find("MfTestObject3") != classes.end());
manifest.clear();
assert (manifest.empty());
assert (manifest.size() == 0);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject4")));
assert (!manifest.empty());
assert (manifest.size() == 1);
it = manifest.begin();
assert (it != manifest.end());
assert (std::string(it->name()) == "MfTestObject4");
++it;
assert (it == manifest.end());
}