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


C++ Cfg::GetKey方法代码示例

本文整理汇总了C++中Cfg::GetKey方法的典型用法代码示例。如果您正苦于以下问题:C++ Cfg::GetKey方法的具体用法?C++ Cfg::GetKey怎么用?C++ Cfg::GetKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cfg的用法示例。


在下文中一共展示了Cfg::GetKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetPackageManifest

PackageInfo PackageManager::GetPackageManifest(const Cfg& cfg, const string& packageId, const std::string& texmfPrefix)
{
  auto key = cfg.GetKey(packageId);
  if (key == nullptr)
  {
    MIKTEX_UNEXPECTED();
  }
  PackageInfo packageInfo;
  packageInfo.id = packageId;
  for (auto val : *key)
  {
    if (val->GetName() == "displayName")
    {
      packageInfo.displayName = val->AsString();
    }
    else if (val->GetName() == "creator")
    {
      packageInfo.creator = val->AsString();
    }
    else if (val->GetName() == "title")
    {
      packageInfo.title = val->AsString();
    }
    else if (val->GetName() == "version")
    {
      packageInfo.version = val->AsString();
    }
    else if (val->GetName() == "targetSystem")
    {
      packageInfo.targetSystem = val->AsString();
    }
    else if (val->GetName() == "description[]")
    {
      packageInfo.description = std::for_each(val->begin(), val->end(), Flattener('\n')).result;
    }
    else if (val->GetName() == "require[]")
    {
      packageInfo.requiredPackages = val->AsStringVector();
    }
    else if (val->GetName() == "runSize")
    {
      packageInfo.sizeRunFiles = Utils::ToSizeT(val->AsString());
    }
    else if (val->GetName() == "run[]")
    {
      for (const string& s : *val)
      {
        PathName path(s);
#if defined(MIKTEX_UNIX)
        path.ConvertToUnix();
#endif
        if (texmfPrefix.empty() || (PathName::Compare(texmfPrefix, path, texmfPrefix.length()) == 0))
        {
          packageInfo.runFiles.push_back(path.ToString());
        }
      }
    }
    else if (val->GetName() == "docSize")
    {
      packageInfo.sizeDocFiles = Utils::ToSizeT(val->AsString());
    }
    else if (val->GetName() == "doc[]")
    {
      for (const string& s : *val)
      {
        PathName path(s);
#if defined(MIKTEX_UNIX)
        path.ConvertToUnix();
#endif
        if (texmfPrefix.empty() || (PathName::Compare(texmfPrefix, path, texmfPrefix.length()) == 0))
        {
          packageInfo.docFiles.push_back(path.ToString());
        }
      }
    }
    else if (val->GetName() == "sourceSize")
    {
      packageInfo.sizeSourceFiles = Utils::ToSizeT(val->AsString());
    }
    else if (val->GetName() == "source[]")
    {
      for (const string& s : *val)
      {
        PathName path(s);
#if defined(MIKTEX_UNIX)
        path.ConvertToUnix();
#endif
        if (texmfPrefix.empty() || (PathName::Compare(texmfPrefix, path, texmfPrefix.length()) == 0))
        {
          packageInfo.sourceFiles.push_back(path.ToString());
        }
      }
    }
    else if (val->GetName() == "timePackaged")
    {
      packageInfo.timePackaged = Utils::ToTimeT(val->AsString());
    }
    else if (val->GetName() == "digest")
    {
      packageInfo.digest = MD5::Parse(val->AsString());
//.........这里部分代码省略.........
开发者ID:MiKTeX,项目名称:miktex,代码行数:101,代码来源:PackageManagerImpl.cpp

示例2: PutPackageManifest

void PackageManager::PutPackageManifest(Cfg& cfg, const PackageInfo& packageInfo, time_t timePackaged)
{
  if (cfg.GetKey(packageInfo.id) != nullptr)
  {
    cfg.DeleteKey(packageInfo.id);
  }
  if (!packageInfo.displayName.empty())
  {
    cfg.PutValue(packageInfo.id, "displayName", packageInfo.displayName);
  }
  cfg.PutValue(packageInfo.id, "creator", "mpc");
  if (!packageInfo.title.empty())
  {
    cfg.PutValue(packageInfo.id, "title", packageInfo.title);
  }
  if (!packageInfo.version.empty())
  {
    cfg.PutValue(packageInfo.id, "version", packageInfo.version);
  }
  if (!packageInfo.targetSystem.empty())
  {
    cfg.PutValue(packageInfo.id, "targetSystem", packageInfo.targetSystem);
  }
  if (!packageInfo.description.empty())
  {
    for (const string& line : StringUtil::Split(packageInfo.description, '\n'))
    {
      cfg.PutValue(packageInfo.id, "description[]", line);
    }
  }
  if (!packageInfo.requiredPackages.empty())
  {
    for (const string& pkg : packageInfo.requiredPackages)
    {
      cfg.PutValue(packageInfo.id, "require[]", pkg);
    }
  }
  if (!packageInfo.runFiles.empty())
  {
    cfg.PutValue(packageInfo.id, "runSize", std::to_string(packageInfo.sizeRunFiles));
    for (const string& file : packageInfo.runFiles)
    {
      cfg.PutValue(packageInfo.id, "run[]", PathName(file).ToUnix().ToString());
    }
  }
  if (!packageInfo.docFiles.empty())
  {
    cfg.PutValue(packageInfo.id, "docSize", std::to_string(packageInfo.sizeDocFiles));
    for (const string& file : packageInfo.docFiles)
    {
      cfg.PutValue(packageInfo.id, "doc[]", PathName(file).ToUnix().ToString());
    }
  }
  if (!packageInfo.sourceFiles.empty())
  {
    cfg.PutValue(packageInfo.id, "sourceSize", std::to_string(packageInfo.sizeSourceFiles));
    for (const string& file : packageInfo.sourceFiles)
    {
      cfg.PutValue(packageInfo.id, "source[]", PathName(file).ToUnix().ToString());
    }
  }
  if (IsValidTimeT(timePackaged))
  {
    cfg.PutValue(packageInfo.id, "timePackaged", std::to_string(timePackaged));
  }
  cfg.PutValue(packageInfo.id, "digest", packageInfo.digest.ToString());
  if (!packageInfo.ctanPath.empty())
  {
    cfg.PutValue(packageInfo.id, "ctanPath", packageInfo.ctanPath);
  }
  if (!packageInfo.copyrightOwner.empty())
  {
    cfg.PutValue(packageInfo.id, "copyrightOwner", packageInfo.copyrightOwner);
  }
  if (!packageInfo.copyrightYear.empty())
  {
    cfg.PutValue(packageInfo.id, "copyrightYear", packageInfo.copyrightYear);
  }
  if (!packageInfo.licenseType.empty())
  {
    cfg.PutValue(packageInfo.id, "licenseType", packageInfo.licenseType);
  }
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:83,代码来源:PackageManagerImpl.cpp


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