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


C++ dynamic::isString方法代码示例

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


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

示例1: parsePool

PoolFactory::PoolJson PoolFactory::parsePool(const folly::dynamic& json) {
  checkLogic(json.isString() || json.isObject(),
             "Pool should be a string (name of pool) or an object");
  if (json.isString()) {
    return parseNamedPool(json.stringPiece());
  }
  auto jname = json.get_ptr("name");
  checkLogic(jname && jname->isString(), "Pool should have string 'name'");
  pools_.emplace(jname->stringPiece(), std::make_pair(json, PoolState::NEW));
  return parseNamedPool(jname->stringPiece());
}
开发者ID:Fierralin,项目名称:mcrouter,代码行数:11,代码来源:PoolFactory.cpp

示例2: parsePool

std::shared_ptr<ClientPool>
PoolFactory::parsePool(const folly::dynamic& json) {
  checkLogic(json.isString() || json.isObject(),
             "Pool should be a string (name of pool) or an object");
  if (json.isString()) {
    return parsePool(json.stringPiece().str(), json);
  } else {
    auto name = json.get_ptr("name");
    checkLogic(name && name->isString(), "Pool should have string 'name'");
    return parsePool(name->stringPiece().str(), json);
  }
}
开发者ID:easyfmxu,项目名称:mcrouter,代码行数:12,代码来源:PoolFactory.cpp

示例3: makeErrorRoute

McrouterRouteHandlePtr makeErrorRoute(
    RouteHandleFactory<McrouterRouteHandleIf>& factory,
    const folly::dynamic& json) {
  checkLogic(json.isObject() || json.isString() || json.isNull(),
             "ErrorRoute: should be string or object");
  std::string response;
  if (json.isString()) {
    response = json.stringPiece().str();
  } else if (json.isObject()) {
    if (auto jResponse = json.get_ptr("response")) {
      checkLogic(jResponse->isString(), "ErrorRoute: response is not a string");
      response = jResponse->stringPiece().str();
    }
  }
  return makeErrorRoute(std::move(response));
}
开发者ID:THIAGOWESLLEY2,项目名称:mcrouter,代码行数:16,代码来源:ErrorRoute.cpp

示例4: yogaStyleDisplayFromDynamic

YGDisplay yogaStyleDisplayFromDynamic(const folly::dynamic &value) {
  assert(value.isString());
  auto stringValue = value.asString();

  if (stringValue == "flex") { return YGDisplayFlex; }
  if (stringValue == "none") { return YGDisplayNone; }

  abort();
}
开发者ID:4Catalyzer,项目名称:react-native,代码行数:9,代码来源:yogaValuesConversions.cpp

示例5: yogaStylePositionTypeFromDynamic

YGPositionType yogaStylePositionTypeFromDynamic(const folly::dynamic &value) {
  assert(value.isString());
  auto stringValue = value.asString();

  if (stringValue == "relative") { return YGPositionTypeRelative; }
  if (stringValue == "absolute") { return YGPositionTypeAbsolute; }

  abort();
}
开发者ID:4Catalyzer,项目名称:react-native,代码行数:9,代码来源:yogaValuesConversions.cpp

示例6: yogaStyleDirectionFromDynamic

YGDirection yogaStyleDirectionFromDynamic(const folly::dynamic &value) {
  assert(value.isString());
  auto stringValue = value.asString();

  if (stringValue == "inherit") { return YGDirectionInherit; }
  if (stringValue == "ltr") { return YGDirectionLTR; }
  if (stringValue == "rtl") { return YGDirectionRTL; }

  abort();
}
开发者ID:4Catalyzer,项目名称:react-native,代码行数:10,代码来源:yogaValuesConversions.cpp

示例7: yogaStyleOverflowFromDynamic

YGOverflow yogaStyleOverflowFromDynamic(const folly::dynamic &value) {
  assert(value.isString());
  auto stringValue = value.asString();

  if (stringValue == "visible") { return YGOverflowVisible; }
  if (stringValue == "hidden") { return YGOverflowHidden; }
  if (stringValue == "scroll") { return YGOverflowScroll; }

  abort();
}
开发者ID:4Catalyzer,项目名称:react-native,代码行数:10,代码来源:yogaValuesConversions.cpp

示例8: yogaStyleWrapFromDynamic

YGWrap yogaStyleWrapFromDynamic(const folly::dynamic &value) {
  assert(value.isString());
  auto stringValue = value.asString();

  if (stringValue == "no-wrap") { return YGWrapNoWrap; }
  if (stringValue == "wrap") { return YGWrapWrap; }
  if (stringValue == "wrap-reverse") { return YGWrapWrapReverse; }

  abort();
}
开发者ID:4Catalyzer,项目名称:react-native,代码行数:10,代码来源:yogaValuesConversions.cpp

示例9: yogaStyleFlexDirectionFromDynamic

YGFlexDirection yogaStyleFlexDirectionFromDynamic(const folly::dynamic &value) {
  assert(value.isString());
  auto stringValue = value.asString();

  if (stringValue == "column") { return YGFlexDirectionColumn; }
  if (stringValue == "column-reverse") { return YGFlexDirectionColumnReverse; }
  if (stringValue == "row") { return YGFlexDirectionRow; }
  if (stringValue == "row-reverse") { return YGFlexDirectionRowReverse; }

  abort();
}
开发者ID:4Catalyzer,项目名称:react-native,代码行数:11,代码来源:yogaValuesConversions.cpp

示例10: phpSerialize

fbstring phpSerialize(const folly::dynamic& d) {
  if (d.isNull()) {
    return "N;";
  }
  if (d.isBool()) {
    return d.asBool() ? "b:1;" : "b:0;";
  }
  if (d.isInt()) {
    return "i:" + d.asString() + ";";
  }
  if (d.isDouble()) {
    return "d:" + d.asString() + ";";
  }
  if (d.isString()) {
    auto str = d.asString();
    return folly::to<fbstring>("s:", str.size(), ":\"", str, "\";");
  }
  if (d.isArray()) {
    fbstring ret = folly::to<fbstring>("a:", d.size(), ":{");
    int i = 0;
    for (auto &v : d) {
      ret += folly::to<fbstring>("i:", i, ";", phpSerialize(v));
    }
    return ret + "};";
  }
  if (d.isObject()) {
    fbstring ret = folly::to<fbstring>("a:", d.size(), ":{");
    int nextindex = 0;
    for (auto &k : d.keys()) {
      if (k.isNull()) {
        ret += "i:0;";
        if (nextindex <= 0) {
          nextindex = 1;
        }
      } else if (k.isInt() || k.isDouble()) {
        int i = k.asInt();
        ret += folly::to<fbstring>("i:", i, ";");
        if (nextindex <= i) {
          nextindex = i + 1;
        }
      } else if (k.isString()) {
        ret += folly::to<fbstring>("s:", k.size(), ":\"",
                                   escapeCpp(k.asString()), "\";");
      } else {
        /* Should never be reached, but cover it to be safe */
        ret += folly::to<fbstring>("i:", nextindex++, ";");
      }
      ret += phpSerialize(d[k]);
    }
    return ret + "};";
  }
  throw std::logic_error("Unhandled dynamic type in php serialization");
  return "N;";
}
开发者ID:abacaxinho,项目名称:hhvm,代码行数:54,代码来源:idl.cpp

示例11: parseAsynclogRoute

/**
 * @return target and asynclogName
 *         Caller may call makeAsynclogRoute afterwards.
 */
std::pair<McrouterRouteHandlePtr, std::string> parseAsynclogRoute(
    RouteHandleFactory<McrouterRouteHandleIf>& factory,
    const folly::dynamic& json) {
  std::string asynclogName;
  McrouterRouteHandlePtr target;
  checkLogic(json.isObject() || json.isString(),
             "AsynclogRoute should be object or string");
  if (json.isString()) {
    asynclogName = json.stringPiece().str();
    target = factory.create(json);
  } else { // object
    auto jname = json.get_ptr("name");
    checkLogic(jname && jname->isString(),
               "AsynclogRoute: required string name");
    auto jtarget = json.get_ptr("target");
    checkLogic(jtarget, "AsynclogRoute: target not found");
    asynclogName = jname->stringPiece().str();
    target = factory.create(*jtarget);
  }
  return { std::move(target), std::move(asynclogName) };
}
开发者ID:THIAGOWESLLEY2,项目名称:mcrouter,代码行数:25,代码来源:AsynclogRoute.cpp

示例12: yogaStyleOptionalFloatFromDynamic

YGFloatOptional yogaStyleOptionalFloatFromDynamic(const folly::dynamic &value) {
  if (value.isNumber()) {
    return YGFloatOptional(value.asDouble());
  } else if (value.isString()) {
    const auto stringValue = value.asString();
    if (stringValue == "auto") {
      return YGFloatOptional();
    }
  }

  abort();
}
开发者ID:4Catalyzer,项目名称:react-native,代码行数:12,代码来源:yogaValuesConversions.cpp

示例13: yogaStyleJustifyFromDynamic

YGJustify yogaStyleJustifyFromDynamic(const folly::dynamic &value) {
  assert(value.isString());
  auto stringValue = value.asString();

  if (stringValue == "flex-start") { return YGJustifyFlexStart; }
  if (stringValue == "center") { return YGJustifyCenter; }
  if (stringValue == "flex-end") { return YGJustifyFlexEnd; }
  if (stringValue == "space-between") { return YGJustifySpaceBetween; }
  if (stringValue == "space-around") { return YGJustifySpaceAround; }
  if (stringValue == "space-evenly") { return YGJustifySpaceEvenly; }

  abort();
}
开发者ID:4Catalyzer,项目名称:react-native,代码行数:13,代码来源:yogaValuesConversions.cpp

示例14: make_pair

std::pair<std::shared_ptr<ClientPool>, std::vector<McrouterRouteHandlePtr>>
McRouteHandleProvider::makePool(const folly::dynamic& json) {
  checkLogic(json.isString() || json.isObject(),
             "Pool should be a string (name of pool) or an object");
  auto pool = poolFactory_.parsePool(json);
  std::vector<McrouterRouteHandlePtr> destinations;
  for (const auto& client : pool->getClients()) {
    auto pdstn = destinationMap_.fetch(*client);
    auto route = makeDestinationRoute(client, std::move(pdstn));
    destinations.push_back(std::move(route));
  }

  return std::make_pair(std::move(pool), std::move(destinations));
}
开发者ID:glensc,项目名称:mcrouter,代码行数:14,代码来源:McRouteHandleProvider.cpp

示例15: yogaStyleAlignFromDynamic

YGAlign yogaStyleAlignFromDynamic(const folly::dynamic &value) {
  assert(value.isString());
  auto stringValue = value.asString();

  if (stringValue == "auto") { return YGAlignAuto; }
  if (stringValue == "flex-start") { return YGAlignFlexStart; }
  if (stringValue == "center") { return YGAlignCenter; }
  if (stringValue == "flex-end") { return YGAlignFlexEnd; }
  if (stringValue == "stretch") { return YGAlignStretch; }
  if (stringValue == "baseline") { return YGAlignBaseline; }
  if (stringValue == "between") { return YGAlignSpaceBetween; }
  if (stringValue == "space-around") { return YGAlignSpaceAround; }

  abort();
}
开发者ID:4Catalyzer,项目名称:react-native,代码行数:15,代码来源:yogaValuesConversions.cpp


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