| 149 | } |
| 150 | |
| 151 | bool Reader::readValue() { |
| 152 | // readValue() may call itself only if it calls readObject() or ReadArray(). |
| 153 | // These methods execute nodes_.push() just before and nodes_.pop)() just |
| 154 | // after calling readValue(). parse() executes one nodes_.push(), so > instead |
| 155 | // of >=. |
| 156 | if (nodes_.size() > stackLimit_g) |
| 157 | throwRuntimeError("Exceeded stackLimit in readValue()."); |
| 158 | |
| 159 | Token token; |
| 160 | readTokenSkippingComments(token); |
| 161 | bool successful = true; |
| 162 | |
| 163 | if (collectComments_ && !commentsBefore_.empty()) { |
| 164 | currentValue().setComment(commentsBefore_, commentBefore); |
| 165 | commentsBefore_.clear(); |
| 166 | } |
| 167 | |
| 168 | switch (token.type_) { |
| 169 | case tokenObjectBegin: |
| 170 | successful = readObject(token); |
| 171 | currentValue().setOffsetLimit(current_ - begin_); |
| 172 | break; |
| 173 | case tokenArrayBegin: |
| 174 | successful = readArray(token); |
| 175 | currentValue().setOffsetLimit(current_ - begin_); |
| 176 | break; |
| 177 | case tokenNumber: |
| 178 | successful = decodeNumber(token); |
| 179 | break; |
| 180 | case tokenString: |
| 181 | successful = decodeString(token); |
| 182 | break; |
| 183 | case tokenTrue: { |
| 184 | Value v(true); |
| 185 | currentValue().swapPayload(v); |
| 186 | currentValue().setOffsetStart(token.start_ - begin_); |
| 187 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 188 | } break; |
| 189 | case tokenFalse: { |
| 190 | Value v(false); |
| 191 | currentValue().swapPayload(v); |
| 192 | currentValue().setOffsetStart(token.start_ - begin_); |
| 193 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 194 | } break; |
| 195 | case tokenNull: { |
| 196 | Value v; |
| 197 | currentValue().swapPayload(v); |
| 198 | currentValue().setOffsetStart(token.start_ - begin_); |
| 199 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 200 | } break; |
| 201 | case tokenArraySeparator: |
| 202 | case tokenObjectEnd: |
| 203 | case tokenArrayEnd: |
| 204 | if (features_.allowDroppedNullPlaceholders_) { |
| 205 | // "Un-read" the current token and mark the current value as a null |
| 206 | // token. |
| 207 | current_--; |
| 208 | Value v; |
nothing calls this directly
no test coverage detected