File: ondemand.h

package info (click to toggle)
simdjson 4.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 31,400 kB
  • sloc: cpp: 195,760; ansic: 20,954; sh: 1,126; python: 885; makefile: 47; ruby: 25; javascript: 13
file content (37 lines) | stat: -rw-r--r-- 813 bytes parent folder | download | duplicates (7)
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
31
32
33
34
35
36
37
#pragma once

#if SIMDJSON_EXCEPTIONS

#include "largerandom.h"

namespace largerandom {

using namespace simdjson;

class OnDemand {
public:
  simdjson_inline bool Run(const padded_string &json);
  simdjson_inline const std::vector<my_point> &Result() { return container; }
  simdjson_inline size_t ItemCount() { return container.size(); }

private:
  ondemand::parser parser{};
  std::vector<my_point> container{};
};

simdjson_inline bool OnDemand::Run(const padded_string &json) {
  container.clear();

  auto doc = parser.iterate(json);
  for (ondemand::object coord : doc) {
    container.emplace_back(my_point{coord.find_field("x"), coord.find_field("y"), coord.find_field("z")});
  }

  return true;
}

BENCHMARK_TEMPLATE(LargeRandom, OnDemand);

} // namespace largerandom

#endif // SIMDJSON_EXCEPTIONS