本文整理汇总了C++中dynamic::getBool方法的典型用法代码示例。如果您正苦于以下问题:C++ dynamic::getBool方法的具体用法?C++ dynamic::getBool怎么用?C++ dynamic::getBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dynamic
的用法示例。
在下文中一共展示了dynamic::getBool方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cint
TEST(Dynamic, GetSmallThings) {
const dynamic cint(5);
const dynamic cdouble(5.0);
const dynamic cbool(true);
dynamic dint(5);
dynamic ddouble(5.0);
dynamic dbool(true);
dynamic mint(5);
dynamic mdouble(5.0);
dynamic mbool(true);
EXPECT_EQ(5, cint.getInt());
dint.getInt() = 6;
EXPECT_EQ(6, dint.getInt());
EXPECT_EQ(5, std::move(mint).getInt());
EXPECT_EQ(5.0, cdouble.getDouble());
ddouble.getDouble() = 6.0;
EXPECT_EQ(6.0, ddouble.getDouble());
EXPECT_EQ(5.0, std::move(mdouble).getDouble());
EXPECT_EQ(true, cbool.getBool());
dbool.getBool() = false;
EXPECT_FALSE(dbool.getBool());
EXPECT_EQ(true, std::move(mbool).getBool());
}
示例2: bserEncode
static void bserEncode(dynamic const& dyn,
QueueAppender& appender,
const serialization_opts& opts) {
switch (dyn.type()) {
case dynamic::Type::NULLT:
appender.write((int8_t)BserType::Null);
return;
case dynamic::Type::BOOL:
appender.write(
(int8_t)(dyn.getBool() ? BserType::True : BserType::False));
return;
case dynamic::Type::DOUBLE: {
double dval = dyn.getDouble();
appender.write((int8_t)BserType::Real);
appender.write(dval);
return;
}
case dynamic::Type::INT64:
bserEncodeInt(dyn.getInt(), appender);
return;
case dynamic::Type::OBJECT:
bserEncodeObject(dyn, appender, opts);
return;
case dynamic::Type::ARRAY:
bserEncodeArray(dyn, appender, opts);
return;
case dynamic::Type::STRING:
bserEncodeString(dyn.getString(), appender);
return;
}
}
示例3: GenStat
static void GenStat(Stat& stat, const dynamic& v) {
switch (v.type()) {
case dynamic::ARRAY:
{
for (auto &i : v)
GenStat(stat, i);
stat.arrayCount++;
stat.elementCount += v.size();
}
break;
case dynamic::OBJECT:
{
auto p = v.items();
for (auto& i : p) {
GenStat(stat, i.second);
stat.stringLength += i.first.size();
}
stat.objectCount++;
stat.memberCount += v.size();
stat.stringCount += v.size();
}
break;
case dynamic::STRING:
stat.stringCount++;
stat.stringLength += v.size();
break;
case dynamic::INT64:
case dynamic::DOUBLE:
stat.numberCount++;
break;
case dynamic::BOOL:
if (v.getBool())
stat.trueCount++;
else
stat.falseCount++;
break;
case dynamic::NULLT:
stat.nullCount++;
break;
}
}
示例4: ArrayUniqueValidator
explicit ArrayUniqueValidator(const dynamic& schema) : unique_(false) {
if (schema.isBool()) {
unique_ = schema.getBool();
}
}