| 164 | } |
| 165 | |
| 166 | bool Reader::readValue() { |
| 167 | // readValue() may call itself only if it calls readObject() or ReadArray(). |
| 168 | // These methods execute nodes_.push() just before and nodes_.pop)() just after calling readValue(). |
| 169 | // parse() executes one nodes_.push(), so > instead of >=. |
| 170 | if (nodes_.size() > stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue()."); |
| 171 | |
| 172 | Token token; |
| 173 | skipCommentTokens(token); |
| 174 | bool successful = true; |
| 175 | |
| 176 | if (collectComments_ && !commentsBefore_.empty()) { |
| 177 | currentValue().setComment(commentsBefore_, commentBefore); |
| 178 | commentsBefore_.clear(); |
| 179 | } |
| 180 | |
| 181 | switch (token.type_) { |
| 182 | case tokenObjectBegin: |
| 183 | successful = readObject(token); |
| 184 | currentValue().setOffsetLimit(current_ - begin_); |
| 185 | break; |
| 186 | case tokenArrayBegin: |
| 187 | successful = readArray(token); |
| 188 | currentValue().setOffsetLimit(current_ - begin_); |
| 189 | break; |
| 190 | case tokenNumber: |
| 191 | successful = decodeNumber(token); |
| 192 | break; |
| 193 | case tokenString: |
| 194 | successful = decodeString(token); |
| 195 | break; |
| 196 | case tokenTrue: |
| 197 | { |
| 198 | Value v(true); |
| 199 | currentValue().swapPayload(v); |
| 200 | currentValue().setOffsetStart(token.start_ - begin_); |
| 201 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 202 | } |
| 203 | break; |
| 204 | case tokenFalse: |
| 205 | { |
| 206 | Value v(false); |
| 207 | currentValue().swapPayload(v); |
| 208 | currentValue().setOffsetStart(token.start_ - begin_); |
| 209 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 210 | } |
| 211 | break; |
| 212 | case tokenNull: |
| 213 | { |
| 214 | Value v; |
| 215 | currentValue().swapPayload(v); |
| 216 | currentValue().setOffsetStart(token.start_ - begin_); |
| 217 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 218 | } |
| 219 | break; |
| 220 | case tokenArraySeparator: |
| 221 | case tokenObjectEnd: |
| 222 | case tokenArrayEnd: |
| 223 | if (features_.allowDroppedNullPlaceholders_) { |
nothing calls this directly
no test coverage detected