本文整理汇总了C++中rapidjson::Value::GetArray方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::GetArray方法的具体用法?C++ Value::GetArray怎么用?C++ Value::GetArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Value
的用法示例。
在下文中一共展示了Value::GetArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserializeQueryData
Status deserializeQueryData(const rj::Value& v, QueryDataSet& qd) {
if (!v.IsArray()) {
return Status(1, "JSON object was not an array");
}
for (const auto& i : v.GetArray()) {
Row r;
auto status = deserializeRow(i, r);
if (!status.ok()) {
return status;
}
qd.insert(std::move(r));
}
return Status();
}
示例2:
// parse coordinate pair from JSON array
osmium::geom::Coordinates parse_coordinate(const rapidjson::Value& value) {
if (!value.IsArray()) {
throw config_error{"Coordinates must be an array."};
}
const auto array = value.GetArray();
if (array.Size() != 2) {
throw config_error{"Coordinates array must have exactly two elements."};
}
if (array[0].IsNumber() && array[1].IsNumber()) {
return osmium::geom::Coordinates{array[0].GetDouble(), array[1].GetDouble()};
}
throw config_error{"Coordinates array must contain numbers."};
}
示例3: parseExtensions
void Client::parseExtensions(const rapidjson::Value &value)
{
if (!value.IsArray()) {
return;
}
for (const rapidjson::Value &ext : value.GetArray()) {
if (!ext.IsString()) {
continue;
}
if (strcmp(ext.GetString(), "nicehash") == 0) {
m_nicehash = true;
}
}
}
示例4: parse_multipolygon_array
std::size_t parse_multipolygon_array(const rapidjson::Value& value, osmium::memory::Buffer& buffer) {
assert(value.IsArray());
const auto array = value.GetArray();
if (array.Empty()) {
throw config_error{"Multipolygon must contain at least one polygon array."};
}
{
osmium::builder::AreaBuilder builder{buffer};
for (const auto& polygon : array) {
if (!polygon.IsArray()) {
throw config_error{"Polygon must be an array."};
}
parse_rings(polygon, builder);
}
}
return buffer.commit();
}
示例5: parse_rings
void parse_rings(const rapidjson::Value& value, osmium::builder::AreaBuilder& builder) {
assert(value.IsArray());
const auto array = value.GetArray();
if (array.Empty()) {
throw config_error{"Polygon must contain at least one ring."};
}
{
const auto outer_ring = parse_ring(array[0]);
osmium::builder::OuterRingBuilder ring_builder{builder};
for (const auto& c : outer_ring) {
osmium::Location loc{c.x, c.y};
if (loc.valid()) {
ring_builder.add_node_ref(0, loc);
} else {
throw config_error{"Invalid location in boundary (multi)polygon: (" +
std::to_string(c.x) +
", " +
std::to_string(c.y) + ")."};
}
}
}
for (unsigned int i = 1; i < array.Size(); ++i) {
const auto inner_ring = parse_ring(array[i]);
osmium::builder::InnerRingBuilder ring_builder{builder};
for (const auto& c : inner_ring) {
osmium::Location loc{c.x, c.y};
if (loc.valid()) {
ring_builder.add_node_ref(0, loc);
} else {
throw config_error{"Invalid location in boundary (multi)polygon: (" +
std::to_string(c.x) +
", " +
std::to_string(c.y) + ")."};
}
}
}
}
示例6: loadJson
void ArchiveStack::loadJson(const rapidjson::Value& lensStack) {
for (const auto& metadata : lensStack.GetArray()) {
stack_.push_back(ArchiveMetadata::fromJson(metadata));
}
}