本文整理汇总了C++中folly::dynamic::getDefault方法的典型用法代码示例。如果您正苦于以下问题:C++ dynamic::getDefault方法的具体用法?C++ dynamic::getDefault怎么用?C++ dynamic::getDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类folly::dynamic
的用法示例。
在下文中一共展示了dynamic::getDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logic_error
PhpFunc::PhpFunc(const folly::dynamic& d,
const fbstring& className) :
m_idlName(d["name"].asString()),
m_phpName(toPhpName(m_idlName)),
m_cppName(toCppName(m_idlName)),
m_className(className),
m_func(d),
m_desc(getFollyDynamicDefaultString(d, "desc", "")),
m_returnRef(d.getDefault("ref", "false") == "true"),
m_returnKindOf(KindOfNull),
m_returnCppType("void"),
m_returnPhpType("void"),
m_minNumParams(0),
m_numTypeChecks(0) {
if (isMethod() &&
m_idlName.find_last_of(NAMESPACE_STRING) != std::string::npos) {
throw std::logic_error(
folly::format("'{0}' is a method and cannot have a namespace in its name",
m_idlName).str()
);
}
auto returnIt = d.find("return");
if (returnIt != d.items().end()) {
auto retNode = returnIt->second;
auto typeIt = retNode.find("type");
if (typeIt != retNode.items().end()) {
auto type = typeIt->second;
if ((type.isString()) && (type != "void") && (type != "null")) {
m_returnKindOf = m_returnRef ? KindOfRef : kindOfFromDynamic(type);
m_returnCppType = typeString(type, true);
m_returnPhpType = phpTypeFromDataType(m_returnKindOf);
}
}
m_returnDesc = getFollyDynamicDefaultString(retNode, "desc", "");
}
auto args = d.find("args");
if (args == d.items().end() || !args->second.isArray()) {
throw std::logic_error(
folly::format("'{0}' must have an array field 'args'", m_idlName).str()
);
}
auto ret = d.find("return");
if (ret == d.items().end() || !ret->second.isObject() ||
ret->second.find("type") == ret->second.items().end()) {
throw std::logic_error(
folly::format("'{0}' must have an array field 'return', which must have "
"a string field 'type'", m_idlName).str()
);
}
bool magic = isMagicMethod();
m_flags = parseFlags(m_func["flags"]);
ParamMode paramMode = ParamMode::CoerceAndCall;
if (m_flags & ParamCoerceModeNull) {
paramMode = ParamMode::ZendNull;
} else if (m_flags & ParamCoerceModeFalse) {
paramMode = ParamMode::ZendFalse;
}
for (auto &p : args->second) {
PhpParam param(p, magic, paramMode);
m_params.push_back(param);
if (!param.hasDefault()) {
++m_minNumParams;
}
if (param.isCheckedType()) {
++m_numTypeChecks;
}
}
}