@@ -11,75 +11,66 @@ namespace stream {
1111// document
1212//
1313really_inline document::document (const dom::parser &parser, const uint8_t *buf) noexcept
14- : json{&parser.implementation ->structural_indexes [0 ], buf, parser.doc .string_buf .get ()} {
15- }
16-
17- really_inline element document::root () noexcept {
18- return element (json);
14+ : json{&parser.implementation ->structural_indexes [0 ], buf, parser.doc .string_buf .get (), 0 },
15+ root{json} {
1916}
2017
2118really_inline simdjson_result<array> document::get_array () noexcept {
22- return root () .get_array ();
19+ return root.get_array ();
2320}
2421really_inline simdjson_result<object> document::get_object () noexcept {
25- return root () .get_object ();
22+ return root.get_object ();
2623}
2724really_inline simdjson_result<raw_json_string> document::get_raw_json_string () noexcept {
28- return root () .get_raw_json_string ();
25+ return root.get_raw_json_string ();
2926}
3027// really_inline simdjson_result<std::string_view> document::get_string() noexcept {
31- // return root() .get_string();
28+ // return root.get_string();
3229// }
3330// really_inline simdjson_result<double> document::get_double() noexcept {
34- // return root() .get_double();
31+ // return root.get_double();
3532// }
3633really_inline simdjson_result<uint64_t > document::get_uint64 () noexcept {
37- return root () .get_uint64 ();
34+ return root.get_uint64 ();
3835}
3936really_inline simdjson_result<int64_t > document::get_int64 () noexcept {
40- return root () .get_int64 ();
37+ return root.get_int64 ();
4138}
4239// really_inline simdjson_result<bool> document::get_bool() noexcept {
43- // return root() .get_bool();
40+ // return root.get_bool();
4441// }
4542
46- // TODO users should never have to call this for things to work. Figure out how to make it happen
47- // in destructors or some other automatic mechanism.
48- inline error_code document::skip () noexcept {
49- return root ().skip ();
50- }
51-
5243#if SIMDJSON_EXCEPTIONS
5344really_inline document::operator array () noexcept (false ) {
54- return root () ;
45+ return root;
5546}
5647really_inline document::operator object () noexcept (false ) {
57- return root () ;
48+ return root;
5849}
5950really_inline document::operator raw_json_string () noexcept (false ) {
60- return root () ;
51+ return root;
6152}
6253// really_inline document::operator std::string_view() noexcept(false) {
63- // return root() ;
54+ // return root;
6455// }
6556// really_inline document::operator double() noexcept(false) {
66- // return root() ;
57+ // return root;
6758// }
6859really_inline document::operator uint64_t () noexcept (false ) {
69- return root () ;
60+ return root;
7061}
7162really_inline document::operator int64_t () noexcept (false ) {
72- return root () ;
63+ return root;
7364}
7465// really_inline element::operator bool() noexcept(false) {
75- // return root() ;
66+ // return root;
7667// }
7768
78- really_inline array::iterator document::begin () noexcept (false ) {
79- return get_array () .begin ();
69+ really_inline array_iterator document::begin () noexcept (false ) {
70+ return root .begin ();
8071}
81- really_inline array::iterator document::end () noexcept (false ) {
82- return get_array () .end ();
72+ really_inline array_iterator document::end () noexcept (false ) {
73+ return root .end ();
8374}
8475#endif // SIMDJSON_EXCEPTIONS
8576
@@ -93,10 +84,6 @@ really_inline simdjson_result<stream::document>::simdjson_result(stream::documen
9384really_inline simdjson_result<stream::document>::simdjson_result(stream::document &&value, error_code error) noexcept
9485 : internal::simdjson_result_base<stream::document>(std::forward<stream::document>(value), error) {}
9586
96- really_inline simdjson_result<stream::element> simdjson_result<stream::document>::root() noexcept {
97- return { first.json , error () };
98- }
99-
10087really_inline simdjson_result<stream::array> simdjson_result<stream::document>::get_array() & noexcept {
10188 return root ().get_array ();
10289}
@@ -122,10 +109,6 @@ really_inline simdjson_result<int64_t> simdjson_result<stream::document>::get_in
122109// return root().get_bool();
123110// }
124111
125- really_inline error_code simdjson_result<stream::document>::skip() noexcept {
126- return root ().skip ();
127- }
128-
129112#if SIMDJSON_EXCEPTIONS
130113really_inline simdjson_result<stream::document>::operator stream::array () noexcept (false ) {
131114 return root ();
@@ -152,17 +135,15 @@ really_inline simdjson_result<stream::document>::operator int64_t() noexcept(fal
152135// return root();
153136// }
154137
155- really_inline stream::array::iterator simdjson_result<stream::document>::begin() & noexcept (false ) {
156- printf (" begin\n " );
138+ really_inline stream::array_iterator simdjson_result<stream::document>::begin() & noexcept (false ) {
157139 return root ().begin ();
158140}
159- really_inline stream::array::iterator simdjson_result<stream::document>::end() & noexcept (false ) {
160- // We don't call get_array because it advances the iterator, and we already did that in begin()
161- // Here we assume the open array was already checked by begin()
162- printf (" end\n " );
163- auto result = root ().end ();
164- printf (" end2\n " );
165- return result;
141+ really_inline stream::array_iterator simdjson_result<stream::document>::end() & noexcept (false ) {
142+ return root ().end ();
143+ }
144+
145+ really_inline simdjson_result<stream::element&> simdjson_result<stream::document>::root() noexcept {
146+ return { first.root , error () };
166147}
167148
168149#endif // SIMDJSON_EXCEPTIONS
0 commit comments