本文整理汇总了C++中JsonWriter::writeBoolean方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonWriter::writeBoolean方法的具体用法?C++ JsonWriter::writeBoolean怎么用?C++ JsonWriter::writeBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonWriter
的用法示例。
在下文中一共展示了JsonWriter::writeBoolean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeTo
void JsonVariant::writeTo(JsonWriter &writer) const {
if (is<const JsonArray &>())
as<const JsonArray &>().writeTo(writer);
else if (is<const JsonObject &>())
as<const JsonObject &>().writeTo(writer);
else if (is<const char *>())
writer.writeString(as<const char *>());
else if (is<const String *>())
writer.writeString(as<const String *>()->c_str());
else if (is<long>())
writer.writeLong(as<long>());
else if (is<bool>())
writer.writeBoolean(as<bool>());
else if (is<double>()) {
uint8_t decimals = static_cast<uint8_t>(_type - JSON_DOUBLE_0_DECIMALS);
writer.writeDouble(as<double>(), decimals);
}
}
示例2: writeTo
void JsonVariant::writeTo(JsonWriter &writer) const {
if (_type == JSON_ARRAY)
_content.asArray->writeTo(writer);
else if (_type == JSON_OBJECT)
_content.asObject->writeTo(writer);
else if (_type == JSON_STRING)
writer.writeString(_content.asString);
else if (_type == JSON_UNPARSED)
writer.writeRaw(_content.asString);
else if (_type == JSON_INTEGER)
writer.writeInteger(_content.asInteger);
else if (_type == JSON_BOOLEAN)
writer.writeBoolean(_content.asInteger != 0);
else if (_type >= JSON_FLOAT_0_DECIMALS) {
uint8_t decimals = static_cast<uint8_t>(_type - JSON_FLOAT_0_DECIMALS);
writer.writeFloat(_content.asFloat, decimals);
}
}
示例3: writeTo
void JsonVariant::writeTo(JsonWriter &writer) const {
switch (_type) {
case JSON_UNDEFINED:
return;
case JSON_ARRAY:
_content.asArray->writeTo(writer);
return;
case JSON_OBJECT:
_content.asObject->writeTo(writer);
return;
case JSON_STRING:
writer.writeString(_content.asString);
return;
case JSON_UNPARSED:
writer.writeRaw(_content.asString);
return;
case JSON_NEGATIVE_INTEGER:
writer.writeRaw('-');
case JSON_POSITIVE_INTEGER:
writer.writeInteger(_content.asInteger);
return;
case JSON_BOOLEAN:
writer.writeBoolean(_content.asInteger != 0);
return;
default:
uint8_t decimals = static_cast<uint8_t>(_type - JSON_FLOAT_0_DECIMALS);
writer.writeFloat(_content.asFloat, decimals);
}
}