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


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

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


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

示例1: dispatchScrollViewEvent

void ScrollViewEventEmitter::dispatchScrollViewEvent(
    const std::string &name,
    const ScrollViewMetrics &scrollViewMetrics,
    const folly::dynamic &payload) const {
  folly::dynamic compoundPayload = folly::dynamic::object();

  compoundPayload["contentOffset"] =
      folly::dynamic::object("x", scrollViewMetrics.contentOffset.x)(
          "y", scrollViewMetrics.contentOffset.y);

  compoundPayload["contentInset"] =
      folly::dynamic::object("top", scrollViewMetrics.contentInset.top)(
          "left", scrollViewMetrics.contentInset.left)(
          "bottom", scrollViewMetrics.contentInset.bottom)(
          "right", scrollViewMetrics.contentInset.right);

  compoundPayload["contentSize"] =
      folly::dynamic::object("width", scrollViewMetrics.contentSize.width)(
          "height", scrollViewMetrics.contentSize.height);

  compoundPayload["layoutMeasurement"] =
      folly::dynamic::object("width", scrollViewMetrics.containerSize.width)(
          "height", scrollViewMetrics.containerSize.height);

  compoundPayload["zoomScale"] = scrollViewMetrics.zoomScale;

  if (!payload.isNull()) {
    compoundPayload.merge_patch(payload);
  }

  dispatchEvent(name, compoundPayload);
}
开发者ID:Kuchitama,项目名称:react-native,代码行数:32,代码来源:ScrollViewEventEmitter.cpp

示例2: 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

示例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: logic_error

static unsigned long parseFlags(const folly::dynamic &flags) {
  if (flags.isNull()) {
    return 0;
  }
  if (!flags.isArray()) {
    throw std::logic_error("'flags' field must be an array");
  }

  unsigned long ret = 0;
  for (auto &flag : flags) {
    auto f = g_flagsMap.find(flag.asString());
    if (f == g_flagsMap.end()) {
      throw std::logic_error(
        folly::format("Unknown flag '{0}' specified", flag.asString()).str()
      );
    }
    ret |= f->second;
  }
  return ret;
}
开发者ID:abacaxinho,项目名称:hhvm,代码行数:20,代码来源:idl.cpp

示例5:

jni::local_ref<NativeArray::jhybridobject>
createReadableNativeArrayWithContents(folly::dynamic array) {
  if (array.isNull()) {
    return jni::local_ref<NativeArray::jhybridobject>();
  }

  if (!array.isArray()) {
    jni::throwNewJavaException("com/facebook/react/bridge/UnexpectedNativeTypeException",
                               "expected Array, got a %s", array.typeName());
  }

  static auto readableNativeArrayClass =
    jni::findClassStatic("com/facebook/react/bridge/ReadableNativeArray");
  static auto readableNativeArrayCtor =
    readableNativeArrayClass->getConstructor<NativeArray::jhybridobject()>();

  auto jnewArray = readableNativeArrayClass->newObject(readableNativeArrayCtor);
  jni::cthis(jnewArray)->array = std::move(array);
  return jnewArray;
}
开发者ID:309746069,项目名称:react-native,代码行数:20,代码来源:NativeArray.cpp

示例6: kindOfFromValue

// Infer type from an actual value, e.g. 123, "foo", null, true, etc...
static DataType kindOfFromValue(const folly::dynamic& v) {
  if (v.isNull()) {
    return KindOfNull;
  }
  if (v.isBool()) {
    return KindOfBoolean;
  }
  if (v.isInt()) {
    return KindOfInt64;
  }
  if (v.isDouble()) {
    return KindOfDouble;
  }
  if (v.isString()) {
    return KindOfString;
  }
  if (v.isArray()) {
    return KindOfArray;
  }
  if (v.isObject()) {
    return KindOfObject;
  }
  return KindOfInvalid;
}
开发者ID:CodingBots,项目名称:hhvm,代码行数:25,代码来源:idl.cpp


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