当前位置: 首页>>代码示例>>C++>>正文


C++ dynamic::size方法代码示例

本文整理汇总了C++中dynamic::size方法的典型用法代码示例。如果您正苦于以下问题:C++ dynamic::size方法的具体用法?C++ dynamic::size怎么用?C++ dynamic::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dynamic的用法示例。


在下文中一共展示了dynamic::size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: del

int MCRouterTestClient::del(const dynamic &keys, bool local,
                            dynamic &results) {

  std::vector<mcrouter_msg_t> msgs(keys.size());
  dynamic raw_results = dynamic::object;

  for (int i = 0; i < keys.size(); i ++) {
    auto key = keys[i].asString().toStdString();
    if (!local) {
      key = "/*/*/" + key;
    }
    msgs[i] = make_delete_request(key);
  }

  int ret = 0;
  bool res = issueRequests(msgs.data(), keys.size(), raw_results);
  if (res) {
    for ( auto& raw_reply : raw_results.items() ) {
      bool found = (raw_reply.second["result"] == (int) mc_res_deleted);
      results[raw_reply.first] = found;
      ret += (int) found;
    }
  }
  return ret;
}
开发者ID:0xd3adsh3ll,项目名称:mcrouter,代码行数:25,代码来源:mcrouter_test_client.cpp

示例2: makeError

 Optional<SchemaError> validate(ValidationContext& vc,
                                const dynamic& value) const override {
   if (!value.isArray()) {
     return none;
   }
   if (itemsValidator_) {
     for (const auto& v : value) {
       if (auto se = vc.validate(itemsValidator_.get(), v)) {
         return se;
       }
     }
     return none;
   }
   size_t pos = 0;
   for (; pos < value.size() && pos < itemsValidators_.size(); ++pos) {
     if (auto se = vc.validate(itemsValidators_[pos].get(), value[pos])) {
       return se;
     }
   }
   if (!allowAdditionalItems_ && pos < value.size()) {
     return makeError("no more additional items", value);
   }
   if (additionalItemsValidator_) {
     for (; pos < value.size(); ++pos) {
       if (auto se =
               vc.validate(additionalItemsValidator_.get(), value[pos])) {
         return se;
       }
     }
   }
   return none;
 }
开发者ID:AddictXQ,项目名称:folly,代码行数:32,代码来源:JSONSchema.cpp

示例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;
    }
}
开发者ID:Lyoko-Jeremie,项目名称:nativejson-benchmark,代码行数:46,代码来源:follytest.cpp

示例4: bserEncodeArraySimple

static void bserEncodeArraySimple(dynamic const& dyn,
                                  QueueAppender& appender,
                                  const serialization_opts& opts) {
  appender.write((int8_t)BserType::Array);
  bserEncodeInt(dyn.size(), appender);
  for (const auto& ele : dyn) {
    bserEncode(ele, appender, opts);
  }
}
开发者ID:1Hgm,项目名称:folly,代码行数:9,代码来源:Dump.cpp

示例5: runtime_error

EpochCrontabItem::EpochCrontabItem(
  const dynamic& d, boost::local_time::time_zone_ptr tz
) : CrontabItem(tz),
    epoch_sel_(d.getDefault("epoch"), 0, std::numeric_limits<time_t>::max()) {

  if (d.size() != 1) {
    throw runtime_error(
      "Can only have the 'epoch' key: " + folly::toJson(d).toStdString()
    );
  }
}
开发者ID:conkeyn,项目名称:bistro,代码行数:11,代码来源:EpochCrontabItem.cpp

示例6: get

int MCRouterTestClient::get(const dynamic &keys,
                            dynamic &results) {
  std::vector<mcrouter_msg_t> msgs(keys.size());
  int ret = 0;
  dynamic raw_results = dynamic::object;

  for (int i = 0; i < keys.size(); i ++) {
    msgs[i] = make_get_request(keys[i].asString().toStdString());
  }

  bool res = issueRequests(msgs.data(), keys.size(), raw_results);
  assert(res);
  for ( auto & raw_reply : raw_results.items() ) {
    if (raw_reply.second["result"] == (int) mc_res_found) {
      results[raw_reply.first] = raw_reply.second["value"];
      ret ++;
    }
  }
  return ret;

}
开发者ID:0xd3adsh3ll,项目名称:mcrouter,代码行数:21,代码来源:mcrouter_test_client.cpp

示例7: set

int MCRouterTestClient::set(const dynamic &kv_pairs,
                            dynamic &results) {
  std::vector<mcrouter_msg_t> msgs(kv_pairs.size());
  int i = 0;
  dynamic raw_results = dynamic::object;

  for (auto &kv_pair : kv_pairs.items()) {
    msgs[i] = make_set_request(kv_pair.first.asString().toStdString(),
                               kv_pair.second.asString().toStdString());
    i ++;
  }

  int ret = 0;
  bool res = issueRequests(msgs.data(), kv_pairs.size(), raw_results);
  if (res) {
    for ( auto& raw_reply : raw_results.items()) {
      bool stored = (raw_reply.second["result"] == (int) mc_res_stored);
      results[raw_reply.first] = stored;
      ret += (int) stored;
    }
  }
  return ret;
}
开发者ID:0xd3adsh3ll,项目名称:mcrouter,代码行数:23,代码来源:mcrouter_test_client.cpp

示例8: bserEncodeObject

static void bserEncodeObject(dynamic const& dyn,
                             QueueAppender& appender,
                             const serialization_opts& opts) {
  appender.write((int8_t)BserType::Object);
  bserEncodeInt(dyn.size(), appender);

  if (opts.sort_keys) {
    std::vector<std::pair<dynamic, dynamic>> sorted(dyn.items().begin(),
                                                    dyn.items().end());
    std::sort(sorted.begin(), sorted.end());
    for (const auto& item : sorted) {
      bserEncode(item.first, appender, opts);
      bserEncode(item.second, appender, opts);
    }
  } else {
    for (const auto& item : dyn.items()) {
      bserEncode(item.first, appender, opts);
      bserEncode(item.second, appender, opts);
    }
  }
}
开发者ID:1Hgm,项目名称:folly,代码行数:21,代码来源:Dump.cpp

示例9: bserEncodeArray

static void bserEncodeArray(dynamic const& dyn,
                            QueueAppender& appender,
                            const serialization_opts& opts) {

  auto templ = getTemplate(opts, dyn);
  if (UNLIKELY(templ != nullptr)) {
    appender.write((int8_t)BserType::Template);

    // Emit the list of property names
    bserEncodeArraySimple(*templ, appender, opts);

    // The number of objects in the array
    bserEncodeInt(dyn.size(), appender);

    // For each object in the array
    for (const auto& ele : dyn) {
      // For each key in the template
      for (const auto& name : *templ) {
        if (auto found = ele.get_ptr(name)) {
          if (found->isNull()) {
            // Prefer to Skip rather than encode a null value for
            // compatibility with the other bser implementations
            appender.write((int8_t)BserType::Skip);
          } else {
            bserEncode(*found, appender, opts);
          }
        } else {
          appender.write((int8_t)BserType::Skip);
        }
      }
    }
    return;
  }

  bserEncodeArraySimple(dyn, appender, opts);
}
开发者ID:1Hgm,项目名称:folly,代码行数:36,代码来源:Dump.cpp


注:本文中的dynamic::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。