File: boostjson.h

package info (click to toggle)
simdjson 4.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,936 kB
  • sloc: cpp: 171,612; ansic: 19,122; sh: 1,126; python: 842; makefile: 47; ruby: 25; javascript: 13
file content (30 lines) | stat: -rw-r--r-- 620 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#ifdef SIMDJSON_COMPETITION_BOOSTJSON

#include "find_tweet.h"

namespace find_tweet {

struct boostjson {
  using StringType=std::string;

  bool run(simdjson::padded_string &json, uint64_t find_id, std::string &result) {

    auto root = boost::json::parse(json);
    for (const auto &tweet : root.at("statuses").as_array()) {
      if (tweet.at("id") == find_id) {
        result = tweet.at("text").as_string();
        return true;
      }
    }

    return false;
  }
};

BENCHMARK_TEMPLATE(find_tweet, boostjson)->UseManualTime();

} // namespace find_tweet

#endif // SIMDJSON_COMPETITION_BOOSTJSON