当前位置: 首页>>代码示例>>C++>>正文


C++ Manifest::size方法代码示例

本文整理汇总了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);
}
开发者ID:json87,项目名称:entwine,代码行数:34,代码来源:manifest.cpp

示例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));
  }
}
开发者ID:Simiopolis,项目名称:core,代码行数:21,代码来源:ResourceBuff.cpp

示例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());
}
开发者ID:ConfusedReality,项目名称:pkg_network_poco,代码行数:52,代码来源:ManifestTest.cpp


注:本文中的Manifest::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。