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


C++ ContainerID::parent方法代码示例

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


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

示例1: iscntrl

Option<Error> validateContainerId(const ContainerID& containerId)
{
  // Slashes are disallowed as these IDs are mapped to directories.
  //
  // Periods are disallowed because our string representation of
  // ContainerID uses periods: <uuid>.<child>.<grandchild>.
  // For example: <uuid>.redis.backup
  //
  // Spaces are disallowed as they can render logs confusing and
  // need escaping on terminals when dealing with paths.
  //
  // TODO(bmahler): Add common/validation.hpp to share ID validation.
  // Note that this however is slightly stricter than other IDs in
  // that we do not allow periods or spaces.
  auto invalidCharacter = [](char c) {
    return iscntrl(c) ||
      c == os::POSIX_PATH_SEPARATOR ||
      c == os::WINDOWS_PATH_SEPARATOR ||
      c == '.' ||
      c == ' ';
  };

  const string& id = containerId.value();

  if (id.empty()) {
    return Error("'ContainerID.value' must be non-empty");
  }

  if (std::any_of(id.begin(), id.end(), invalidCharacter)) {
    return Error("'ContainerID.value' '" + id + "'"
                 " contains invalid characters");
  }

  // TODO(bmahler): Print the invalid field nicely within the error
  // (e.g. 'parent.parent.parent.value'). For now we only have one
  // level of nesting so it's ok.
  if (containerId.has_parent()) {
    Option<Error> parentError = validateContainerId(containerId.parent());

    if (parentError.isSome()) {
      return Error("'ContainerID.parent' is invalid: " + parentError->message);
    }
  }

  return None();
}
开发者ID:SStar1314,项目名称:mesos,代码行数:46,代码来源:validation.cpp

示例2: Error

Option<Error> validateContainerId(const ContainerID& containerId)
{
  const string& id = containerId.value();

  // Check common Mesos ID rules.
  Option<Error> error = common::validation::validateID(id);
  if (error.isSome()) {
    return Error(error->message);
  }

  // Check ContainerID specific rules.
  //
  // Periods are disallowed because our string representation of
  // ContainerID uses periods: <uuid>.<child>.<grandchild>.
  // For example: <uuid>.redis.backup
  //
  // Spaces are disallowed as they can render logs confusing and
  // need escaping on terminals when dealing with paths.
  auto invalidCharacter = [](char c) {
    return  c == '.' || c == ' ';
  };

  if (std::any_of(id.begin(), id.end(), invalidCharacter)) {
    return Error("'ContainerID.value' '" + id + "'"
                 " contains invalid characters");
  }

  // TODO(bmahler): Print the invalid field nicely within the error
  // (e.g. 'parent.parent.parent.value'). For now we only have one
  // level of nesting so it's ok.
  if (containerId.has_parent()) {
    Option<Error> parentError = validateContainerId(containerId.parent());

    if (parentError.isSome()) {
      return Error("'ContainerID.parent' is invalid: " + parentError->message);
    }
  }

  return None();
}
开发者ID:ChrisPaprocki,项目名称:mesos,代码行数:40,代码来源:validation.cpp

示例3:

bool operator==(const ContainerID& left, const ContainerID& right)
{
  return left.value() == right.value() &&
    left.has_parent() == right.has_parent() &&
    (!left.has_parent() || left.parent() == right.parent());
}
开发者ID:davelester,项目名称:mesos,代码行数:6,代码来源:type_utils.cpp


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