@@ -105,78 +105,6 @@ bool ParsedJson::iterator::move_forward() {
105105 return true ;
106106}
107107
108- uint8_t ParsedJson::iterator::get_type () const {
109- return current_type;
110- }
111-
112-
113- int64_t ParsedJson::iterator::get_integer () const {
114- if (location + 1 >= tape_length) {
115- return 0 ;// default value in case of error
116- }
117- return static_cast <int64_t >(pj.tape [location + 1 ]);
118- }
119-
120- double ParsedJson::iterator::get_double () const {
121- if (location + 1 >= tape_length) {
122- return NAN ;// default value in case of error
123- }
124- double answer;
125- memcpy (&answer, & pj.tape [location + 1 ], sizeof (answer));
126- return answer;
127- }
128-
129- const char * ParsedJson::iterator::get_string () const {
130- return reinterpret_cast <const char *>(pj.string_buf + (current_val & JSONVALUEMASK ) + sizeof (uint32_t )) ;
131- }
132-
133-
134- uint32_t ParsedJson::iterator::get_string_length () const {
135- uint32_t answer;
136- memcpy (&answer, reinterpret_cast <const char *>(pj.string_buf + (current_val & JSONVALUEMASK )), sizeof (uint32_t ));
137- return answer;
138- }
139-
140- bool ParsedJson::iterator::is_object_or_array () const {
141- return is_object_or_array (get_type ());
142- }
143-
144- bool ParsedJson::iterator::is_object () const {
145- return get_type () == ' {' ;
146- }
147-
148- bool ParsedJson::iterator::is_array () const {
149- return get_type () == ' [' ;
150- }
151-
152- bool ParsedJson::iterator::is_string () const {
153- return get_type () == ' "' ;
154- }
155-
156- bool ParsedJson::iterator::is_integer () const {
157- return get_type () == ' l' ;
158- }
159-
160- bool ParsedJson::iterator::is_double () const {
161- return get_type () == ' d' ;
162- }
163-
164- bool ParsedJson::iterator::is_true () const {
165- return get_type () == ' t' ;
166- }
167-
168- bool ParsedJson::iterator::is_false () const {
169- return get_type () == ' f' ;
170- }
171-
172- bool ParsedJson::iterator::is_null () const {
173- return get_type () == ' n' ;
174- }
175-
176- bool ParsedJson::iterator::is_object_or_array (uint8_t type) {
177- return (type == ' [' || (type == ' {' ));
178- }
179-
180108bool ParsedJson::iterator::move_to_key (const char * key) {
181109 if (down ()) {
182110 do {
@@ -195,24 +123,25 @@ bool ParsedJson::iterator::move_to_key(const char * key) {
195123
196124 bool ParsedJson::iterator::next () {
197125 if ((current_type == ' [' ) || (current_type == ' {' )){
198- // we need to jump
199- size_t npos = ( current_val & JSONVALUEMASK );
200- if (npos >= tape_length) {
126+ // we need to jump
127+ size_t npos = ( current_val & JSONVALUEMASK );
128+ if (npos >= tape_length) {
201129 return false ; // shoud never happen unless at the root
202- }
203- uint64_t nextval = pj.tape [npos];
204- uint8_t nexttype = (nextval >> 56 );
205- if ((nexttype == ' ]' ) || (nexttype == ' }' )) {
130+ }
131+ uint64_t nextval = pj.tape [npos];
132+ uint8_t nexttype = (nextval >> 56 );
133+ if ((nexttype == ' ]' ) || (nexttype == ' }' )) {
206134 return false ; // we reached the end of the scope
207- }
208- location = npos;
209- current_val = nextval;
210- current_type = nexttype;
211- return true ;
135+ }
136+ location = npos;
137+ current_val = nextval;
138+ current_type = nexttype;
139+ return true ;
212140 }
213141 size_t increment = (current_type == ' d' || current_type == ' l' ) ? 2 : 1 ;
214- if (location + increment >= tape_length) { return false ;
215- }
142+ if (location + increment >= tape_length) {
143+ return false ;
144+ }
216145 uint64_t nextval = pj.tape [location + increment];
217146 uint8_t nexttype = (nextval >> 56 );
218147 if ((nexttype == ' ]' ) || (nexttype == ' }' )) {
@@ -222,33 +151,33 @@ bool ParsedJson::iterator::move_to_key(const char * key) {
222151 current_val = nextval;
223152 current_type = nexttype;
224153 return true ;
225-
226154}
227155
228156
229157 bool ParsedJson::iterator::prev () {
230- if (location - 1 < depthindex[depth].start_of_scope ) { return false ;
231- }
158+ if (location - 1 < depthindex[depth].start_of_scope ) {
159+ return false ;
160+ }
232161 location -= 1 ;
233162 current_val = pj.tape [location];
234163 current_type = (current_val >> 56 );
235164 if ((current_type == ' ]' ) || (current_type == ' }' )){
236- // we need to jump
237- size_t new_location = ( current_val & JSONVALUEMASK );
238- if (new_location < depthindex[depth].start_of_scope ) {
165+ // we need to jump
166+ size_t new_location = ( current_val & JSONVALUEMASK );
167+ if (new_location < depthindex[depth].start_of_scope ) {
239168 return false ; // shoud never happen
240- }
241- location = new_location;
242- current_val = pj.tape [location];
243- current_type = (current_val >> 56 );
169+ }
170+ location = new_location;
171+ current_val = pj.tape [location];
172+ current_type = (current_val >> 56 );
244173 }
245174 return true ;
246175}
247176
248177
249178 bool ParsedJson::iterator::up () {
250179 if (depth == 1 ) {
251- return false ; // don't allow moving back to root
180+ return false ; // don't allow moving back to root
252181 }
253182 to_start_scope ();
254183 // next we just move to the previous value
@@ -261,8 +190,9 @@ bool ParsedJson::iterator::move_to_key(const char * key) {
261190
262191
263192 bool ParsedJson::iterator::down () {
264- if (location + 1 >= tape_length) { return false ;
265- }
193+ if (location + 1 >= tape_length) {
194+ return false ;
195+ }
266196 if ((current_type == ' [' ) || (current_type == ' {' )) {
267197 size_t npos = (current_val & JSONVALUEMASK );
268198 if (npos == location + 2 ) {
0 commit comments