fix comments before several types

tests pass
This commit is contained in:
Christopher Dunn 2015-01-20 11:09:36 -06:00
parent 37644abd77
commit 836f0fb863

View File

@ -163,14 +163,20 @@ bool Reader::readValue() {
successful = decodeString(token); successful = decodeString(token);
break; break;
case tokenTrue: case tokenTrue:
currentValue() = true; {
Value v(true);
currentValue().swapPayload(v);
currentValue().setOffsetStart(token.start_ - begin_); currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_); currentValue().setOffsetLimit(token.end_ - begin_);
}
break; break;
case tokenFalse: case tokenFalse:
currentValue() = false; {
Value v(false);
currentValue().swapPayload(v);
currentValue().setOffsetStart(token.start_ - begin_); currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_); currentValue().setOffsetLimit(token.end_ - begin_);
}
break; break;
case tokenNull: case tokenNull:
{ {
@ -185,7 +191,8 @@ bool Reader::readValue() {
// "Un-read" the current token and mark the current value as a null // "Un-read" the current token and mark the current value as a null
// token. // token.
current_--; current_--;
currentValue() = Value(); Value v;
currentValue().swapPayload(v);
currentValue().setOffsetStart(current_ - begin_ - 1); currentValue().setOffsetStart(current_ - begin_ - 1);
currentValue().setOffsetLimit(current_ - begin_); currentValue().setOffsetLimit(current_ - begin_);
break; break;
@ -450,7 +457,8 @@ bool Reader::readObject(Token& tokenStart) {
} }
bool Reader::readArray(Token& tokenStart) { bool Reader::readArray(Token& tokenStart) {
currentValue() = Value(arrayValue); Value init(arrayValue);
currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_); currentValue().setOffsetStart(tokenStart.start_ - begin_);
skipSpaces(); skipSpaces();
if (*current_ == ']') // empty array if (*current_ == ']') // empty array
@ -540,7 +548,7 @@ bool Reader::decodeDouble(Token& token) {
Value decoded; Value decoded;
if (!decodeDouble(token, decoded)) if (!decodeDouble(token, decoded))
return false; return false;
currentValue() = decoded; currentValue().swapPayload(decoded);
currentValue().setOffsetStart(token.start_ - begin_); currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_); currentValue().setOffsetLimit(token.end_ - begin_);
return true; return true;
@ -583,10 +591,11 @@ bool Reader::decodeDouble(Token& token, Value& decoded) {
} }
bool Reader::decodeString(Token& token) { bool Reader::decodeString(Token& token) {
std::string decoded; std::string decoded_string;
if (!decodeString(token, decoded)) if (!decodeString(token, decoded_string))
return false; return false;
currentValue() = decoded; Value decoded(decoded_string);
currentValue().swapPayload(decoded);
currentValue().setOffsetStart(token.start_ - begin_); currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_); currentValue().setOffsetLimit(token.end_ - begin_);
return true; return true;