本文整理汇总了C++中folly::dynamic::stringPiece方法的典型用法代码示例。如果您正苦于以下问题:C++ dynamic::stringPiece方法的具体用法?C++ dynamic::stringPiece怎么用?C++ dynamic::stringPiece使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类folly::dynamic
的用法示例。
在下文中一共展示了dynamic::stringPiece方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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);
}
}
示例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));
}
示例4: 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) };
}