1 | namespace simdjson { |
---|---|
2 | namespace SIMDJSON_IMPLEMENTATION { |
3 | namespace ondemand { |
4 | |
5 | // clang 6 doesn't think the default constructor can be noexcept, so we make it explicit |
6 | simdjson_inline field::field() noexcept : std::pair<raw_json_string, ondemand::value>() {} |
7 | |
8 | simdjson_inline field::field(raw_json_string key, ondemand::value &&value) noexcept |
9 | : std::pair<raw_json_string, ondemand::value>(key, std::forward<ondemand::value>(t&: value)) |
10 | { |
11 | } |
12 | |
13 | simdjson_inline simdjson_result<field> field::start(value_iterator &parent_iter) noexcept { |
14 | raw_json_string key; |
15 | SIMDJSON_TRY( parent_iter.field_key().get(key) ); |
16 | SIMDJSON_TRY( parent_iter.field_value() ); |
17 | return field::start(parent_iter, key); |
18 | } |
19 | |
20 | simdjson_inline simdjson_result<field> field::start(const value_iterator &parent_iter, raw_json_string key) noexcept { |
21 | return field(key, parent_iter.child()); |
22 | } |
23 | |
24 | simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> field::unescaped_key(bool allow_replacement) noexcept { |
25 | SIMDJSON_ASSUME(first.buf != nullptr); // We would like to call .alive() but Visual Studio won't let us. |
26 | simdjson_result<std::string_view> answer = first.unescape(iter&: second.iter.json_iter(), allow_replacement); |
27 | first.consume(); |
28 | return answer; |
29 | } |
30 | |
31 | simdjson_inline raw_json_string field::key() const noexcept { |
32 | SIMDJSON_ASSUME(first.buf != nullptr); // We would like to call .alive() by Visual Studio won't let us. |
33 | return first; |
34 | } |
35 | |
36 | simdjson_inline value &field::value() & noexcept { |
37 | return second; |
38 | } |
39 | |
40 | simdjson_inline value field::value() && noexcept { |
41 | return std::forward<field>(t&: *this).second; |
42 | } |
43 | |
44 | } // namespace ondemand |
45 | } // namespace SIMDJSON_IMPLEMENTATION |
46 | } // namespace simdjson |
47 | |
48 | namespace simdjson { |
49 | |
50 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field>::simdjson_result( |
51 | SIMDJSON_IMPLEMENTATION::ondemand::field &&value |
52 | ) noexcept : |
53 | implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::field>( |
54 | std::forward<SIMDJSON_IMPLEMENTATION::ondemand::field>(t&: value) |
55 | ) |
56 | { |
57 | } |
58 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field>::simdjson_result( |
59 | error_code error |
60 | ) noexcept : |
61 | implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::field>(error) |
62 | { |
63 | } |
64 | |
65 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field>::key() noexcept { |
66 | if (error()) { return error(); } |
67 | return first.key(); |
68 | } |
69 | simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field>::unescaped_key(bool allow_replacement) noexcept { |
70 | if (error()) { return error(); } |
71 | return first.unescaped_key(allow_replacement); |
72 | } |
73 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field>::value() noexcept { |
74 | if (error()) { return error(); } |
75 | return std::move(first.value()); |
76 | } |
77 | |
78 | } // namespace simdjson |
79 |